////////////////////////////////////////////////////////////////////// // // Pixie // // Copyright © 1999 - 2003, Okan Arikan // // Contact: okan@cs.berkeley.edu // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // // File : imageView.cpp // Classes : CImageView // Description : // //////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include "imageView.h" /////////////////////////////////////////////////////////////////////// // Function : convert // Description : Convert the input texture to float per sample // Return Value : - // Comments : // Date last edited : 10/5/2005 static void convert(float *dest,void *src,int n,int bpp) { int i; unsigned char *src8; unsigned short *src16; float *src32f; switch(bpp) { case 8: src8 = (unsigned char *) src; for (i=0;i%dx%d[%d samples,%d bits / pixel]\n",width,height,numSamples,bitspersample*numSamples); // Is this a tiled image ? if (TIFFIsTiled(in)) { uint32 tileWidth,tileHeight; TIFFGetFieldDefaulted(in,TIFFTAG_TILEWIDTH ,&tileWidth); TIFFGetFieldDefaulted(in,TIFFTAG_TILELENGTH ,&tileHeight); fprintf(stdout,"->Tilesize: %dx%d\n",tileWidth,tileHeight); // Allocate temp memory tmp1 = new unsigned char[tileWidth*tileHeight*numSamples*4]; tmp2 = new float[tileWidth*tileHeight*numSamples]; // Read the texture for (j=0;jThis seems like a depth file. Normalizing...\n"); // Find the range for (j=0;j= 1e20) continue; if (texture[j*texWidth+i] < minDepth) minDepth = texture[j*texWidth+i]; if (texture[j*texWidth+i] > maxDepth) maxDepth = texture[j*texWidth+i]; } } // No the normalization if (maxDepth > minDepth) { const double tmp = 1 / (maxDepth - minDepth); for (j=0;jwidth/CInterface::width,yoffset*this->height/CInterface::height,0); glTranslatef((float) (texWidth >> 1), (float) (texHeight >> 1),0); glScalef(length,length,1); glTranslatef((float) (-texWidth >> 1),(float) (-texHeight >> 1),0); glColor3f(1,1,1); glBegin(GL_QUADS); glTexCoord2f(0,1); glVertex2i(0,0); glTexCoord2f(1,1); glVertex2i(texWidth,0); glTexCoord2f(1,0); glVertex2i(texWidth,texHeight); glTexCoord2f(0,0); glVertex2i(0,texHeight); glEnd(); } /////////////////////////////////////////////////////////////////////// // Class : CImageView // Method : mouseDown // Description : Mouse down handle // Return Value : - // Comments : // Date last edited : 10/5/2005 void CImageView::leftMouseDown(int x,int y) { lastXoffset = xoffset; lastYoffset = yoffset; lastLength = length; lastX = x; lastY = y; flags |= IMAGE_MOUSE_DOWN; if (Fl::event_button() == 1) flags |= FMOUSE_LEFT; else flags |= FMOUSE_RIGHT; } /////////////////////////////////////////////////////////////////////// // Class : CImageView // Method : leftMouseUp // Description : Mouse down handle // Return Value : - // Comments : // Date last edited : 10/5/2005 void CImageView::leftMouseUp(int x,int y) { flags &= ~IMAGE_MOUSE_DOWN; if (Fl::event_button() == 1) flags &= ~FMOUSE_LEFT; else flags &= ~FMOUSE_RIGHT; } /////////////////////////////////////////////////////////////////////// // Class : CImageView // Method : mouseMove // Description : Mouse move handle // Return Value : - // Comments : // Date last edited : 10/5/2005 void CImageView::mouseMove(int x,int y) { if (flags & IMAGE_MOUSE_DOWN) { int dx = x - lastX; int dy = y - lastY; if ((flags & IMAGE_ZOOM) || ((flags & FMOUSE_LEFT) && (flags & FMOUSE_RIGHT))) { length = lastLength + dx / 500.0f; } else { xoffset = lastXoffset + dx; yoffset = lastYoffset - dy; } } redraw(); } /////////////////////////////////////////////////////////////////////// // Class : CImageView // Method : keyDown // Description : Key down handler // Return Value : - // Comments : // Date last edited : 10/5/2005 void CImageView::keyDown(char key) { if (key == 'z') { if ((flags & IMAGE_MOUSE_DOWN)) { flags |= IMAGE_ZOOM; } } else if (key == 'r') { xoffset = 0; yoffset = 0; length = 1; size_range(width,height); redraw(); } } /////////////////////////////////////////////////////////////////////// // Class : CImageView // Method : keyUp // Description : Key up handler // Return Value : - // Comments : // Date last edited : 10/5/2005 void CImageView::keyUp(char key) { if (key == 'z') { flags &= ~IMAGE_ZOOM; } else { } }