Is it possible to convert graphics object to image object?
I now design app like a audio player with waveform viewer.
On the current code, waveform is repainted every paint function called
but it is high cpu load.
So, I want to convert Grapchis object to Image object.
If it is possible,
I draw waveform using many lines(strokePath) at the initial time only and
after that I convert the waveform(Graphics Object) to image object.
I want to draw the image object
without redrawing many waveform lines when paint function called.
You can either call setBufferedToImage() for the component in question and it will draw to an image in this way for you. Or you can draw to your own image by creating a Graphics from an image whenever you actually need to update the image (usually when the audio data changes or when the component is resized):
``
{
image = image (Image::ARGB, imageWidth, imageHeight, true); // image is member of your component
Graphics g (image);
// draw with g as usual…
}
Then in your `paint()` method:
`g.drawImageAt (image, 0, 0);`