[Libreoffice-commits] core.git: vcl/Library_vcl.mk vcl/source

Stephan Bergmann sbergman at redhat.com
Thu Feb 6 05:25:31 PST 2014


 vcl/Library_vcl.mk                       |    2 
 vcl/source/filter/jpeg/JpegReader.cxx    |   62 +---
 vcl/source/filter/jpeg/JpegReader.hxx    |   17 +
 vcl/source/filter/jpeg/JpegTransform.cxx |    6 
 vcl/source/filter/jpeg/JpegWriter.cxx    |   56 +---
 vcl/source/filter/jpeg/jpeg.h            |   43 +--
 vcl/source/filter/jpeg/jpegc.c           |  389 -------------------------------
 vcl/source/filter/jpeg/jpegc.cxx         |  383 ++++++++++++++++++++++++++++++
 8 files changed, 459 insertions(+), 499 deletions(-)

New commits:
commit 11dbbc792f53dc581822c873eb198731c3425576
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Feb 6 14:20:00 2014 +0100

    Make vcl/source/filter/jpeg/jpegc.c be C++ code
    
    ...simplify the corresponding jpeg.h now that it deals in C++, and fold
    SetJpegPreviewSizeHint into ReadJPEG to avoid global static data.
    
    Change-Id: Id3721bdb37be05e3e6bbbaef3b0aa0c0e1a9ff5a

diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 04fc6cc..1725823 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -173,6 +173,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/filter/ixpm/xpmread \
     vcl/source/filter/jpeg/Exif \
     vcl/source/filter/jpeg/jpeg \
+    vcl/source/filter/jpeg/jpegc \
     vcl/source/filter/jpeg/JpegReader \
     vcl/source/filter/jpeg/JpegWriter \
     vcl/source/filter/jpeg/JpegTransform \
@@ -314,7 +315,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 ))
 
 $(eval $(call gb_Library_add_cobjects,vcl,\
-    vcl/source/filter/jpeg/jpegc \
     vcl/source/filter/jpeg/transupp \
 ))
 
diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx
index 5d3af16..61d7985 100644
--- a/vcl/source/filter/jpeg/JpegReader.cxx
+++ b/vcl/source/filter/jpeg/JpegReader.cxx
@@ -17,16 +17,12 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
 
-#include <tools/solar.h>
-
-extern "C"
-{
-    #include "stdio.h"
-    #include "jpeg.h"
-    #include <jpeglib.h>
-    #include <jerror.h>
-}
+#include "stdio.h"
+#include "jpeg.h"
+#include <jpeglib.h>
+#include <jerror.h>
 
 #include "JpegReader.hxx"
 #include <vcl/bmpacc.hxx>
@@ -43,21 +39,14 @@ namespace {
     static const sal_uInt64 MAX_BITMAP_BYTE_SIZE = sal_uInt64(512 * 1024 * 1024);
 }
 
-extern "C" void* CreateBitmapFromJPEGReader( void* pJPEGReader, void* pJPEGCreateBitmapParam )
-{
-    return ( (JPEGReader*) pJPEGReader )->CreateBitmap( pJPEGCreateBitmapParam );
-}
-
 /* Expanded data source object for stdio input */
 
-typedef struct {
-    struct      jpeg_source_mgr pub;    /* public fields */
+struct SourceManagerStruct {
+    jpeg_source_mgr pub;                /* public fields */
     SvStream*   stream;                 /* source stream */
     JOCTET*     buffer;                 /* start of buffer */
     boolean     start_of_file;          /* have we gotten any data yet? */
-} SourceManagerStruct;
-
-typedef SourceManagerStruct* SourceManagerStructPointer;
+};
 
 /*
  * Initialize source --- called by jpeg_read_header
@@ -65,7 +54,7 @@ typedef SourceManagerStruct* SourceManagerStructPointer;
  */
 extern "C" void init_source (j_decompress_ptr cinfo)
 {
-    SourceManagerStructPointer source = (SourceManagerStructPointer) cinfo->src;
+    SourceManagerStruct * source = (SourceManagerStruct *) cinfo->src;
 
     /* We reset the empty-input-file flag for each image,
      * but we don't clear the input buffer.
@@ -99,7 +88,7 @@ long StreamRead( SvStream* pStream, void* pBuffer, long nBufferSize )
 
 extern "C" boolean fill_input_buffer (j_decompress_ptr cinfo)
 {
-    SourceManagerStructPointer source = (SourceManagerStructPointer) cinfo->src;
+    SourceManagerStruct * source = (SourceManagerStruct *) cinfo->src;
     size_t nbytes;
 
     nbytes = StreamRead(source->stream, source->buffer, BUFFER_SIZE);
@@ -126,7 +115,7 @@ extern "C" boolean fill_input_buffer (j_decompress_ptr cinfo)
 
 extern "C" void skip_input_data (j_decompress_ptr cinfo, long numberOfBytes)
 {
-    SourceManagerStructPointer source = (SourceManagerStructPointer) cinfo->src;
+    SourceManagerStruct * source = (SourceManagerStruct *) cinfo->src;
 
     /* Just a dumb implementation for now.  Could use fseek() except
      * it doesn't work on pipes.  Not clear that being smart is worth
@@ -153,9 +142,9 @@ extern "C" void term_source (j_decompress_ptr)
     /* no work necessary here */
 }
 
-extern "C" void jpeg_svstream_src (j_decompress_ptr cinfo, void* input)
+void jpeg_svstream_src (j_decompress_ptr cinfo, void* input)
 {
-    SourceManagerStructPointer source;
+    SourceManagerStruct * source;
     SvStream* stream = (SvStream*)input;
 
     /* The source object and input buffer are made permanent so that a series
@@ -168,14 +157,14 @@ extern "C" void jpeg_svstream_src (j_decompress_ptr cinfo, void* input)
 
     if (cinfo->src == NULL)
     { /* first time for this JPEG object? */
-        cinfo->src = (struct jpeg_source_mgr *)
+        cinfo->src = (jpeg_source_mgr *)
             (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(SourceManagerStruct));
-        source = (SourceManagerStructPointer) cinfo->src;
+        source = (SourceManagerStruct *) cinfo->src;
         source->buffer = (JOCTET *)
             (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, BUFFER_SIZE * sizeof(JOCTET));
     }
 
-    source = (SourceManagerStructPointer) cinfo->src;
+    source = (SourceManagerStruct *) cinfo->src;
     source->pub.init_source = init_source;
     source->pub.fill_input_buffer = fill_input_buffer;
     source->pub.skip_input_data = skip_input_data;
@@ -202,7 +191,7 @@ JPEGReader::JPEGReader( SvStream& rStream, void* /*pCallData*/, bool bSetLogSize
 JPEGReader::~JPEGReader()
 {
     if( mpBuffer )
-        rtl_freeMemory( mpBuffer );
+        delete[] mpBuffer;
 
     if( mpAcc )
         maBmp.ReleaseAccess( mpAcc );
@@ -211,10 +200,8 @@ JPEGReader::~JPEGReader()
         maBmp1.ReleaseAccess( mpAcc1 );
 }
 
-void* JPEGReader::CreateBitmap( void* _pParam )
+unsigned char * JPEGReader::CreateBitmap( JPEGCreateBitmapParam * pParam )
 {
-    JPEGCreateBitmapParam *pParam = (JPEGCreateBitmapParam *) _pParam;
-
     if (pParam->nWidth > SAL_MAX_INT32 / 8 || pParam->nHeight > SAL_MAX_INT32 / 8)
         return NULL; // avoid overflows later
 
@@ -224,7 +211,7 @@ void* JPEGReader::CreateBitmap( void* _pParam )
     Size        aSize( pParam->nWidth, pParam->nHeight );
     bool        bGray = pParam->bGray != 0;
 
-    void* pBmpBuf = NULL;
+    unsigned char * pBmpBuf = NULL;
 
     if( mpAcc )
     {
@@ -265,7 +252,7 @@ void* JPEGReader::CreateBitmap( void* _pParam )
 
     if ( mbSetLogSize )
     {
-        unsigned long nUnit = ((JPEGCreateBitmapParam*)pParam)->density_unit;
+        unsigned long nUnit = pParam->density_unit;
 
         if( ( ( 1 == nUnit ) || ( 2 == nUnit ) ) && pParam->X_density && pParam->Y_density )
         {
@@ -299,7 +286,7 @@ void* JPEGReader::CreateBitmap( void* _pParam )
         {
             pParam->nAlignedWidth = AlignedWidth4Bytes( aSize.Width() * ( bGray ? 8 : 24 ) );
             pParam->bTopDown = sal_True;
-            pBmpBuf = mpBuffer = rtl_allocateMemory( pParam->nAlignedWidth * aSize.Height() );
+            pBmpBuf = mpBuffer = new unsigned char[pParam->nAlignedWidth * aSize.Height()];
         }
     }
 
@@ -318,7 +305,7 @@ void JPEGReader::FillBitmap()
 {
     if( mpBuffer && mpAcc )
     {
-        HPBYTE      pTmp;
+        unsigned char * pTmp;
         BitmapColor aColor;
         long        nAlignedWidth;
         long        nWidth = mpAcc->Width();
@@ -467,17 +454,16 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
     mrStream.Seek( mnLastPos );
 
     Size aPreviewSize = GetPreviewSize();
-    SetJpegPreviewSizeHint( aPreviewSize.Width(), aPreviewSize.Height() );
 
     // read the (partial) image
-    ReadJPEG( this, &mrStream, &nLines );
+    ReadJPEG( this, &mrStream, &nLines, aPreviewSize.Width(), aPreviewSize.Height() );
 
     if( mpAcc )
     {
         if( mpBuffer )
         {
             FillBitmap();
-            rtl_freeMemory( mpBuffer );
+            delete[] mpBuffer;
             mpBuffer = NULL;
         }
 
diff --git a/vcl/source/filter/jpeg/JpegReader.hxx b/vcl/source/filter/jpeg/JpegReader.hxx
index 061eb2d..442c52d 100644
--- a/vcl/source/filter/jpeg/JpegReader.hxx
+++ b/vcl/source/filter/jpeg/JpegReader.hxx
@@ -33,6 +33,19 @@ enum ReadState
     JPEGREAD_NEED_MORE
 };
 
+struct JPEGCreateBitmapParam
+{
+    unsigned long nWidth;
+    unsigned long nHeight;
+    unsigned long density_unit;
+    unsigned long X_density;
+    unsigned long Y_density;
+    long     bGray;
+
+    long     nAlignedWidth;  // these members will be filled by the
+    long     bTopDown;      // CreateBitmap method in svtools
+};
+
 class JPEGReader : public GraphicReader
 {
     SvStream&           mrStream;
@@ -40,7 +53,7 @@ class JPEGReader : public GraphicReader
     Bitmap              maBmp1;
     BitmapWriteAccess*  mpAcc;
     BitmapWriteAccess*  mpAcc1;
-    void*               mpBuffer;
+    unsigned char *     mpBuffer;
     long                mnLastPos;
     long                mnFormerPos;
     long                mnLastLines;
@@ -54,7 +67,7 @@ public:
     virtual ~JPEGReader();
 
     ReadState   Read( Graphic& rGraphic );
-    void*       CreateBitmap( void* JPEGCreateBitmapParam );
+    unsigned char * CreateBitmap( JPEGCreateBitmapParam* param );
 };
 
 #endif // INCLUDED_VCL_SOURCE_FILTER_JPEG_JPEGREADER_HXX
diff --git a/vcl/source/filter/jpeg/JpegTransform.cxx b/vcl/source/filter/jpeg/JpegTransform.cxx
index 789d303..722ddbd 100644
--- a/vcl/source/filter/jpeg/JpegTransform.cxx
+++ b/vcl/source/filter/jpeg/JpegTransform.cxx
@@ -17,11 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
 
-extern "C"
-{
-    #include "jpeg.h"
-}
+#include "jpeg.h"
 
 #include "JpegTransform.hxx"
 
diff --git a/vcl/source/filter/jpeg/JpegWriter.cxx b/vcl/source/filter/jpeg/JpegWriter.cxx
index 5f8abed..e763314 100644
--- a/vcl/source/filter/jpeg/JpegWriter.cxx
+++ b/vcl/source/filter/jpeg/JpegWriter.cxx
@@ -17,13 +17,12 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-extern "C"
-{
-    #include "stdio.h"
-    #include "jpeg.h"
-    #include <jpeglib.h>
-    #include <jerror.h>
-}
+#include <sal/config.h>
+
+#include "stdio.h"
+#include "jpeg.h"
+#include <jpeglib.h>
+#include <jerror.h>
 
 #include "JpegWriter.hxx"
 #include <vcl/bmpacc.hxx>
@@ -32,38 +31,21 @@ extern "C"
 
 #define BUFFER_SIZE  4096
 
-extern "C" void* GetScanline( void* pJPEGWriter, long nY )
+void* GetScanline( void* pJPEGWriter, long nY )
 {
     return ( (JPEGWriter*) pJPEGWriter )->GetScanline( nY );
 }
 
-struct JPEGCallbackStruct
+struct DestinationManagerStruct
 {
-    css::uno::Reference< css::task::XStatusIndicator > xStatusIndicator;
-};
-
-extern "C" long JPEGCallback( void* pCallbackData, long nPercent )
-{
-    JPEGCallbackStruct* pCallbackStruct = (JPEGCallbackStruct*)pCallbackData;
-    if ( pCallbackStruct && pCallbackStruct->xStatusIndicator.is() )
-    {
-        pCallbackStruct->xStatusIndicator->setValue( nPercent );
-    }
-    return 0L;
-}
-
-typedef struct
-{
-    struct jpeg_destination_mgr pub;  /* public fields */
+    jpeg_destination_mgr pub;         /* public fields */
     SvStream* stream;                 /* target stream */
     JOCTET * buffer;                  /* start of buffer */
-} DestinationManagerStruct;
-
-typedef DestinationManagerStruct* DestinationManagerStructPointer;
+};
 
 extern "C" void init_destination (j_compress_ptr cinfo)
 {
-    DestinationManagerStructPointer destination = (DestinationManagerStructPointer) cinfo->dest;
+    DestinationManagerStruct * destination = (DestinationManagerStruct *) cinfo->dest;
 
     /* Allocate the output buffer -- it will be released when done with image */
     destination->buffer = (JOCTET *)
@@ -75,7 +57,7 @@ extern "C" void init_destination (j_compress_ptr cinfo)
 
 extern "C" boolean empty_output_buffer (j_compress_ptr cinfo)
 {
-    DestinationManagerStructPointer destination = (DestinationManagerStructPointer) cinfo->dest;
+    DestinationManagerStruct * destination = (DestinationManagerStruct *) cinfo->dest;
 
     if (destination->stream->Write(destination->buffer, BUFFER_SIZE) != (size_t) BUFFER_SIZE)
     {
@@ -90,7 +72,7 @@ extern "C" boolean empty_output_buffer (j_compress_ptr cinfo)
 
 extern "C" void term_destination (j_compress_ptr cinfo)
 {
-    DestinationManagerStructPointer destination = (DestinationManagerStructPointer) cinfo->dest;
+    DestinationManagerStruct * destination = (DestinationManagerStruct *) cinfo->dest;
     size_t datacount = BUFFER_SIZE - destination->pub.free_in_buffer;
 
     /* Write any data remaining in the buffer */
@@ -103,10 +85,10 @@ extern "C" void term_destination (j_compress_ptr cinfo)
     }
 }
 
-extern "C" void jpeg_svstream_dest (j_compress_ptr cinfo, void* output)
+void jpeg_svstream_dest (j_compress_ptr cinfo, void* output)
 {
     SvStream* stream = (SvStream*) output;
-    DestinationManagerStructPointer destination;
+    DestinationManagerStruct * destination;
 
     /* The destination object is made permanent so that multiple JPEG images
      * can be written to the same file without re-executing jpeg_svstream_dest.
@@ -116,11 +98,11 @@ extern "C" void jpeg_svstream_dest (j_compress_ptr cinfo, void* output)
      */
     if (cinfo->dest == NULL)
     {    /* first time for this JPEG object? */
-        cinfo->dest = (struct jpeg_destination_mgr*)
+        cinfo->dest = (jpeg_destination_mgr*)
         (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(DestinationManagerStruct));
     }
 
-    destination = (DestinationManagerStructPointer) cinfo->dest;
+    destination = (DestinationManagerStruct *) cinfo->dest;
     destination->pub.init_destination = init_destination;
     destination->pub.empty_output_buffer = empty_output_buffer;
     destination->pub.term_destination = term_destination;
@@ -254,9 +236,7 @@ sal_Bool JPEGWriter::Write( const Graphic& rGraphic )
         if( !mbNative )
             mpBuffer = new sal_uInt8[ AlignedWidth4Bytes( mbGreys ? mpReadAccess->Width() * 8L : mpReadAccess->Width() * 24L ) ];
 
-        JPEGCallbackStruct aCallbackData;
-        aCallbackData.xStatusIndicator = mxStatusIndicator;
-        bRet = (sal_Bool) WriteJPEG( this, &mrStream, mpReadAccess->Width(), mpReadAccess->Height(), mbGreys, mnQuality, maChromaSubsampling, &aCallbackData );
+        bRet = (sal_Bool) WriteJPEG( this, &mrStream, mpReadAccess->Width(), mpReadAccess->Height(), mbGreys, mnQuality, maChromaSubsampling, mxStatusIndicator );
 
         delete[] mpBuffer;
         mpBuffer = NULL;
diff --git a/vcl/source/filter/jpeg/jpeg.h b/vcl/source/filter/jpeg/jpeg.h
index 6efa927..9701170 100644
--- a/vcl/source/filter/jpeg/jpeg.h
+++ b/vcl/source/filter/jpeg/jpeg.h
@@ -20,40 +20,29 @@
 #ifndef INCLUDED_VCL_SOURCE_FILTER_JPEG_JPEG_H
 #define INCLUDED_VCL_SOURCE_FILTER_JPEG_JPEG_H
 
-#if defined (UNX) || defined(__MINGW32__)
-#include <sys/types.h>
-#endif
+#include <sal/config.h>
 
-struct JPEGCreateBitmapParam
-{
-    unsigned long nWidth;
-    unsigned long nHeight;
-    unsigned long density_unit;
-    unsigned long X_density;
-    unsigned long Y_density;
-    long     bGray;
+#include <com/sun/star/uno/Reference.hxx>
+#include <sal/types.h>
 
-    long     nAlignedWidth;  // these members will be filled by the
-    long     bTopDown;      // CreateBitmap method in svtools
-};
+#include <jpeglib.h>
 
-typedef struct ErrorManagerStruct* ErrorManagerPointer;
-typedef unsigned char* HPBYTE;
+namespace com { namespace sun { namespace star { namespace task {
+    class XStatusIndicator;
+} } } }
+class JPEGReader;
+class JPEGWriter;
 
-void*   JPEGMalloc( size_t size );
-void    JPEGFree( void *ptr );
-long    JPEGCallback( void* pCallbackData, long nPercent );
+void jpeg_svstream_src (j_decompress_ptr cinfo, void* infile);
 
-long    WriteJPEG( void* pJPEGWriter, void* pOutputStream, long nWidth, long nHeight, long bGreyScale,
-                   long nQualityPercent, long aChromaSubsampling, void* pCallbackData );
-void*   GetScanline( void* pJPEGWriter, long nY );
+void jpeg_svstream_dest (j_compress_ptr cinfo, void* outfile);
 
-void    ReadJPEG( void* pJPEGReader, void* pInputStream, long* pLines );
-void*   CreateBitmapFromJPEGReader( void* pJPEGReader, void* pJPEGCreateBitmapParam );
+long    WriteJPEG( JPEGWriter* pJPEGWriter, void* pOutputStream, long nWidth, long nHeight, long bGreyScale,
+                   long nQualityPercent, long aChromaSubsampling,
+                   css::uno::Reference<css::task::XStatusIndicator> const & status);
 
-/* TODO: when incompatible changes are possible again
-   the preview size hint should be redone */
-void    SetJpegPreviewSizeHint( int nWidth, int nHeight );
+void    ReadJPEG( JPEGReader* pJPEGReader, void* pInputStream, long* pLines,
+                  int nPreviewWidth, int nPreviewHeight );
 
 long    Transform( void* pInputStream, void* pOutputStream, long nAngle );
 
diff --git a/vcl/source/filter/jpeg/jpegc.c b/vcl/source/filter/jpeg/jpegc.cxx
similarity index 85%
rename from vcl/source/filter/jpeg/jpegc.c
rename to vcl/source/filter/jpeg/jpegc.cxx
index c05a219..841a5e3 100644
--- a/vcl/source/filter/jpeg/jpegc.c
+++ b/vcl/source/filter/jpeg/jpegc.cxx
@@ -17,62 +17,57 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <setjmp.h>
 #include <jpeglib.h>
 #include <jerror.h>
 
-#include <rtl/alloc.h>
+#include <com/sun/star/task/XStatusIndicator.hpp>
 #include <osl/diagnose.h>
 
+extern "C" {
 #include "transupp.h"
+}
+
 #include "jpeg.h"
+#include <JpegReader.hxx>
+#include <JpegWriter.hxx>
 
 struct ErrorManagerStruct
 {
-    struct jpeg_error_mgr pub;
+    jpeg_error_mgr pub;
     jmp_buf setjmp_buffer;
 };
 
-void jpeg_svstream_src (j_decompress_ptr cinfo, void* infile);
-void jpeg_svstream_dest (j_compress_ptr cinfo, void* outfile);
-
-METHODDEF( void ) errorExit (j_common_ptr cinfo)
+extern "C" void errorExit (j_common_ptr cinfo)
 {
-    ErrorManagerPointer error = (ErrorManagerPointer) cinfo->err;
+    ErrorManagerStruct * error = (ErrorManagerStruct *) cinfo->err;
     (*cinfo->err->output_message) (cinfo);
     longjmp(error->setjmp_buffer, 1);
 }
 
-METHODDEF( void ) outputMessage (j_common_ptr cinfo)
+extern "C" void outputMessage (j_common_ptr cinfo)
 {
     char buffer[JMSG_LENGTH_MAX];
     (*cinfo->err->format_message) (cinfo, buffer);
 }
 
-/* TODO: when incompatible changes are possible again
-   the preview size hint should be redone */
-static int nPreviewWidth = 0;
-static int nPreviewHeight = 0;
-void SetJpegPreviewSizeHint( int nWidth, int nHeight )
-{
-    nPreviewWidth = nWidth;
-    nPreviewHeight = nHeight;
-}
-
-void ReadJPEG( void* pJPEGReader, void* pInputStream, long* pLines )
+void ReadJPEG( JPEGReader* pJPEGReader, void* pInputStream, long* pLines,
+               int nPreviewWidth, int nPreviewHeight )
 {
-    struct jpeg_decompress_struct   cinfo;
-    struct ErrorManagerStruct       jerr;
-    struct JPEGCreateBitmapParam    aCreateBitmapParam;
-    HPBYTE                          pDIB;
-    HPBYTE                          pTmp;
+    jpeg_decompress_struct          cinfo;
+    ErrorManagerStruct              jerr;
+    JPEGCreateBitmapParam           aCreateBitmapParam;
+    unsigned char *                 pDIB;
+    unsigned char *                 pTmp;
     long                            nWidth;
     long                            nHeight;
     long                            nAlignedWidth;
     JSAMPLE*                        aRangeLimit;
-    HPBYTE                          pScanLineBuffer = NULL;
+    unsigned char *                 pScanLineBuffer = NULL;
     long                            nScanLineBufferComponents = 0;
 
     if ( setjmp( jerr.setjmp_buffer ) )
@@ -147,15 +142,15 @@ void ReadJPEG( void* pJPEGReader, void* pInputStream, long* pLines )
     aCreateBitmapParam.density_unit = cinfo.density_unit;
     aCreateBitmapParam.X_density = cinfo.X_density;
     aCreateBitmapParam.Y_density = cinfo.Y_density;
-    aCreateBitmapParam.bGray = cinfo.output_components == 1;
-    pDIB = CreateBitmapFromJPEGReader( pJPEGReader, &aCreateBitmapParam );
+    aCreateBitmapParam.bGray = long(cinfo.output_components == 1);
+    pDIB = pJPEGReader->CreateBitmap( &aCreateBitmapParam );
     nAlignedWidth = aCreateBitmapParam.nAlignedWidth;
     aRangeLimit = cinfo.sample_range_limit;
 
     if ( cinfo.out_color_space == JCS_CMYK )
     {
         nScanLineBufferComponents = cinfo.output_width * 4;
-        pScanLineBuffer = rtl_allocateMemory( nScanLineBufferComponents );
+        pScanLineBuffer = new unsigned char[nScanLineBufferComponents];
     }
 
     if( pDIB )
@@ -213,20 +208,20 @@ void ReadJPEG( void* pJPEGReader, void* pInputStream, long* pLines )
 
     if (pScanLineBuffer != NULL)
     {
-        rtl_freeMemory( pScanLineBuffer );
+        delete[] pScanLineBuffer;
         pScanLineBuffer = NULL;
     }
 
     jpeg_destroy_decompress( &cinfo );
 }
 
-long WriteJPEG( void* pJPEGWriter, void* pOutputStream,
+long WriteJPEG( JPEGWriter* pJPEGWriter, void* pOutputStream,
                 long nWidth, long nHeight, long bGreys,
                 long nQualityPercent, long aChromaSubsampling,
-                void* pCallbackData )
+                css::uno::Reference<css::task::XStatusIndicator> const & status )
 {
-    struct jpeg_compress_struct cinfo;
-    struct ErrorManagerStruct   jerr;
+    jpeg_compress_struct        cinfo;
+    ErrorManagerStruct          jerr;
     void*                       pScanline;
     long                        nY;
 
@@ -282,17 +277,16 @@ long WriteJPEG( void* pJPEGWriter, void* pOutputStream,
 
     for( nY = 0; nY < nHeight; nY++ )
     {
-        pScanline = GetScanline( pJPEGWriter, nY );
+        pScanline = pJPEGWriter->GetScanline( nY );
 
         if( pScanline )
         {
             jpeg_write_scanlines( &cinfo, (JSAMPARRAY) &pScanline, 1 );
         }
 
-        if( JPEGCallback( pCallbackData, nY * 100L / nHeight ) )
+        if( status.is() )
         {
-            jpeg_destroy_compress( &cinfo );
-            return 0;
+            status->setValue( nY * 100L / nHeight );
         }
     }
 
@@ -307,10 +301,10 @@ long Transform(void* pInputStream, void* pOutputStream, long nAngle)
     jpeg_transform_info aTransformOption;
     JCOPY_OPTION        aCopyOption = JCOPYOPT_ALL;
 
-    struct jpeg_decompress_struct   aSourceInfo;
-    struct jpeg_compress_struct     aDestinationInfo;
-    struct ErrorManagerStruct       aSourceError;
-    struct ErrorManagerStruct       aDestinationError;
+    jpeg_decompress_struct   aSourceInfo;
+    jpeg_compress_struct     aDestinationInfo;
+    ErrorManagerStruct       aSourceError;
+    ErrorManagerStruct       aDestinationError;
 
     jvirt_barray_ptr* aSourceCoefArrays      = 0;
     jvirt_barray_ptr* aDestinationCoefArrays = 0;


More information about the Libreoffice-commits mailing list