Hi, i’m making a program to display an image buffer on a window, the image buffer can be reallocated during the execution of the program when the user resizes the window.
The function i’m using to map the image is:
Component::paint() {
g.drawImage(image......);
To allow the reallication of an image object i’ve created a class
class FrameBufferWrapper: public Image {
...
};
In that class I have a function to reallocate the image buffer
[code]unsigned char* FrameBufferWrapper::reallocBuffer(unsigned width, unsigned height) {
imageData = (uint8*)realloc((uint8*)imageData,
width * height * bytes_per_pixel);
imageWidth = width; // Problem here, const member
imageHeight = height; // Problem here, const member
pixelStride = bytes_per_pixel;
lineStride = width * height * pixelStride;
return (unsigned char*)imageData;
}[/code]
The problem is the imageWidth and imageHeight members of the image class that are const and can’t be modified. A solution could be the creation of a new Image object at each time the user resize the window, but it’s more expensive than a simple realloc call !
So how can I use an Image and modify it’s dimensions dynamically ? Also, I need to have an access to the data to use that image with the AGG library, is the Image solution the good one ? Are theire other functions to map pixels data one a window without allocate an Image object ?
Thanks.
Bouba
PS: Sorry for my english, I’m french