LCOV - code coverage report
Current view: top level - frmts/gif - gifdrivercore.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 42 42 100.0 %
Date: 2024-11-21 22:18:42 Functions: 7 7 100.0 %

          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      103558 : int GIFDriverIdentify(GDALOpenInfo *poOpenInfo)
      21             : 
      22             : {
      23      103558 :     if (poOpenInfo->nHeaderBytes < 8 || !poOpenInfo->fpL)
      24       96219 :         return FALSE;
      25             : 
      26       14626 :     return (memcmp(poOpenInfo->pabyHeader, "GIF87a", 6) == 0 ||
      27       14626 :             memcmp(poOpenInfo->pabyHeader, "GIF89a", 6) == 0);
      28             : }
      29             : 
      30             : /************************************************************************/
      31             : /*                      BIGGIFDriverSetCommonMetadata()                 */
      32             : /************************************************************************/
      33             : 
      34        1312 : void BIGGIFDriverSetCommonMetadata(GDALDriver *poDriver)
      35             : {
      36        1312 :     poDriver->SetDescription(BIGGIF_DRIVER_NAME);
      37        1312 :     poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES");
      38        1312 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME,
      39        1312 :                               "Graphics Interchange Format (.gif)");
      40        1312 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/gif.html");
      41        1312 :     poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "gif");
      42        1312 :     poDriver->SetMetadataItem(GDAL_DMD_MIMETYPE, "image/gif");
      43        1312 :     poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES");
      44             : 
      45        1312 :     poDriver->pfnIdentify = GIFDriverIdentify;
      46        1312 :     poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES");
      47        1312 : }
      48             : 
      49             : /************************************************************************/
      50             : /*                      GIFDriverSetCommonMetadata()                    */
      51             : /************************************************************************/
      52             : 
      53        1312 : void GIFDriverSetCommonMetadata(GDALDriver *poDriver)
      54             : {
      55        1312 :     poDriver->SetDescription(GIF_DRIVER_NAME);
      56        1312 :     poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES");
      57        1312 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME,
      58        1312 :                               "Graphics Interchange Format (.gif)");
      59        1312 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/gif.html");
      60        1312 :     poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "gif");
      61        1312 :     poDriver->SetMetadataItem(GDAL_DMD_MIMETYPE, "image/gif");
      62        1312 :     poDriver->SetMetadataItem(GDAL_DMD_CREATIONDATATYPES, "Byte");
      63             : 
      64        1312 :     poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST,
      65             :                               "<CreationOptionList>\n"
      66             :                               "   <Option name='INTERLACING' type='boolean'/>\n"
      67             :                               "   <Option name='WORLDFILE' type='boolean'/>\n"
      68        1312 :                               "</CreationOptionList>\n");
      69             : 
      70        1312 :     poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES");
      71             : 
      72        1312 :     poDriver->pfnIdentify = GIFDriverIdentify;
      73        1312 :     poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES");
      74        1312 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATECOPY, "YES");
      75        1312 : }
      76             : 
      77             : /************************************************************************/
      78             : /*                     DeclareDeferredGIFPlugin()                       */
      79             : /************************************************************************/
      80             : 
      81             : #ifdef PLUGIN_FILENAME
      82        1595 : void DeclareDeferredGIFPlugin()
      83             : {
      84        1595 :     if (GDALGetDriverByName(GIF_DRIVER_NAME) != nullptr)
      85             :     {
      86         302 :         return;
      87             :     }
      88             :     {
      89        1293 :         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        1293 :         GIFDriverSetCommonMetadata(poDriver);
      95        1293 :         GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver);
      96             :     }
      97             :     {
      98        1293 :         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        1293 :         BIGGIFDriverSetCommonMetadata(poDriver);
     104        1293 :         GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver);
     105             :     }
     106             : }
     107             : #endif

Generated by: LCOV version 1.14