////////////////////////////////////////////////////////////////////// // // 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 : file.cpp // Classes : // Description : This file implements the default output device // that sends the image into a radiance RGBA image // // //////////////////////////////////////////////////////////////////////// #include #include #include #include #include "common/global.h" #include "common/os.h" #include "ri/dsply.h" // The display functions #include "rgbe.h" /////////////////////////////////////////////////////////////////////// // Class : CFramebuffer // Description : Holds the framebuffer // Comments : // Date last edited : 5/9/2002 class CFramebuffer { public: /////////////////////////////////////////////////////////////////////// // Class : CFramebuffer // Method : CFramebuffer // Description : Ctor // Return Value : - // Comments : // Date last edited : 5/9/2002 CFramebuffer(const char *name,int width,int height,int numSamples,const char *samples,TDisplayParameterFunction findParameter) { char fileName[256]; if (strchr(name,'.') == NULL) { sprintf(fileName,"%s.pic",name); } else { strcpy(fileName,name); } image = fopen(fileName,"wb"); RGBE_WriteHeader(image,width,height,NULL); this->width = width; this->height = height; this->numSamples = numSamples; this->data = new float[width*height*numSamples]; } /////////////////////////////////////////////////////////////////////// // Class : CFramebuffer // Method : ~CFramebuffer // Description : Dtor // Return Value : - // Comments : // Date last edited : 11/28/2001 ~CFramebuffer() { RGBE_WritePixels(image,data,width*height); if (image != NULL) fclose(image); delete [] data; } /////////////////////////////////////////////////////////////////////// // Class : CFramebuffer // Method : write // Description : Swrite some data to the out file // Return Value : - // Comments : // Date last edited : 11/28/2001 void write(int x,int y,int w,int h,float *data) { int i,j; int check = FALSE; int numChannels = w*h*numSamples; if (image == NULL) return; for (i=0;idata + ((i+y)*width + x)*numSamples; for (j=0;jwrite(x,y,w,h,data); return TRUE; } /////////////////////////////////////////////////////////////////////// // Function : displayFinish // Description : Finish receiving an image // Return Value : TRUE on success, FALSE othervise // Comments : // Date last edited : 11/28/2001 void displayFinish(void *im) { CFramebuffer *fb = (CFramebuffer *) im; assert(fb != NULL); delete fb; }