rpms/openoffice.org/devel openoffice.org-3.3.0.ooo80674.cmyk-for-jpeg-images.patch, NONE, 1.1 openoffice.org.spec, 1.2123, 1.2124

David Tardon dtardon at fedoraproject.org
Thu Jan 14 16:18:49 UTC 2010


Author: dtardon

Update of /cvs/pkgs/rpms/openoffice.org/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26406

Modified Files:
	openoffice.org.spec 
Added Files:
	openoffice.org-3.3.0.ooo80674.cmyk-for-jpeg-images.patch 
Log Message:
Resolves: rbhz#555257 openoffice cannot use JPEG images using CMYK colorspace

openoffice.org-3.3.0.ooo80674.cmyk-for-jpeg-images.patch:
 jpegc.c |   54 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 45 insertions(+), 9 deletions(-)

--- NEW FILE openoffice.org-3.3.0.ooo80674.cmyk-for-jpeg-images.patch ---
--- ooo/svtools/source/filter.vcl/jpeg/jpegc.c.orig	2006-09-08 10:25:21.000000000 +0200
+++ ooo/svtools/source/filter.vcl/jpeg/jpegc.c	2007-11-02 17:40:10.000000000 +0100
@@ -39,7 +39,8 @@
 #include "jpeglib.h"
 #include "jerror.h"
 #include "jpeg.h"
-
+#include "rtl/alloc.h"
+#include "osl/diagnose.h"
 
 struct my_error_mgr
 {
@@ -86,6 +87,9 @@ void ReadJPEG( void* pJPEGReader, void* 
     long                            nWidth;
     long                            nHeight;
     long                            nAlignedWidth;
+    JSAMPLE * range_limit;
+    HPBYTE pScanLineBuffer = NULL;
+    long nScanLineBufferComponents = 0;
     // declare bDecompCreated volatile because of gcc
     // warning: variable 'bDecompCreated' might be clobbered by `longjmp' or `vfork'
 	volatile long					bDecompCreated = 0;
@@ -111,8 +115,12 @@ void ReadJPEG( void* pJPEGReader, void* 
 	cinfo.output_gamma = 1.0;
 	cinfo.raw_data_out = FALSE;
 	cinfo.quantize_colors = FALSE;
-	if ( cinfo.jpeg_color_space != JCS_GRAYSCALE )
-		cinfo.out_color_space = JCS_RGB;
+	if ( cinfo.jpeg_color_space == JCS_YCbCr )
+	    cinfo.out_color_space = JCS_RGB;
+	else if ( cinfo.jpeg_color_space == JCS_YCCK )
+	    cinfo.out_color_space = JCS_CMYK;
+
+	OSL_ASSERT(cinfo.out_color_space == JCS_CMYK || cinfo.out_color_space == JCS_GRAYSCALE || cinfo.out_color_space == JCS_RGB);
 
     /* change scale for preview import */
     if( nPreviewWidth || nPreviewHeight )
@@ -156,6 +164,14 @@ void ReadJPEG( void* pJPEGReader, void* 
     aCreateBitmapParam.bGray = cinfo.output_components == 1;
 	pDIB = CreateBitmap( pJPEGReader, &aCreateBitmapParam );
     nAlignedWidth = aCreateBitmapParam.nAlignedWidth;
+    range_limit=cinfo.sample_range_limit;
+
+	if ( cinfo.out_color_space == JCS_CMYK )
+	{
+    		nScanLineBufferComponents = cinfo.output_width * 4;
+		pScanLineBuffer = rtl_allocateMemory( nScanLineBufferComponents );
+	}
+
 	if( pDIB )
 	{
 		if( aCreateBitmapParam.bTopDown )
@@ -168,17 +184,37 @@ void ReadJPEG( void* pJPEGReader, void* 
 
 		for ( *pLines = 0; *pLines < nHeight; (*pLines)++ )
 		{
+		    if (pScanLineBuffer!=NULL) { // in other words cinfo.out_color_space == JCS_CMYK
+			int i;
+			int j;
+			jpeg_read_scanlines( &cinfo, (JSAMPARRAY) &pScanLineBuffer, 1 );
+			// convert CMYK to RGB
+			for( i=0, j=0; i < nScanLineBufferComponents; i+=4, j+=3 )
+			{
+			    int c_=255-pScanLineBuffer[i+0];
+			    int m_=255-pScanLineBuffer[i+1];
+			    int y_=255-pScanLineBuffer[i+2];
+			    int k_=255-pScanLineBuffer[i+3];
+			    pTmp[j+0]=range_limit[ 255L - ( c_ + k_ ) ];
+			    pTmp[j+1]=range_limit[ 255L - ( m_ + k_ ) ];
+			    pTmp[j+2]=range_limit[ 255L - ( y_ + k_ ) ];
+			}
+		    } else {
 			jpeg_read_scanlines( &cinfo, (JSAMPARRAY) &pTmp, 1 );
-
-			/* PENDING ??? */
-			if ( cinfo.err->msg_code == 113 )
-				break;
-
-			pTmp += nAlignedWidth;
+		    }
+		    /* PENDING ??? */
+		    if ( cinfo.err->msg_code == 113 )
+			break;
+		    
+		    pTmp += nAlignedWidth;
 		}
 	}
 
 	jpeg_finish_decompress( &cinfo );
+	if (pScanLineBuffer!=NULL) {
+	    rtl_freeMemory( pScanLineBuffer );
+	    pScanLineBuffer=NULL;
+	}
 
 Exit:
 


Index: openoffice.org.spec
===================================================================
RCS file: /cvs/pkgs/rpms/openoffice.org/devel/openoffice.org.spec,v
retrieving revision 1.2123
retrieving revision 1.2124
diff -u -p -r1.2123 -r1.2124
--- openoffice.org.spec	14 Jan 2010 12:08:09 -0000	1.2123
+++ openoffice.org.spec	14 Jan 2010 16:18:48 -0000	1.2124
@@ -1,6 +1,6 @@
 %define oootag OOO320
 %define ooomilestone 9
-%define rh_rpm_release 4
+%define rh_rpm_release 5
 
 # rhbz#465664 jar-repacking breaks help by reordering META-INF/MANIFEST.MF
 %define __jar_repack %{nil}
@@ -129,6 +129,7 @@ Patch53: openoffice.org-3.3.0.ooo108047.
 Patch54: openoffice.org-3.3.0.ooo108246.svx.check-for-possible-out-of-bounds-index.patch
 Patch55: workspace.sw33bf02.patch
 Patch56: openoffice.org-3.2.0.oooXXXXX.embeddedobj.outplace.readonly.os.dispatch.patch
+Patch57: openoffice.org-3.3.0.ooo80674.cmyk-for-jpeg-images.patch
 
 %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
 %define instdir %{_libdir}
@@ -1685,6 +1686,7 @@ cp -p %{SOURCE5} external/unowinreg/unow
 %patch54 -p1 -b .ooo108246.svx.check-for-possible-out-of-bounds-index.patch
 %patch55 -p1 -b .workspace.sw33bf02.patch
 %patch56 -p0 -b .oooXXXXX.embeddedobj.outplace.readonly.os.dispatch.patch
+%patch57 -p1 -b .ooo80674.cmyk-for-jpeg-images.patch
 
 %build
 echo build start time is `date`, diskspace: `df -h . | tail -n 1`
@@ -4167,6 +4169,10 @@ fi
 %endif
 
 %changelog
+* Thu Jan 14 2010 Caolán McNamara <caolanm at redhat.com> - 1:3.2.0-9.5
+- Resolves: rbhz#555257 openoffice cannot use JPEG images using CMYK
+  colorspace (dtardon)
+
 * Thu Jan 14 2010 Caolán McNamara <caolanm at redhat.com> - 1:3.2.0-9.4
 - Resolves: rhbz#550043 dispatch outplace objects as ro documents to OS (caolanm)
 



More information about the scm-commits mailing list