Just using Juce Image

Hi

I’m in the slow progress of moving towards a Juce version of my plugin. For now I really only want to use the Image class of Juce. I would like to use the loading functions ( which i got working ) and the painting functions. I have great trouble getting the images on screen. At the moment I use the following code, but that does not work. How can I do something similar for just getting an Image on screen. Outside the scope of this function I would like to use as less Juce as possible since I’m using my own graphics framework there.

Any suggestions ?

Kind regards,
Jankoen

[code]// beware the following code does not work !
if ( fJuceImage.isValid() )
{
juce::Image nativeBitmap( juce::Image::ARGB, dest.GetWidth(), dest.GetHeight(), true );

const juce::ScopedPointerjuce::LowLevelGraphicsContext lowLevelBM( nativeBitmap.createLowLevelContext() );

juce::Graphics juceG( lowLevelBM );

juceG.drawImageWithin( fJuceImage, 0,0, dest.GetWidth(), dest.GetHeight(), juce::RectanglePlacement( juce::RectanglePlacement::fillDestination ), false );

}[/code]

Seems a bit confused… Why are you trying to use a low-level context rather than just creating the Graphics from the image directly?

Wish I knew. I tried the following code too, but i could not get the image on screen. Are you telling me the following could should work ?

somewhere in the beginning of my code I call:

and then I load an Image

juce::MemoryInputStream imageDataStream( inData->GetDataPtr(), inData->GetDataSize(), false );

fJuceImage = juce::ImageFileFormat::loadFrom( imageDataStream );

I know for sure the Image loaded correctly, because I could extract the Bitmap and convert it to my own internal format. But I don’t want to go that way.

Then the third thing I do Is trying to get the Image on sreen:

[code]
if ( fJuceImage.isValid() )
{
juce::Image nativeBitmap( juce::Image::ARGB, dest.GetWidth(), dest.GetHeight(), true);

juce::Graphics juceG( nativeBitmap );
	
juceG.drawImageWithin( fJuceImage, 0,0, dest.GetWidth(), dest.GetHeight(), juce::RectanglePlacement( juce::RectanglePlacement::fillDestination ), false );

}[/code]

But I don’t see it. Do think this code should work ?

Regards,
Jankoen

Well, if all of the sizes and data that you’re feeding to it are correct, then I can’t see any obvious mistakes.

[code]if ( fJuceImage.isValid() )
{
juce::Image nativeBitmap( juce::Image::ARGB, dest.GetWidth(), dest.GetHeight(), true);

juce::Graphics juceG( nativeBitmap );

juceG.drawImageWithin( fJuceImage, 0,0, dest.GetWidth(), dest.GetHeight(), juce::RectanglePlacement( juce::RectanglePlacement::fillDestination ), false );
}[/code]

You’re writing into a local variable (nativeBitmap) not onto the screen . It’s perfectly normal nothing is drawn.
You should paint into the Graphics object in the arg of the paint function.

Am I missing something ?

But how can JUCE know to which HWND to draw ?

…so you were expecting your code to actually draw something? I thought you were just preparing an image. Haven’t you looked at any of the example code??

Well, actually I was not expecting this code to draw something since the link with an HWND is non existant. I was hoping to get a little push in the right direction to get something like this to draw something.

ostristan helped me on this way.

Thanks