I am drawing on a small image and then trying to transfer that to same size ImageButton. When I load an image from Binary Resource to the button it shows fine, but for some reason I am missing something when trying to draw and then transfer the image to my button.
// From header file
private:
Image loadImage, plot;
ImageButton loadButton, myImageButton;
DetailLFO::DetailLFO()
{
loadImage = ImageCache::getFromMemory (
BinaryData::buttonload_png, BinaryData::buttonload_pngSize);
loadButton.setImages (false, true, true, loadImage, 0.75f,
Colours::transparentBlack, loadImage, 1.0f, Colours::transparentWhite,
loadImage, 1.0f, Colours::transparentBlack);
int buttonSize = 64;
plot = Image (Image::PixelFormat::RGB, buttonSize, buttonSize / 2, false);
// Clear image
plot.clear (Rectangle<int> (0, 0, buttonSize, buttonSize / 2), Colour (0x000000));
// Draw image
for (int i = 0; i < buttonSize; i++)
plot.setPixelAt (i, i / 2, Colours::green);
myImageButton.setComponentID ("Saw waveform");
myImageButton.setImages (false, true, true, plot, 0.75f,
Colours::transparentBlack, plot, 1.0f, Colours::transparentWhite,
plot, 1.0f, Colours::transparentBlack);
addAndMakeVisible (myImageButton);
}
I position the button in “resized()” and as I described if I instead replace the “plot” image with a binary resource image, it shows fine.