I am using OpenGL to as part of a drawing application for iOS. When the user finishes drawing the texture is saved to a jpg using SOIL. The image appears correct in the view, when saved the output is oriented correctly (after inverting the image) but the image is scaled to a smaller size (based on device.. higher res devices produce smaller images) than what I am expecting.
The process I am following is:
unsigned char *pixels = (unsigned char*)malloc( 4* imgwidth* imgheight);
glBindTexture(GL_TEXTURE_2D, 0);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, imgwidth, imgheight);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glPixelStorei (GL_UNPACK_SKIP_ROWS, 1);
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 1);
glReadPixels(0, 0, imgwidth, imgheight, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *) pixels);
invertPixels(pixels);
int result;
result = SOIL_save_image_quality(imagepath, SOIL_SAVE_TYPE_JPG, d, imgheight, 4, pixel_data, 99);
delete [] pixel;
I have analyzed the inversion algorithm to death and am confident its doing its job, without it the image is the same size but upside down. What could be causing this? Do I need to rescale my texture?