I receive some Images from a database that returns them as:
const unsigned char* buffer[];
unsigned int saved_size;
The images are png 320x240; RGB
and the size that is returned is 105791
I am trying to make them back into an ofImage;
The images are uploaded to the database after saving them with standard ofSaveImage()
ofSaveImage(vidGrab->getPixels(), ofToDataPath(project_directories.GENERAL_SETTINGS+"/GRAB.png"));
is it possible to turn it back into an image?
ok I’ve figured it out…
ofBuffer to ofTexture
ofTexture to ofPixels
ofPixels to ofImage
simple 
ofBuffer buf;
buf.set(*(buffer), saved_size);
ofTexture texture;
ofLoadImage(texture, buf);
ofPixels pixels;
texture.readToPixels(pixels);
img.setFromPixels(pixels);
arturo
#3
you can just do:
ofBuffer buf;
buf.set(*(buffer), saved_size);
ofImage img;
img.load(buf);
which should be faster than going through a texture and then downloading again to an image
1 Like
arturo
#4
Or if you just need to draw it you can just use a texture without an image and draw that:
ofBuffer buf;
buf.set(*(buffer), saved_size);
ofTexture texture;
ofLoadImage(texture, buf);
...
texture.draw(0,0);
3 Likes