1 /******************************************************************************
2  * $Id: gifabstractdataset.h b55a33407a80673ec314b165c82f47dd02e9dc9c 2020-04-27 20:37:55 +0200 Even Rouault $
3  *
4  * Project:  GIF Driver
5  * Purpose:  GIF Abstract Dataset
6  * Author:   Even Rouault <even dot rouault at spatialys.com>
7  *
8  ****************************************************************************
9  * Copyright (c) 2011-2013, Even Rouault <even dot rouault at spatialys.com>
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included
19  * in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  ****************************************************************************/
29 
30 #ifndef GIFABSTRACTDATASET_H_INCLUDED
31 #define GIFABSTRACTDATASET_H_INCLUDED
32 
33 #include "gdal_pam.h"
34 
35 CPL_C_START
36 #include "gif_lib.h"
37 CPL_C_END
38 
39 /************************************************************************/
40 /* ==================================================================== */
41 /*                        GIFAbstractDataset                            */
42 /* ==================================================================== */
43 /************************************************************************/
44 
45 class GIFAbstractDataset CPL_NON_FINAL: public GDALPamDataset
46 {
47   protected:
48     friend class    GIFAbstractRasterBand;
49 
50     VSILFILE        *fp;
51 
52     GifFileType *hGifFile;
53 
54     char        *pszProjection;
55     int         bGeoTransformValid;
56     double      adfGeoTransform[6];
57 
58     int         nGCPCount;
59     GDAL_GCP    *pasGCPList;
60 
61     int         bHasReadXMPMetadata;
62     void        CollectXMPMetadata();
63 
64     CPLString   osWldFilename;
65 
66     void        DetectGeoreferencing( GDALOpenInfo * poOpenInfo );
67 
68   public:
69     GIFAbstractDataset();
70     ~GIFAbstractDataset() override;
71 
72     const char *_GetProjectionRef() override;
GetSpatialRef()73     const OGRSpatialReference* GetSpatialRef() const override {
74         return GetSpatialRefFromOldGetProjectionRef();
75     }
76     CPLErr GetGeoTransform( double * ) override;
77     int GetGCPCount() override;
78     const char *_GetGCPProjection() override;
GetGCPSpatialRef()79     const OGRSpatialReference* GetGCPSpatialRef() const override {
80         return GetGCPSpatialRefFromOldGetGCPProjection();
81     }
82     const GDAL_GCP *GetGCPs() override;
83 
84     char **GetMetadataDomainList() override;
85     char **GetMetadata( const char * pszDomain = "" ) override;
86 
87     char **GetFileList() override;
88 
89     static int          Identify( GDALOpenInfo * );
90 
91     static GifFileType* myDGifOpen( void *userPtr, InputFunc readFunc );
92     static int          myDGifCloseFile( GifFileType *hGifFile );
93     static int          myEGifCloseFile( GifFileType *hGifFile );
94     static int          ReadFunc( GifFileType *psGFile, GifByteType *pabyBuffer,
95                                   int nBytesToRead );
96     static GifRecordType FindFirstImage( GifFileType* hGifFile );
97 };
98 
99 /************************************************************************/
100 /* ==================================================================== */
101 /*                        GIFAbstractRasterBand                         */
102 /* ==================================================================== */
103 /************************************************************************/
104 
105 class GIFAbstractRasterBand CPL_NON_FINAL: public GDALPamRasterBand
106 {
107   protected:
108     SavedImage  *psImage;
109 
110     int         *panInterlaceMap;
111 
112     GDALColorTable *poColorTable;
113 
114     int         nTransparentColor;
115 
116   public:
117     GIFAbstractRasterBand(GIFAbstractDataset *poDS, int nBand,
118                           SavedImage *psSavedImage, int nBackground,
119                           int bAdvertiseInterlacedMDI );
120     ~GIFAbstractRasterBand() override;
121 
122     double GetNoDataValue( int *pbSuccess = nullptr ) override;
123     GDALColorInterp GetColorInterpretation() override;
124     GDALColorTable *GetColorTable() override;
125 };
126 
127 #endif
128