1 #ifndef __GIF_Handler_hpp__ 2 #define __GIF_Handler_hpp__ 1 3 4 // ================================================================================================= 5 // ADOBE SYSTEMS INCORPORATED 6 // Copyright 2008 Adobe Systems Incorporated 7 // All Rights Reserved 8 // 9 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms 10 // of the Adobe license agreement accompanying it. 11 // 12 // This file includes implementation of GIF file metadata, according to GIF89a Specification. 13 // https://www.w3.org/Graphics/GIF/spec-gif89a.txt 14 // The Graphics Interchange Format(c) is the Copyright property of CompuServe Incorporated. 15 // GIF(sm) is a Service Mark property of CompuServe Incorporated. 16 // All Rights Reserved . http://www.w3.org/Consortium/Legal 17 // 18 //Derived from PNG_Handler.hpp by Ian Jacobi 19 // ================================================================================================= 20 21 #include "public/include/XMP_Environment.h" // ! Must be the first #include! 22 23 #include "public/include/XMP_Const.h" 24 #include "public/include/XMP_IO.hpp" 25 26 #include "XMPFiles/source/XMPFiles_Impl.hpp" 27 28 // ================================================================================================= 29 /// \file GIF_Handler.hpp 30 /// \brief File format handler for GIF. 31 /// 32 /// This header ... 33 /// 34 // ================================================================================================= 35 36 // *** Could derive from Basic_Handler - buffer file tail in a temp file. 37 38 extern XMPFileHandler* GIF_MetaHandlerCTor ( XMPFiles* parent ); 39 40 extern bool GIF_CheckFormat ( XMP_FileFormat format, 41 XMP_StringPtr filePath, 42 XMP_IO* fileRef, 43 XMPFiles* parent ); 44 45 static const XMP_OptionBits kGIF_HandlerFlags = ( kXMPFiles_CanInjectXMP | 46 kXMPFiles_CanExpand | 47 kXMPFiles_PrefersInPlace | 48 kXMPFiles_AllowsOnlyXMP | 49 kXMPFiles_ReturnsRawPacket | 50 kXMPFiles_NeedsReadOnlyPacket 51 ); 52 53 class GIF_MetaHandler : public XMPFileHandler 54 { 55 public: 56 57 void CacheFileData(); 58 void ProcessXMP(); 59 60 void UpdateFile ( bool doSafeUpdate ); 61 void WriteTempFile ( XMP_IO* tempRef ); 62 63 bool SafeWriteFile (); 64 65 GIF_MetaHandler ( XMPFiles* parent ); 66 virtual ~GIF_MetaHandler(); 67 68 private: 69 70 enum GIFBlockType 71 { 72 kXMP_block_ImageDesc = 0x2C, 73 kXMP_block_Extension = 0x21, 74 kXMP_block_Trailer = 0x3B, 75 kXMP_block_Header = 0x47 76 }; 77 78 XMP_Uns64 XMPPacketOffset; 79 XMP_Uns32 XMPPacketLength; 80 XMP_Uns64 trailerOffset; 81 82 bool ParseGIFBlocks( XMP_IO * fileRef ); 83 void ReadLogicalScreenDesc( XMP_IO* fileRef ); 84 void SeekFile( XMP_IO * fileRef, XMP_Int64 offset, SeekMode mode ); 85 86 }; // GIF_MetaHandler 87 88 // ================================================================================================= 89 90 #endif /* __GIF_Handler_hpp__ */ 91