PDA

View Full Version : zoom the .tiff image ?



zarrin
12-14-2006, 02:19 AM
hi..

sorry for posting again.actually i have posted the question in opengl for advanc forum.

i have loaded a .tiff image(map) using opengl.

i want to zoom the selected part of this image and display the zoom image.

the selection should be done through mouse .

i m collecting the coordinates of a rectangle(selected area thru mouse) and trying to zoom the pixels.but i m not getting the zoom image displayed.i m able to collect the rectangle coordinates but pixels are not getting zoomed.

can any body tell how to zoom the image using opengl?

which function shall i use ?
can any body tell the solution.


thanx in advance.

k_szczech
12-14-2006, 06:43 AM
How do you display your image? If you use glDrawPixels, then you could try using textures and draw a textured quad instead. In that case zooming is easy - you just render the same quad with different texture coordinates at corners that specify fragment of texture to display.

Visit nehe.gamedev.net and look for some texturing tutorial there.

zarrin
12-14-2006, 07:09 PM
i m drawing the image using glDrawPixels. this is my code

TIFF *tif;
char emsg[1024];
int i;

tif = TIFFOpen("vancouver.tif", "r");

if (TIFFRGBAImageBegin(&img, tif, 0, emsg)) {

npixels = img.width * img.height;

raster = (uint32 *) _TIFFmalloc(npixels * sizeof(uint32));
if (raster != NULL) {
if (TIFFRGBAImageGet(&img, raster, img.width, img.height) == 0) {
TIFFError(filename, emsg);
//exit(1);
}
}
TIFFRGBAImageEnd(&img);
} else {
TIFFError(filename, emsg);
// exit(1);
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
}

glDrawPixel..

glDrawPixels(imgwidth, imgheight,hasABGR ? GL_ABGR_EXT : GL_RGBA, GL_UNSIGNED_BYTE,raster);


and zoom code is using glPixelZoom and glCopyPixel .

glReadBuffer(GL_FRONT);

glDrawBuffer(GL_FRONT);
glRasterPos2i (0,0);
glPixelZoom (1.0,1.0);
glCopyPixels ( mousex - 8,mousey -8 , 16,16, GL_COLOR);


i m using linux fedora core 4, gcc compiler.
can give example or some sample code using textures and how to draw texture quad.

k_szczech
12-15-2006, 05:17 AM
Well, I never used glDrawPixels since it's too slow (need to pass entire bitmap to the GPU every time you draw), so I have very limited knowledge here. Perhaps you should try calling glDrawPixels again instead of glCopyPixels?