diff options
-rw-r--r-- | svtools/source/filter.vcl/jpeg/jpeg.cxx | 36 | ||||
-rw-r--r-- | svtools/source/filter.vcl/jpeg/jpegc.c | 44 | ||||
-rw-r--r-- | svtools/source/filter.vcl/jpeg/makefile.mk | 4 |
3 files changed, 42 insertions, 42 deletions
diff --git a/svtools/source/filter.vcl/jpeg/jpeg.cxx b/svtools/source/filter.vcl/jpeg/jpeg.cxx index 81d07ccd5e79..9845b6ce67ff 100644 --- a/svtools/source/filter.vcl/jpeg/jpeg.cxx +++ b/svtools/source/filter.vcl/jpeg/jpeg.cxx @@ -33,22 +33,16 @@ #include <tools/solar.h> -#ifdef SYSTEM_JPEG -#define INT32 JPEG_INT32 -#endif - extern "C" { + #define INT32 JPEG_INT32 #include "stdio.h" #include "jpeg.h" #include "jpeglib.h" #include "jerror.h" + #undef INT32 } -#ifdef SYSTEM_JPEG -#undef INT32 -#endif - #define _JPEGPRIVATE #include <vcl/bmpacc.hxx> #include "jpeg.hxx" @@ -399,11 +393,7 @@ void* JPEGReader::CreateBitmap( void* pParam ) if( ( bGray && ( BMP_FORMAT_8BIT_PAL == nFormat ) ) || -#ifndef SYSTEM_JPEG - ( !bGray && ( BMP_FORMAT_24BIT_TC_BGR == nFormat ) ) -#else ( !bGray && ( BMP_FORMAT_24BIT_TC_RGB == nFormat ) ) -#endif ) { pBmpBuf = pAcc->GetBuffer(); @@ -466,15 +456,9 @@ void JPEGReader::FillBitmap() for( long nX = 0L; nX < nWidth; nX++ ) { -#ifndef SYSTEM_JPEG - aColor.SetBlue( *pTmp++ ); - aColor.SetGreen( *pTmp++ ); - aColor.SetRed( *pTmp++ ); -#else aColor.SetRed( *pTmp++ ); aColor.SetGreen( *pTmp++ ); aColor.SetBlue( *pTmp++ ); -#endif pAcc->SetPixel( nY, nX, aColor ); } } @@ -654,15 +638,9 @@ void* JPEGWriter::GetScanline( long nY ) for( long nX = 0L; nX < nWidth; nX++ ) { aColor = pAcc->GetPaletteColor( (BYTE) pAcc->GetPixel( nY, nX ) ); -#ifndef SYSTEM_JPEG - *pTmp++ = aColor.GetBlue(); - *pTmp++ = aColor.GetGreen(); - *pTmp++ = aColor.GetRed(); -#else *pTmp++ = aColor.GetRed(); *pTmp++ = aColor.GetGreen(); *pTmp++ = aColor.GetBlue(); -#endif } } else @@ -670,15 +648,9 @@ void* JPEGWriter::GetScanline( long nY ) for( long nX = 0L; nX < nWidth; nX++ ) { aColor = pAcc->GetPixel( nY, nX ); -#ifndef SYSTEM_JPEG - *pTmp++ = aColor.GetBlue(); - *pTmp++ = aColor.GetGreen(); - *pTmp++ = aColor.GetRed(); -#else *pTmp++ = aColor.GetRed(); *pTmp++ = aColor.GetGreen(); *pTmp++ = aColor.GetBlue(); -#endif } } @@ -713,11 +685,7 @@ BOOL JPEGWriter::Write( const Graphic& rGraphic ) if( pAcc ) { -#ifndef SYSTEM_JPEG - bNative = ( pAcc->GetScanlineFormat() == BMP_FORMAT_24BIT_TC_BGR ); -#else bNative = ( pAcc->GetScanlineFormat() == BMP_FORMAT_24BIT_TC_RGB ); -#endif if( !bNative ) pBuffer = new BYTE[ AlignedWidth4Bytes( pAcc->Width() * 24L ) ]; diff --git a/svtools/source/filter.vcl/jpeg/jpegc.c b/svtools/source/filter.vcl/jpeg/jpegc.c index 84394d945f79..4c6587331cdd 100644 --- a/svtools/source/filter.vcl/jpeg/jpegc.c +++ b/svtools/source/filter.vcl/jpeg/jpegc.c @@ -34,7 +34,8 @@ #include "jpeglib.h" #include "jerror.h" #include "jpeg.h" - +#include "rtl/alloc.h" +#include "osl/diagnose.h" struct my_error_mgr { @@ -81,6 +82,9 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines ) 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; @@ -106,8 +110,12 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines ) cinfo.output_gamma = 1.0; cinfo.raw_data_out = FALSE; cinfo.quantize_colors = FALSE; - if ( cinfo.jpeg_color_space != JCS_GRAYSCALE ) + 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 ) @@ -151,6 +159,14 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines ) 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 ) @@ -163,17 +179,37 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines ) 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; + break; pTmp += nAlignedWidth; } } jpeg_finish_decompress( &cinfo ); + if (pScanLineBuffer!=NULL) { + rtl_freeMemory( pScanLineBuffer ); + pScanLineBuffer=NULL; + } Exit: diff --git a/svtools/source/filter.vcl/jpeg/makefile.mk b/svtools/source/filter.vcl/jpeg/makefile.mk index 7a9b5fc509c9..adb64b81ed44 100644 --- a/svtools/source/filter.vcl/jpeg/makefile.mk +++ b/svtools/source/filter.vcl/jpeg/makefile.mk @@ -39,10 +39,6 @@ TARGET=jpeg .INCLUDE : settings.mk .INCLUDE : $(PRJ)$/util$/svt.pmk -.IF "$(SYSTEM_JPEG)" == "YES" -CFLAGS+=-DSYSTEM_JPEG -.ENDIF - SOLARINC+=-I../../inc # --- Files -------------------------------------------------------- |