xref: /aoo41x/main/svtools/source/inc/gifread.hxx (revision cdf0e10c)
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 _GIFREAD_HXX
29 #define _GIFREAD_HXX
30 
31 #ifndef _GRAPH_HXX
32 #include <vcl/graph.hxx>
33 #endif
34 #ifndef _BMPACC_HXX
35 #include <vcl/bmpacc.hxx>
36 #endif
37 
38 #ifdef _GIFPRIVATE
39 
40 // ---------
41 // - Enums -
42 // ---------
43 
44 enum GIFAction
45 {
46 	GLOBAL_HEADER_READING,
47 	MARKER_READING,
48 	EXTENSION_READING,
49 	LOCAL_HEADER_READING,
50 	FIRST_BLOCK_READING,
51 	NEXT_BLOCK_READING,
52 	ABORT_READING,
53 	END_READING
54 };
55 
56 // ------------------------------------------------------------------------
57 
58 enum ReadState
59 {
60 	GIFREAD_OK,
61 	GIFREAD_ERROR,
62 	GIFREAD_NEED_MORE
63 };
64 
65 // -------------
66 // - GIFReader -
67 // -------------
68 
69 class GIFLZWDecompressor;
70 
71 class SvStream;
72 
73 class GIFReader : public GraphicReader
74 {
75 	Graphic				aImGraphic;
76 	Animation			aAnimation;
77 	Bitmap				aBmp8;
78 	Bitmap				aBmp1;
79 	BitmapPalette		aGPalette;
80 	BitmapPalette		aLPalette;
81 	SvStream&			rIStm;
82 	void*				pCallerData;
83 	HPBYTE				pSrcBuf;
84 	GIFLZWDecompressor*	pDecomp;
85 	BitmapWriteAccess*	pAcc8;
86 	BitmapWriteAccess*	pAcc1;
87 	long				nYAcc;
88 	long				nLastPos;
89 	sal_uInt32			nLogWidth100;
90 	sal_uInt32			nLogHeight100;
91 	sal_uInt16				nTimer;
92 	sal_uInt16				nGlobalWidth;			// maximale Bildbreite aus Header
93 	sal_uInt16				nGlobalHeight;			// maximale Bildhoehe aus Header
94 	sal_uInt16				nImageWidth;			// maximale Bildbreite aus Header
95 	sal_uInt16				nImageHeight;			// maximale Bildhoehe aus Header
96 	sal_uInt16				nImagePosX;
97 	sal_uInt16				nImagePosY;
98 	sal_uInt16				nImageX;				// maximale Bildbreite aus Header
99 	sal_uInt16				nImageY;				// maximale Bildhoehe aus Header
100 	sal_uInt16				nLastImageY;
101 	sal_uInt16				nLastInterCount;
102 	sal_uInt16				nLoops;
103 	GIFAction			eActAction;
104 	sal_Bool				bStatus;
105 	sal_Bool				bGCTransparent;			// Ob das Bild Transparent ist, wenn ja:
106 	sal_Bool				bInterlaced;
107 	sal_Bool				bOverreadBlock;
108 	sal_Bool				bImGraphicReady;
109 	sal_Bool				bGlobalPalette;
110 	sal_uInt8				nBackgroundColor;		// Hintergrundfarbe
111 	sal_uInt8				nGCTransparentIndex;	// Pixel von diesem Index sind durchsichtig
112 	sal_uInt8				nGCDisposalMethod;		// 'Disposal Method' (siehe GIF-Doku)
113 	sal_uInt8				cTransIndex1;
114 	sal_uInt8				cNonTransIndex1;
115 
116 	void				ReadPaletteEntries( BitmapPalette* pPal, sal_uLong nCount );
117 	void				ClearImageExtensions();
118 	sal_Bool				CreateBitmaps( long nWidth, long nHeight, BitmapPalette* pPal, sal_Bool bWatchForBackgroundColor );
119 	sal_Bool				ReadGlobalHeader();
120 	sal_Bool				ReadExtension();
121 	sal_Bool				ReadLocalHeader();
122 	sal_uLong				ReadNextBlock();
123 	void				FillImages( HPBYTE pBytes, sal_uLong nCount );
124 	void				CreateNewBitmaps();
125 	sal_Bool				ProcessGIF();
126 
127 public:
128 
129 	ReadState			ReadGIF( Graphic& rGraphic );
130 	const Graphic&		GetIntermediateGraphic();
131 
132 						GIFReader( SvStream& rStm );
133 	virtual				~GIFReader();
134 };
135 
136 #endif // _GIFPRIVATE
137 
138 // -------------
139 // - ImportGIF -
140 // -------------
141 
142  sal_Bool ImportGIF( SvStream& rStream, Graphic& rGraphic );
143 
144 #endif // _GIFREAD_HXX
145