xref: /trunk/main/svtools/source/inc/gifread.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*01aa44aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*01aa44aaSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*01aa44aaSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*01aa44aaSAndrew Rist  * distributed with this work for additional information
6*01aa44aaSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*01aa44aaSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*01aa44aaSAndrew Rist  * "License"); you may not use this file except in compliance
9*01aa44aaSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*01aa44aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*01aa44aaSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*01aa44aaSAndrew Rist  * software distributed under the License is distributed on an
15*01aa44aaSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*01aa44aaSAndrew Rist  * KIND, either express or implied.  See the License for the
17*01aa44aaSAndrew Rist  * specific language governing permissions and limitations
18*01aa44aaSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*01aa44aaSAndrew Rist  *************************************************************/
21*01aa44aaSAndrew Rist 
22*01aa44aaSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _GIFREAD_HXX
25cdf0e10cSrcweir #define _GIFREAD_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _GRAPH_HXX
28cdf0e10cSrcweir #include <vcl/graph.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _BMPACC_HXX
31cdf0e10cSrcweir #include <vcl/bmpacc.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #ifdef _GIFPRIVATE
35cdf0e10cSrcweir 
36cdf0e10cSrcweir // ---------
37cdf0e10cSrcweir // - Enums -
38cdf0e10cSrcweir // ---------
39cdf0e10cSrcweir 
40cdf0e10cSrcweir enum GIFAction
41cdf0e10cSrcweir {
42cdf0e10cSrcweir     GLOBAL_HEADER_READING,
43cdf0e10cSrcweir     MARKER_READING,
44cdf0e10cSrcweir     EXTENSION_READING,
45cdf0e10cSrcweir     LOCAL_HEADER_READING,
46cdf0e10cSrcweir     FIRST_BLOCK_READING,
47cdf0e10cSrcweir     NEXT_BLOCK_READING,
48cdf0e10cSrcweir     ABORT_READING,
49cdf0e10cSrcweir     END_READING
50cdf0e10cSrcweir };
51cdf0e10cSrcweir 
52cdf0e10cSrcweir // ------------------------------------------------------------------------
53cdf0e10cSrcweir 
54cdf0e10cSrcweir enum ReadState
55cdf0e10cSrcweir {
56cdf0e10cSrcweir     GIFREAD_OK,
57cdf0e10cSrcweir     GIFREAD_ERROR,
58cdf0e10cSrcweir     GIFREAD_NEED_MORE
59cdf0e10cSrcweir };
60cdf0e10cSrcweir 
61cdf0e10cSrcweir // -------------
62cdf0e10cSrcweir // - GIFReader -
63cdf0e10cSrcweir // -------------
64cdf0e10cSrcweir 
65cdf0e10cSrcweir class GIFLZWDecompressor;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir class SvStream;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir class GIFReader : public GraphicReader
70cdf0e10cSrcweir {
71cdf0e10cSrcweir     Graphic             aImGraphic;
72cdf0e10cSrcweir     Animation           aAnimation;
73cdf0e10cSrcweir     Bitmap              aBmp8;
74cdf0e10cSrcweir     Bitmap              aBmp1;
75cdf0e10cSrcweir     BitmapPalette       aGPalette;
76cdf0e10cSrcweir     BitmapPalette       aLPalette;
77cdf0e10cSrcweir     SvStream&           rIStm;
78cdf0e10cSrcweir     void*               pCallerData;
79cdf0e10cSrcweir     HPBYTE              pSrcBuf;
80cdf0e10cSrcweir     GIFLZWDecompressor* pDecomp;
81cdf0e10cSrcweir     BitmapWriteAccess*  pAcc8;
82cdf0e10cSrcweir     BitmapWriteAccess*  pAcc1;
83cdf0e10cSrcweir     long                nYAcc;
84cdf0e10cSrcweir     long                nLastPos;
85cdf0e10cSrcweir     sal_uInt32          nLogWidth100;
86cdf0e10cSrcweir     sal_uInt32          nLogHeight100;
87cdf0e10cSrcweir     sal_uInt16              nTimer;
88cdf0e10cSrcweir     sal_uInt16              nGlobalWidth;           // maximale Bildbreite aus Header
89cdf0e10cSrcweir     sal_uInt16              nGlobalHeight;          // maximale Bildhoehe aus Header
90cdf0e10cSrcweir     sal_uInt16              nImageWidth;            // maximale Bildbreite aus Header
91cdf0e10cSrcweir     sal_uInt16              nImageHeight;           // maximale Bildhoehe aus Header
92cdf0e10cSrcweir     sal_uInt16              nImagePosX;
93cdf0e10cSrcweir     sal_uInt16              nImagePosY;
94cdf0e10cSrcweir     sal_uInt16              nImageX;                // maximale Bildbreite aus Header
95cdf0e10cSrcweir     sal_uInt16              nImageY;                // maximale Bildhoehe aus Header
96cdf0e10cSrcweir     sal_uInt16              nLastImageY;
97cdf0e10cSrcweir     sal_uInt16              nLastInterCount;
98cdf0e10cSrcweir     sal_uInt16              nLoops;
99cdf0e10cSrcweir     GIFAction           eActAction;
100cdf0e10cSrcweir     sal_Bool                bStatus;
101cdf0e10cSrcweir     sal_Bool                bGCTransparent;         // Ob das Bild Transparent ist, wenn ja:
102cdf0e10cSrcweir     sal_Bool                bInterlaced;
103cdf0e10cSrcweir     sal_Bool                bOverreadBlock;
104cdf0e10cSrcweir     sal_Bool                bImGraphicReady;
105cdf0e10cSrcweir     sal_Bool                bGlobalPalette;
106cdf0e10cSrcweir     sal_uInt8               nBackgroundColor;       // Hintergrundfarbe
107cdf0e10cSrcweir     sal_uInt8               nGCTransparentIndex;    // Pixel von diesem Index sind durchsichtig
108cdf0e10cSrcweir     sal_uInt8               nGCDisposalMethod;      // 'Disposal Method' (siehe GIF-Doku)
109cdf0e10cSrcweir     sal_uInt8               cTransIndex1;
110cdf0e10cSrcweir     sal_uInt8               cNonTransIndex1;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     void                ReadPaletteEntries( BitmapPalette* pPal, sal_uLong nCount );
113cdf0e10cSrcweir     void                ClearImageExtensions();
114cdf0e10cSrcweir     sal_Bool                CreateBitmaps( long nWidth, long nHeight, BitmapPalette* pPal, sal_Bool bWatchForBackgroundColor );
115cdf0e10cSrcweir     sal_Bool                ReadGlobalHeader();
116cdf0e10cSrcweir     sal_Bool                ReadExtension();
117cdf0e10cSrcweir     sal_Bool                ReadLocalHeader();
118cdf0e10cSrcweir     sal_uLong               ReadNextBlock();
119cdf0e10cSrcweir     void                FillImages( HPBYTE pBytes, sal_uLong nCount );
120cdf0e10cSrcweir     void                CreateNewBitmaps();
121cdf0e10cSrcweir     sal_Bool                ProcessGIF();
122cdf0e10cSrcweir 
123cdf0e10cSrcweir public:
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     ReadState           ReadGIF( Graphic& rGraphic );
126cdf0e10cSrcweir     const Graphic&      GetIntermediateGraphic();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir                         GIFReader( SvStream& rStm );
129cdf0e10cSrcweir     virtual             ~GIFReader();
130cdf0e10cSrcweir };
131cdf0e10cSrcweir 
132cdf0e10cSrcweir #endif // _GIFPRIVATE
133cdf0e10cSrcweir 
134cdf0e10cSrcweir // -------------
135cdf0e10cSrcweir // - ImportGIF -
136cdf0e10cSrcweir // -------------
137cdf0e10cSrcweir 
138cdf0e10cSrcweir  sal_Bool ImportGIF( SvStream& rStream, Graphic& rGraphic );
139cdf0e10cSrcweir 
140cdf0e10cSrcweir #endif // _GIFREAD_HXX
141