Breaking ofImage and video frames into small tiles of different sizes.

Hello again! :smiley:
I’m trying to make an ofImage break appart into small tiles of different sizes. I’d also like to do that with a video frame that is playing.
I don’t know if this is a topic but I’m not sure of where I should start or what the correct name for this process is in order to search for it in the forum.

Any ideas? =D
As always, thank you very much!

maybe this will help http://forum.openframeworks.cc/t/part-of-a-texture/5962/2

Yes!!!
That is exactly what I was looking for!, thank you! =D

Questions:
-How can I load an image on a jpg file onto a texture?
-Do I have to go pixel-by-pixel?

I’ve searched the forum and managed to get a black and white texture by doing the following:

  
//--------------------------------------------------------------  
void testApp::setup(){  
    Backg.loadImage("Fondo.jpg");  
    Fondo.allocate(800, 600, true);  
    Fondo.loadData(Backg.getPixels(),800,600,GL_RGB);  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
    Fondo.draw(0,0);  
}  

when you load an ofImage, it automatically loads it into an ofTexture that’s stored inside the ofImage. so you only need to do loadImage, nothing else.

alternatively, there is some new functionality in 007 that will let you load directly into a texture using the function ofLoadImage. but that’s kind of overkill here.

I’m sorry, I get that an ofImage is an oftexture but I don’t really know how to do stuff with it. I read that you can use myImage.getTextureReference().bind() to get it working but I get no compiling errors now, just a grey window. Would you mind detailing the conection a bit more please? At this point I’d be happy with just getting it to draw on screen by using it as a texture, cropping it would be even better! =D

  
void testApp::setup(){  
    myImage.loadImage("myImage.jpg");  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
    myImage.getTextureReference().bind();  
    glBegin(GL_QUADS);  
    glTexCoord2f(myImage.getTextureReference().getCoordFromPoint(0,0).x, myImage.getTextureReference().getCoordFromPoint(0,0).y);  
    glVertex2f(0.0f,0.0f);  
    glTexCoord2f(myImage.getTextureReference().getCoordFromPoint(0,50).x, myImage.getTextureReference().getCoordFromPoint(0,50).y);  
    glVertex2f(0.0f,50.0f);  
    glEnd();  
    myImage.getTextureReference().unbind();  
    myImage.draw(300,300);  
}  

the problem with the code that you just posted is that you’re trying to draw GL_QUADS with only two vertices.

a GL_QUADS array needs 4 vertices per quad. NeHe has a nice short tutorial about drawing different polygons http://nehe.gamedev.net/tutorial/your-first-polygon/13002/

Perfect! =D
I shall bother you no more.
:slight_smile: Thanks again!

no worries! the exact same questions were tripping me up only a year or two ago, so i figure i’m in a decent position to answer those questions now :slight_smile: