Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GIF Driver 4 : * Purpose: Implement GDAL GIF Support using libungif code. 5 : * Author: Frank Warmerdam, warmerdam@pobox.com 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2001, Frank Warmerdam 9 : * Copyright (c) 2007-2012, 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 : #include "gifdrivercore.h" 31 : 32 : /************************************************************************/ 33 : /* GIFDriverIdentify() */ 34 : /************************************************************************/ 35 : 36 98203 : int GIFDriverIdentify(GDALOpenInfo *poOpenInfo) 37 : 38 : { 39 98203 : if (poOpenInfo->nHeaderBytes < 8 || !poOpenInfo->fpL) 40 91263 : return FALSE; 41 : 42 13828 : return (memcmp(poOpenInfo->pabyHeader, "GIF87a", 6) == 0 || 43 13828 : memcmp(poOpenInfo->pabyHeader, "GIF89a", 6) == 0); 44 : } 45 : 46 : /************************************************************************/ 47 : /* BIGGIFDriverSetCommonMetadata() */ 48 : /************************************************************************/ 49 : 50 1236 : void BIGGIFDriverSetCommonMetadata(GDALDriver *poDriver) 51 : { 52 1236 : poDriver->SetDescription(BIGGIF_DRIVER_NAME); 53 1236 : poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES"); 54 1236 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, 55 1236 : "Graphics Interchange Format (.gif)"); 56 1236 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/gif.html"); 57 1236 : poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "gif"); 58 1236 : poDriver->SetMetadataItem(GDAL_DMD_MIMETYPE, "image/gif"); 59 1236 : poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); 60 : 61 1236 : poDriver->pfnIdentify = GIFDriverIdentify; 62 1236 : poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES"); 63 1236 : } 64 : 65 : /************************************************************************/ 66 : /* GIFDriverSetCommonMetadata() */ 67 : /************************************************************************/ 68 : 69 1236 : void GIFDriverSetCommonMetadata(GDALDriver *poDriver) 70 : { 71 1236 : poDriver->SetDescription(GIF_DRIVER_NAME); 72 1236 : poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES"); 73 1236 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, 74 1236 : "Graphics Interchange Format (.gif)"); 75 1236 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/gif.html"); 76 1236 : poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "gif"); 77 1236 : poDriver->SetMetadataItem(GDAL_DMD_MIMETYPE, "image/gif"); 78 1236 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONDATATYPES, "Byte"); 79 : 80 1236 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST, 81 : "<CreationOptionList>\n" 82 : " <Option name='INTERLACING' type='boolean'/>\n" 83 : " <Option name='WORLDFILE' type='boolean'/>\n" 84 1236 : "</CreationOptionList>\n"); 85 : 86 1236 : poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); 87 : 88 1236 : poDriver->pfnIdentify = GIFDriverIdentify; 89 1236 : poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES"); 90 1236 : poDriver->SetMetadataItem(GDAL_DCAP_CREATECOPY, "YES"); 91 1236 : } 92 : 93 : /************************************************************************/ 94 : /* DeclareDeferredGIFPlugin() */ 95 : /************************************************************************/ 96 : 97 : #ifdef PLUGIN_FILENAME 98 1520 : void DeclareDeferredGIFPlugin() 99 : { 100 1520 : if (GDALGetDriverByName(GIF_DRIVER_NAME) != nullptr) 101 : { 102 301 : return; 103 : } 104 : { 105 1219 : auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME); 106 : #ifdef PLUGIN_INSTALLATION_MESSAGE 107 : poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE, 108 : PLUGIN_INSTALLATION_MESSAGE); 109 : #endif 110 1219 : GIFDriverSetCommonMetadata(poDriver); 111 1219 : GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver); 112 : } 113 : { 114 1219 : auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME); 115 : #ifdef PLUGIN_INSTALLATION_MESSAGE 116 : poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE, 117 : PLUGIN_INSTALLATION_MESSAGE); 118 : #endif 119 1219 : BIGGIFDriverSetCommonMetadata(poDriver); 120 1219 : GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver); 121 : } 122 : } 123 : #endif