Transform and merge two ofImage

Hello,

I am looking for a way to first transform an ofImage (which has an alpha channel):
Load a png file into an ofImage, rotate it, translate it and save it in another ofImage.

Then merge this transformed image with another one. I found this topic and maybe I am too tired but it does not do anything…http://forum.openframeworks.cc/t/merging-ofimages/4431/0

Basically as it is explained in the previous topic, I want to do the same as when we draw images on screen, using for example:

  
  
imageA.draw(0, 0);  
  
ofPushMatrix();  
ofRotate(some angle);  
ofTranslate(someX, someY);  
ofEnableAlphaBlending();  
imageB.draw(0, 0);  
ofDisableAlphaBlending();  
ofPopMatrix();  
  

Does anyone has clues on how to perform such operations? I also found a quite old addon called ofxImage which seems to be doing the transformations I am looking for but I cannot make it work with the current version of OF.

Thanks!

Have you tried an FBO? I am thinking

(just pseudocode)

create an FBO

fbo.begin();
do your image stuff
fbo.end();

ofImage imageToSave;
imageToSave.allocate(imgWidth, imgHeight, OF_COLOR_ALPHA):
fbo.readToPixels(imageToSave.getPixels());
imageToSave.update();
imageToSave.saveImage(“mySavedImage.png”);

Hi jvcleave,

Thanks for the tip, until now I didn’t know what were Fbos…and damn I wasted lots of time yesterday without knowing those.

It does exactly what I want to do, with 10 times less hassle!!!

Cheers!

Just an additional question:
What is the use of imageToSave.update(); before saving it?

I realize that is is also working without.

Cheers!

I couldn’t remember off the top of my head if update() was required if you changed the pixels - sounds like it is not needed

glad it works!