xref: /trunk/main/svtools/source/inc/jpeg.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _JPEG_HXX
29 #define _JPEG_HXX
30 
31 #ifndef _GRAPH_HXX
32 #include <vcl/graph.hxx>
33 #endif
34 #include <svtools/fltcall.hxx>
35 #include <com/sun/star/uno/Sequence.h>
36 #include <com/sun/star/beans/PropertyValue.hpp>
37 #include <com/sun/star/task/XStatusIndicator.hpp>
38 
39 #ifdef _JPEGPRIVATE
40 
41 // --------
42 // - Enum -
43 // --------
44 
45 enum ReadState
46 {
47     JPEGREAD_OK,
48     JPEGREAD_ERROR,
49     JPEGREAD_NEED_MORE
50 };
51 
52 // --------------
53 // - JPEGReader -
54 // --------------
55 
56 class JPEGReader : public GraphicReader
57 {
58     SvStream&           rIStm;
59     Bitmap              aBmp;
60     Bitmap              aBmp1;
61     BitmapWriteAccess*  pAcc;
62     BitmapWriteAccess*  pAcc1;
63     void*               pBuffer;
64     long                nLastPos;
65     long                nFormerPos;
66     long                nLastLines;
67     sal_Bool            bSetLogSize;
68 
69     Graphic             CreateIntermediateGraphic( const Bitmap& rBitmap, long nLines );
70     void                FillBitmap();
71 
72 public:
73 
74     void*               CreateBitmap( void* JPEGCreateBitmapParam );
75 
76 public:
77 
78 
79 
80                         JPEGReader( SvStream& rStm, void* pCallData, sal_Bool bSetLogSize );
81     virtual             ~JPEGReader();
82 
83 
84     ReadState           Read( Graphic& rGraphic );
85 };
86 
87 // --------------
88 // - JPEGWriter -
89 // --------------
90 
91 class JPEGWriter
92 {
93     SvStream&           rOStm;
94     Bitmap              aBmp;
95     BitmapReadAccess*   pAcc;
96     sal_uInt8*              pBuffer;
97     sal_Bool                bNative;
98 
99     sal_Bool            bGreys;
100     sal_Int32           nQuality;
101 
102     bool*               pExpWasGrey;
103 
104     com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
105 
106 public:
107 
108     void*               GetScanline( long nY );
109 
110                         JPEGWriter( SvStream& rOStm, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >* pFilterData,
111                                     bool* pExportWasGrey = NULL );
112                         ~JPEGWriter() {};
113 
114     sal_Bool                Write( const Graphic& rGraphic );
115 };
116 
117 #endif // _JPEGPRIVATE
118 
119 // ---------------------
120 // - Import/ExportJPEG -
121 // ---------------------
122 
123 sal_Bool ImportJPEG( SvStream& rStream, Graphic& rGraphic, void* pCallerData, sal_Int32 nImportFlags );
124 
125 sal_Bool ExportJPEG( SvStream& rStream,
126                  const Graphic& rGraphic,
127                  const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >* pFilterData,
128                  bool* pExportWasGrey = NULL
129                 );
130 
131 #endif // _JPEG_HXX
132