Hi!
I try to use OpenGL for quick image scaling. I have an array of bytes in memory (image), want to scale it and write to another array.
I wrote two variants:
glClear(GL_DEPTH_BUFFER_BIT ^ GL_COLOR_BUFFER_BIT);
glPixelZoom(1.05,1.05);
glDrawPixels(256,256,GL_RGB,GL_UNSIGNED_BYTE,Bits1);
glReadPixels(0,0,256,256,GL_RGB,GL_UNSIGNED_BYTE,Bits2);
or
glClear(GL_DEPTH_BUFFER_BIT ^ GL_COLOR_BUFFER_BIT);
glScaled(1.05,1.05,1);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,256,256,
0,GL_RGBA,GL_UNSIGNED_BYTE,Bits1);
glBegin(GL_QUADS);
glTexCoord2f(0.0,0.0); glVertex3f(-1.0,-1.0,0.0);
glTexCoord2f(0.0,1.0); glVertex3f(-1.0,1.0,0.0);
glTexCoord2f(1.0,1.0); glVertex3f(1.0,1.0,0.0);
glTexCoord2f(1.0,0.0); glVertex3f(1.0,-1.0,0.0);
glEnd();
glReadPixels(0,0,256,256,GL_RGB,GL_UNSIGNED_BYTE,Bits2);
All works correct, but with bad performance. The GDI method StretchBlt - works a little faster…but StretchBlt is not accelerated. How can I scale image with high performance? Thank You!