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