xref: /aoo4110/main/svtools/source/inc/jpeg.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _JPEG_HXX
25 #define _JPEG_HXX
26 
27 #ifndef _GRAPH_HXX
28 #include <vcl/graph.hxx>
29 #endif
30 #include <svtools/fltcall.hxx>
31 #include <com/sun/star/uno/Sequence.h>
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 #include <com/sun/star/task/XStatusIndicator.hpp>
34 
35 #ifdef _JPEGPRIVATE
36 
37 // --------
38 // - Enum -
39 // --------
40 
41 enum ReadState
42 {
43 	JPEGREAD_OK,
44 	JPEGREAD_ERROR,
45 	JPEGREAD_NEED_MORE
46 };
47 
48 // --------------
49 // - JPEGReader	-
50 // --------------
51 
52 class JPEGReader : public GraphicReader
53 {
54 	SvStream&			rIStm;
55 	Bitmap				aBmp;
56 	Bitmap				aBmp1;
57 	BitmapWriteAccess*	pAcc;
58 	BitmapWriteAccess*	pAcc1;
59 	void*				pBuffer;
60 	long				nLastPos;
61 	long				nFormerPos;
62 	long				nLastLines;
63     sal_Bool            bSetLogSize;
64 
65 	Graphic				CreateIntermediateGraphic( const Bitmap& rBitmap, long nLines );
66 	void				FillBitmap();
67 
68 public:
69 
70 	void*				CreateBitmap( void* JPEGCreateBitmapParam );
71 
72 public:
73 
74 
75 
76 						JPEGReader( SvStream& rStm, void* pCallData, sal_Bool bSetLogSize );
77 	virtual				~JPEGReader();
78 
79 
80 	ReadState			Read( Graphic& rGraphic );
81 };
82 
83 // --------------
84 // - JPEGWriter	-
85 // --------------
86 
87 class JPEGWriter
88 {
89 	SvStream&			rOStm;
90 	Bitmap				aBmp;
91 	BitmapReadAccess*	pAcc;
92 	sal_uInt8*				pBuffer;
93 	sal_Bool				bNative;
94 
95 	sal_Bool			bGreys;
96 	sal_Int32			nQuality;
97 
98 	bool*               pExpWasGrey;
99 
100 	com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
101 
102 public:
103 
104 	void*				GetScanline( long nY );
105 
106 						JPEGWriter( SvStream& rOStm, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >* pFilterData,
107 						            bool* pExportWasGrey = NULL );
~JPEGWriter()108 						~JPEGWriter() {};
109 
110 	sal_Bool				Write( const Graphic& rGraphic );
111 };
112 
113 #endif // _JPEGPRIVATE
114 
115 // ---------------------
116 // - Import/ExportJPEG -
117 // ---------------------
118 
119 sal_Bool ImportJPEG( SvStream& rStream, Graphic& rGraphic, void* pCallerData, sal_Int32 nImportFlags );
120 
121 sal_Bool ExportJPEG( SvStream& rStream,
122                  const Graphic& rGraphic,
123                  const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >* pFilterData,
124                  bool* pExportWasGrey = NULL
125                 );
126 
127 #endif // _JPEG_HXX
128