int bitBltRGBToFile( char * name , char * comment , unsigned char * source , unsigned int sX, unsigned int sY , unsigned int sourceWidth , unsigned int sourceHeight , unsigned int width , unsigned int height) { if (source==0) { fprintf(stderr,"Cannot bit blt from empty source..!"); return 0; } char filename[512]; snprintf(filename,512,"%s.pnm",name); unsigned char * tile = (unsigned char*) malloc((width+1)*(height+1)*3*sizeof(unsigned char)); if (tile == 0 ) { return 0; } //fprintf(stderr," Doing bitbltRGB %ux%u\n",width,height); bitbltRGB(tile,0,0,width,height,source,sX,sY,sourceWidth,sourceHeight,width, height); //fprintf(stderr," saveRawImageToFile %ux%u \n",width,height); if ( ! saveRawImageToFile(filename ,comment,tile , width , height, 3 , 8) ) { fprintf(stderr,"Could not bit blt to File %s\n",name); } free(tile); return 1; }
int acquisitionSaveDepthFrame1C(ModuleIdentifier moduleID,DeviceIdentifier devID,char * filename) { printCall(moduleID,devID,"acquisitionSaveColoredDepthFrame", __FILE__, __LINE__); char filenameFull[1024]={0}; sprintf(filenameFull,"%s.pnm",filename); unsigned int width = 0 ; unsigned int height = 0 ; unsigned int channels = 0 ; unsigned int bitsperpixel = 0 ; short * inFrame = 0; char * outFrame = 0 ; inFrame = acquisitionGetDepthFrame(moduleID,devID); if (inFrame!=0) { acquisitionGetDepthFrameDimensions(moduleID,devID,&width,&height,&channels,&bitsperpixel); outFrame = convertShortDepthToCharDepth(inFrame,width,height,0,7000); if (outFrame!=0) { saveRawImageToFile(filenameFull,outFrame,width,height,1,8); free(outFrame); return 1; } } MeaningfullWarningMessage(moduleID,devID,"acquisitionSaveColoredDepthFrame"); return 0; }
int acquisitionSaveDepthFrame(ModuleIdentifier moduleID,DeviceIdentifier devID,char * filename) { printCall(moduleID,devID,"acquisitionSaveDepthFrame", __FILE__, __LINE__); char filenameFull[2048]={0}; sprintf(filenameFull,"%s.pnm",filename); if ( (*plugins[moduleID].getDepthPixels!=0) && (*plugins[moduleID].getDepthWidth!=0) && (*plugins[moduleID].getDepthHeight!=0) && (*plugins[moduleID].getDepthChannels!=0) && (*plugins[moduleID].getDepthBitsPerPixel!=0) ) { return saveRawImageToFile( filenameFull, (*plugins[moduleID].getDepthPixels) (devID), (*plugins[moduleID].getDepthWidth) (devID), (*plugins[moduleID].getDepthHeight) (devID), (*plugins[moduleID].getDepthChannels) (devID), (*plugins[moduleID].getDepthBitsPerPixel)(devID) ); } MeaningfullWarningMessage(moduleID,devID,"acquisitionSaveDepthFrame"); return 0; }
void writeOpenGLColor(char * colorfile,unsigned int x,unsigned int y,unsigned int width,unsigned int height) { char * rgb = (char *) malloc((width-x)*(height-y)*sizeof(char)*3); if (rgb==0) { fprintf(stderr,"Could not allocate a buffer to write color to file %s \n",colorfile); return 0; } getOpenGLColor(rgb, x, y, width, height); saveRawImageToFile(colorfile,rgb,(width-x),(height-y),3,8); if (rgb!=0) { free(rgb); rgb=0; } return ; }
void writeOpenGLDepth(char * depthfile,unsigned int x,unsigned int y,unsigned int width,unsigned int height) { short * zshortbuffer = (short *) malloc((width-x)*(height-y)*sizeof(short)); if (zshortbuffer==0) { fprintf(stderr,"Could not allocate a buffer to write depth to file %s \n",depthfile); return 0; } getOpenGLDepth(zshortbuffer,x,y,width,height); saveRawImageToFile(depthfile,zshortbuffer,(width-x),(height-y),1,16); if (zshortbuffer!=0) { free(zshortbuffer); zshortbuffer=0; } return ; }
int bitBltDepthToFile( char * name ,char * comment , unsigned short * source , unsigned int sX, unsigned int sY , unsigned int sourceWidth , unsigned int sourceHeight , unsigned int width , unsigned int height) { char filename[512]; sprintf(filename,"%s.pnm",name); unsigned short * tile = (unsigned short*) malloc((width+1)*(height+1)*1*sizeof(unsigned short)); if (tile == 0 ) { return 0; } bitbltDepth(tile,0,0,width,height,source,sX,sY,sourceWidth,sourceHeight,width, height); saveRawImageToFile(filename ,comment,(unsigned char*) tile , width , height, 1 , 16); free(tile); return 1; }
int saveTileDepthToFile( unsigned int solutionColumn , unsigned int solutionRow , unsigned short * source , unsigned int sX, unsigned int sY , unsigned int sourceWidth , unsigned int sourceHeight , unsigned int width , unsigned int height) { char filename[512]; sprintf(filename,"tiles/depth_tile%u_%u.pnm",solutionColumn,solutionRow); unsigned short * tile = (unsigned short*) malloc((width+1)*(height+1)*1*sizeof(unsigned short)); if (tile == 0 ) { return 0; } bitbltDepth(tile,0,0,width,height,source,sX,sY,sourceWidth,sourceHeight,width, height); saveRawImageToFile(filename ,0,(unsigned char*) tile , width , height, 1 , 16); free(tile); return 1; }
int saveTileRGBToFile( unsigned int solutionColumn , unsigned int solutionRow , unsigned char * source , unsigned int sX, unsigned int sY , unsigned int sourceWidth , unsigned int sourceHeight , unsigned int width , unsigned int height) { char filename[512]; sprintf(filename,"tiles/rgb_tile%u_%u.pnm",solutionColumn,solutionRow); unsigned char * tile = (unsigned char*) malloc((width+1)*(height+1)*3*sizeof(unsigned char)); if (tile == 0 ) { return 0; } bitbltRGB(tile,0,0,width,height,source,sX,sY,sourceWidth,sourceHeight,width, height); saveRawImageToFile(filename ,0,tile , width , height, 3 , 8); free(tile); return 1; }