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 : * SPDX-License-Identifier: MIT 12 : ****************************************************************************/ 13 : 14 : #include "gifdrivercore.h" 15 : 16 : /************************************************************************/ 17 : /* GIFDriverIdentify() */ 18 : /************************************************************************/ 19 : 20 104680 : int GIFDriverIdentify(GDALOpenInfo *poOpenInfo) 21 : 22 : { 23 104680 : if (poOpenInfo->nHeaderBytes < 8 || !poOpenInfo->fpL) 24 97153 : return FALSE; 25 : 26 15002 : return (memcmp(poOpenInfo->pabyHeader, "GIF87a", 6) == 0 || 27 15002 : memcmp(poOpenInfo->pabyHeader, "GIF89a", 6) == 0); 28 : } 29 : 30 : /************************************************************************/ 31 : /* BIGGIFDriverSetCommonMetadata() */ 32 : /************************************************************************/ 33 : 34 1400 : void BIGGIFDriverSetCommonMetadata(GDALDriver *poDriver) 35 : { 36 1400 : poDriver->SetDescription(BIGGIF_DRIVER_NAME); 37 1400 : poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES"); 38 1400 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, 39 1400 : "Graphics Interchange Format (.gif)"); 40 1400 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/gif.html"); 41 1400 : poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "gif"); 42 1400 : poDriver->SetMetadataItem(GDAL_DMD_MIMETYPE, "image/gif"); 43 1400 : poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); 44 : 45 1400 : poDriver->pfnIdentify = GIFDriverIdentify; 46 1400 : poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES"); 47 1400 : } 48 : 49 : /************************************************************************/ 50 : /* GIFDriverSetCommonMetadata() */ 51 : /************************************************************************/ 52 : 53 1400 : void GIFDriverSetCommonMetadata(GDALDriver *poDriver) 54 : { 55 1400 : poDriver->SetDescription(GIF_DRIVER_NAME); 56 1400 : poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES"); 57 1400 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, 58 1400 : "Graphics Interchange Format (.gif)"); 59 1400 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/gif.html"); 60 1400 : poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "gif"); 61 1400 : poDriver->SetMetadataItem(GDAL_DMD_MIMETYPE, "image/gif"); 62 1400 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONDATATYPES, "Byte"); 63 : 64 1400 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST, 65 : "<CreationOptionList>\n" 66 : " <Option name='INTERLACING' type='boolean'/>\n" 67 : " <Option name='WORLDFILE' type='boolean'/>\n" 68 1400 : "</CreationOptionList>\n"); 69 : 70 1400 : poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); 71 : 72 1400 : poDriver->pfnIdentify = GIFDriverIdentify; 73 1400 : poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES"); 74 1400 : poDriver->SetMetadataItem(GDAL_DCAP_CREATECOPY, "YES"); 75 1400 : } 76 : 77 : /************************************************************************/ 78 : /* DeclareDeferredGIFPlugin() */ 79 : /************************************************************************/ 80 : 81 : #ifdef PLUGIN_FILENAME 82 1682 : void DeclareDeferredGIFPlugin() 83 : { 84 1682 : if (GDALGetDriverByName(GIF_DRIVER_NAME) != nullptr) 85 : { 86 301 : return; 87 : } 88 : { 89 1381 : auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME); 90 : #ifdef PLUGIN_INSTALLATION_MESSAGE 91 : poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE, 92 : PLUGIN_INSTALLATION_MESSAGE); 93 : #endif 94 1381 : GIFDriverSetCommonMetadata(poDriver); 95 1381 : GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver); 96 : } 97 : { 98 1381 : auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME); 99 : #ifdef PLUGIN_INSTALLATION_MESSAGE 100 : poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE, 101 : PLUGIN_INSTALLATION_MESSAGE); 102 : #endif 103 1381 : BIGGIFDriverSetCommonMetadata(poDriver); 104 1381 : GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver); 105 : } 106 : } 107 : #endif