From: Alaoui Y. <kak...@us...> - 2004-12-26 19:40:15
|
Update of /cvsroot/amsn/msn/utils/TkCximage/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29393/src Modified Files: PhotoFormat.cpp TkCximage.cpp procs.cpp Log Message: Fixed some bugs with tkcximage and Added the demo app Index: TkCximage.cpp =================================================================== RCS file: /cvsroot/amsn/msn/utils/TkCximage/src/TkCximage.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TkCximage.cpp 24 Dec 2004 20:46:30 -0000 1.1 --- TkCximage.cpp 26 Dec 2004 19:40:03 -0000 1.2 *************** *** 13,16 **** --- 13,31 ---- #include "procs.cpp" + + void RGB2BGR(Tk_PhotoImageBlock *data) { + int i; + BYTE temp; + int size = data->height * data->width * data->pixelSize; + + for (i = 0; i < size; i+= data->pixelSize) { + temp = *(data->pixelPtr + i + data->offset[0]); + *(data->pixelPtr + i + data->offset[0]) = *(data->pixelPtr + i + data->offset[2]); + *(data->pixelPtr + i + data->offset[2]) = temp; + } + + } + + int GetFileTypeFromFileName(char * Filename) { Index: PhotoFormat.cpp =================================================================== RCS file: /cvsroot/amsn/msn/utils/TkCximage/src/PhotoFormat.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PhotoFormat.cpp 24 Dec 2004 20:46:30 -0000 1.1 --- PhotoFormat.cpp 26 Dec 2004 19:40:03 -0000 1.2 *************** *** 107,119 **** if(!image.Crop(srcX, srcY, srcX + width, srcY + height)) { ! Tcl_AppendResult(interp, image.GetLastError()); return TCL_ERROR; } if(!image.Flip()) { ! Tcl_AppendResult(interp, image.GetLastError()); return TCL_ERROR; } if(!image.Encode2RGBA(buffer, size)) { ! Tcl_AppendResult(interp, image.GetLastError()); return TCL_ERROR; } --- 107,119 ---- if(!image.Crop(srcX, srcY, srcX + width, srcY + height)) { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); return TCL_ERROR; } if(!image.Flip()) { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); return TCL_ERROR; } if(!image.Encode2RGBA(buffer, size)) { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); return TCL_ERROR; } *************** *** 169,184 **** } ! if (Type == CXIMAGE_FORMAT_GIF) ! image.DecreaseBpp(8, true); if(!image.CreateFromArray(blockPtr->pixelPtr, blockPtr->width, blockPtr->height, 8 * blockPtr->pixelSize, blockPtr->pitch, true)) { ! Tcl_AppendResult(interp, image.GetLastError()); return TCL_ERROR; } if (!image.Save(fileName, Type)) { ! Tcl_AppendResult(interp, image.GetLastError()); return TCL_ERROR; } --- 169,187 ---- } ! RGB2BGR(blockPtr); if(!image.CreateFromArray(blockPtr->pixelPtr, blockPtr->width, blockPtr->height, 8 * blockPtr->pixelSize, blockPtr->pitch, true)) { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); return TCL_ERROR; } + + if (Type == CXIMAGE_FORMAT_GIF) + image.DecreaseBpp(8, true); + if (!image.Save(fileName, Type)) { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); return TCL_ERROR; } *************** *** 204,221 **** } ! if (Type == CXIMAGE_FORMAT_GIF) ! image.DecreaseBpp(8, true); ! ! if(!image.CreateFromArray(blockPtr->pixelPtr, blockPtr->width, blockPtr->height, 8 * blockPtr->pixelSize, blockPtr->pitch, true)) { ! Tcl_AppendResult(interp, image.GetLastError()); return TCL_ERROR; } ! if (!image.Encode(buffer, size, Type) ) { ! Tcl_AppendResult(interp, image.GetLastError()); return TCL_ERROR; } --- 207,227 ---- } ! RGB2BGR(blockPtr); if(!image.CreateFromArray(blockPtr->pixelPtr, blockPtr->width, blockPtr->height, 8 * blockPtr->pixelSize, blockPtr->pitch, true)) { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); return TCL_ERROR; } ! ! ! ! if (Type == CXIMAGE_FORMAT_GIF) ! image.DecreaseBpp(8, true); ! ! if (!image.Encode(buffer, size, Type) ) { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); return TCL_ERROR; } Index: procs.cpp =================================================================== RCS file: /cvsroot/amsn/msn/utils/TkCximage/src/procs.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** procs.cpp 24 Dec 2004 20:46:30 -0000 1.1 --- procs.cpp 26 Dec 2004 19:40:04 -0000 1.2 *************** *** 64,84 **** if(!image.Load(In, CXIMAGE_FORMAT_UNKNOWN)) { ! Tcl_AppendResult(interp, image.GetLastError()); return TCL_ERROR; } ! ! if (OutType == CXIMAGE_FORMAT_UNKNOWN) ! OutType = CXIMAGE_FORMAT_GIF; ! ! if (OutType == CXIMAGE_FORMAT_GIF) ! image.DecreaseBpp(8, true); ! if (image.Save(Out, OutType)) ! return TCL_OK; ! else { ! Tcl_AppendResult(interp, image.GetLastError()); ! return TCL_ERROR; ! } } return TCL_OK; --- 64,85 ---- if(!image.Load(In, CXIMAGE_FORMAT_UNKNOWN)) { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); return TCL_ERROR; } ! } ! if (OutType == CXIMAGE_FORMAT_UNKNOWN) ! OutType = CXIMAGE_FORMAT_GIF; ! ! if (OutType == CXIMAGE_FORMAT_GIF) ! image.DecreaseBpp(8, true); ! ! if (image.Save(Out, OutType)) ! return TCL_OK; ! else { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); ! return TCL_ERROR; } + return TCL_OK; *************** *** 235,239 **** if( (Color = Tk_AllocColorFromObj(interp, Tk_MainWindow(interp), objv[4])) == NULL) { ! Tcl_AppendResult(interp, "Invalid Color for background"); return TCL_ERROR; } --- 236,240 ---- if( (Color = Tk_AllocColorFromObj(interp, Tk_MainWindow(interp), objv[4])) == NULL) { ! Tcl_AppendResult(interp, "Invalid Color for background", NULL); return TCL_ERROR; } *************** *** 260,264 **** 8 * photoData.pixelSize, photoData.pitch, true) ) { ! Tcl_AppendResult(interp, image.GetLastError()); return TCL_ERROR; } --- 261,265 ---- 8 * photoData.pixelSize, photoData.pitch, true) ) { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); return TCL_ERROR; } *************** *** 270,274 **** if(!image.Thumbnail(width, height, CxColor)) { ! Tcl_AppendResult(interp, image.GetLastError()); return TCL_ERROR; } --- 271,275 ---- if(!image.Thumbnail(width, height, CxColor)) { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); return TCL_ERROR; } *************** *** 286,294 **** if(!image.Flip()) { ! Tcl_AppendResult(interp, image.GetLastError()); return TCL_ERROR; } if(!image.Encode2RGBA(buffer, size)) { ! Tcl_AppendResult(interp, image.GetLastError()); return TCL_ERROR; } --- 287,295 ---- if(!image.Flip()) { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); return TCL_ERROR; } if(!image.Encode2RGBA(buffer, size)) { ! Tcl_AppendResult(interp, image.GetLastError(), NULL); return TCL_ERROR; } *************** *** 326,341 **** } - void RGB2BGR(Tk_PhotoImageBlock *data) { - int i; - BYTE temp; - int size = data->height * data->width * data->pixelSize; - - for (i = 0; i < size; i+= data->pixelSize) { - temp = *(data->pixelPtr + i + data->offset[0]); - *(data->pixelPtr + i + data->offset[0]) = *(data->pixelPtr + i + data->offset[2]); - *(data->pixelPtr + i + data->offset[2]) = temp; - } - - } --- 327,330 ---- |