SVN commit 450583 by gateau: Do not add a dummy character at the end of JPEG comments. M +1 -0 NEWS M +7 -38 imageutils/jpegcontent.cpp M +2 -2 imageutils/testjpegcontent.cpp --- trunk/extragear/graphics/gwenview/NEWS #450582:450583 @@ -24,6 +24,7 @@ the current image. - The destination URL is now set to the current URL in KIPI plugins. - Use the folder name as an album name for KIPI plugins. + - Do not add a dummy character at the end of JPEG comments. 2005.07.17 - v1.2.91 - New features: --- trunk/extragear/graphics/gwenview/imageutils/jpegcontent.cpp #450582:450583 @@ -322,37 +322,6 @@ } -// This code is inspired by jpegtools.c from fbida -static void doSetComment(struct jpeg_decompress_struct *src, const QString& comment) { - jpeg_saved_marker_ptr mark; - int size; - - /* find or create comment marker */ - for (mark = src->marker_list;; mark = mark->next) { - if (mark->marker == JPEG_COM) - break; - if (NULL == mark->next) { - mark->next = (jpeg_marker_struct*) - src->mem->alloc_large((j_common_ptr)src,JPOOL_IMAGE, - sizeof(*mark)); - mark = mark->next; - memset(mark,0,sizeof(*mark)); - mark->marker = JPEG_COM; - break; - } - } - - /* update comment marker */ - QCString utf8=comment.utf8(); - size = utf8.length() +1; - mark->data = (JOCTET*) - src->mem->alloc_large((j_common_ptr)src,JPOOL_IMAGE,size); - mark->original_length = size; - mark->data_length = size; - memcpy(mark->data, utf8, size); -} - - void JPEGContent::transform(Orientation orientation, bool setComment, const QString& comment) { QMap orientation2jxform; orientation2jxform[NOT_AVAILABLE]= JXFORM_NONE; @@ -405,12 +374,6 @@ // Read file header (void) jpeg_read_header(&srcinfo, TRUE); - // Set comment - if (setComment) { - doSetComment(&srcinfo, comment); - d->mComment=comment; - } - // Init transformation jpeg_transform_info transformoption; transformoption.transform = orientation2jxform[orientation]; @@ -438,7 +401,13 @@ /* Start compressor (note no image data is actually written here) */ jpeg_write_coefficients(&dstinfo, dst_coef_arrays); - + + if (setComment) { + QCString utf8=comment.utf8(); + const char* data=utf8; + jpeg_write_marker(&dstinfo, JPEG_COM, (const JOCTET*)(data), utf8.length()); + } + /* Copy to the output file any extra markers that we want to preserve */ jcopy_markers_execute(&srcinfo, &dstinfo, JCOPYOPT_ALL); --- trunk/extragear/graphics/gwenview/imageutils/testjpegcontent.cpp #450582:450583 @@ -39,10 +39,10 @@ const int ORIENT6_WIDTH=128; // This size is the size *after* orientation const int ORIENT6_HEIGHT=256; // has been applied const char* CUT_FILE="cut.jpg"; -const char* ORIENT6_COMMENT="a comment"; +const QString ORIENT6_COMMENT="a comment"; const char* ORIENT1_FILE="test_orient1.jpg"; const char* ORIENT1_VFLIP_FILE="test_orient1_vflip.jpg"; -const char* ORIENT1_VFLIP_COMMENT="vflip!"; +const QString ORIENT1_VFLIP_COMMENT="vflip!"; const char* THUMBNAIL_FILE="test_thumbnail.jpg";