(Background) Image not shown at all


#1

Hi everybody, i've been trying to include a  background image in an audio plugin,

but it isn't shown at all ...

I've included the image (tried bmp and png so far) as BinaryData using IntroJucer. It worked.

I've declared the image in PluginEditor.h and initialized it in PluginEditor.cpp (in the same way i initialized sliders, ect, in the constructor):

backgroundImage(ImageCache::getFromMemory(BinaryData::bmp00129_bmp, BinaryData::bmp00129_bmpSize)),

Now, in the paint() method, i called:

 g.drawImageAt(backgroundImage, 0, 0, true);

(also tried 'false' for the boolean flag).

Everything compiles fine, there are no problems when i load the plugin in the plugin host, BUT ... there's no image ... sliders and everything is shown ...

Any idea?

Regards,

n


#2

Do other things within paint() draws correctly?

Try drawing just the background without any other visual elements. does it work?


#3

No, if i only try to draw the image, there’s just a black field …


#4

Are you enabling OpenGL context?


#5

No, should i ?


#6

a) you can check with a breakpoint of your debugger, if the backgroundImage has a size of non zero. So you can check if the loading worked

b) comment everything else in the paint method so there is only the image drawn, maybe something later in your code covers everything in black?

c) remove all children: comment all addAndMakeVisible calls in the constructor, they can overpaint too

d) Check that you didn't instanciate your own Graphics instance, only use the one you get as argument from paint(Graphics* g);

Do you hide the "g" unintentionally? similar to:

void Component::paint (Graphics& g)

{

if (true) {

Graphics g;

g.drawImageAt( backgroundImage, 0, 0, true);

}

}

then drawImageAt doesnt reach the graphics context...

Good luck

 


#7

a) Is there some Tutorial on how to use a debugger for audio plugins ? But anyway, manual debug output is fine ! The image is included as BinaryData, anyway, and the BinaryData isn’t empty !

b) Did that, to no avail …

c) Did that, to no avail …

d) “g” is not hidden !

Would it help to use an ImageComponent or something ?


#8

Ok, i just found out that

 

 ImageCache::getFromMemory(BinaryData::bmp00129_bmp, BinaryData::bmp00129_bmpSize)

returns an invalid image, though the BinaryData itself is populated correctly ... any ideas why ?


#9

You know that there's no cross-platform .bmp parser in juce? On OSX the system's image loader may handle it, but I wouldn't count on it.

(And surely you'd want to use pngs instead for your embedded images, which are lossless and smaller than bmps!)


#10

you do it rad, take my bad code, and make it better !!

 

Yes, that was the problem ... with png, the background image is displayed perfectly !

 

Thanks !