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.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/fpng (Version 11.3.0) and /externals/g4tools/include/tools/fpng (Version 7.0.p1)


  1 #ifndef tools_fpng                                
  2 #define tools_fpng                                
  3                                                   
  4 // G.Barrand: pure header version of fpng foun    
  5 //            The original namespace fpng had     
  6 //            clashes with potential other usa    
  7                                                   
  8 // fpng.h - unlicense (see end of fpng.cpp)       
  9                                                   
 10 #include <stdlib.h>                               
 11 #include <stdint.h>                               
 12 #include <vector>                                 
 13                                                   
 14 namespace tools {                                 
 15 namespace fpng                                    
 16 {                                                 
 17   // Fast CRC-32 SSE4.1+pclmul or a scalar fal    
 18   const uint32_t FPNG_CRC32_INIT = 0;             
 19   uint32_t fpng_crc32(const void* pData, size_    
 20                                                   
 21   // Fast Adler32 SSE4.1 Adler-32 with a scala    
 22   const uint32_t FPNG_ADLER32_INIT = 1;           
 23   uint32_t fpng_adler32(const void* pData, siz    
 24                                                   
 25   // ---- Compression                             
 26   enum                                            
 27   {                                               
 28     // Enables computing custom Huffman tables    
 29     // Results in roughly 6% smaller files on     
 30     FPNG_ENCODE_SLOWER = 1,                       
 31                                                   
 32     // Only use raw Deflate blocks (no compres    
 33     FPNG_FORCE_UNCOMPRESSED = 2,                  
 34   };                                              
 35                                                   
 36   // Fast PNG encoding. The resulting file can    
 37   // pImage: pointer to RGB or RGBA image pixe    
 38   // w/h - image dimensions. Image's row pitch    
 39   // num_chans must be 3 or 4.                    
 40   bool fpng_encode_image_to_memory(const void*    
 41                                                   
 42   // Fast PNG encoding to the specified file.     
 43   bool fpng_encode_image_to_file(const char* p    
 44                                                   
 45   // ---- Decompression                           
 46                                                   
 47   enum                                            
 48   {                                               
 49     FPNG_DECODE_SUCCESS = 0,        // file is    
 50                                                   
 51     FPNG_DECODE_NOT_FPNG,         // file is a    
 52                                                   
 53     FPNG_DECODE_INVALID_ARG,        // invalid    
 54                                                   
 55     FPNG_DECODE_FAILED_NOT_PNG,       // file     
 56     FPNG_DECODE_FAILED_HEADER_CRC32,    // a c    
 57     FPNG_DECODE_FAILED_INVALID_DIMENSIONS,  //    
 58     FPNG_DECODE_FAILED_DIMENSIONS_TOO_LARGE, /    
 59     FPNG_DECODE_FAILED_CHUNK_PARSING,   // fai    
 60     FPNG_DECODE_FAILED_INVALID_IDAT,    // IDA    
 61                                                   
 62     // fpng_decode_file() specific errors         
 63     FPNG_DECODE_FILE_OPEN_FAILED,                 
 64     FPNG_DECODE_FILE_TOO_LARGE,                   
 65     FPNG_DECODE_FILE_READ_FAILED,                 
 66     FPNG_DECODE_FILE_SEEK_FAILED                  
 67   };                                              
 68                                                   
 69   // Fast PNG decoding of files ONLY created b    
 70   // If fpng_get_info() or fpng_decode_memory(    
 71   //                                              
 72   // fpng_get_info() parses the PNG header and    
 73   //                                              
 74   // pImage, image_size: Pointer to PNG image     
 75   // width, height: output image's dimensions     
 76   // channels_in_file: will be 3 or 4             
 77   //                                              
 78   // Returns FPNG_DECODE_SUCCESS on success, o    
 79   // If FPNG_DECODE_NOT_FPNG is returned, you     
 80   // If another error occurs, the file is like    
 81   int fpng_get_info(const void* pImage, uint32    
 82                                                   
 83   // fpng_decode_memory() decompresses 24/32bp    
 84   // If the image was written by FPNG, it will    
 85   //                                              
 86   // pImage, image_size: Pointer to PNG image     
 87   // out: Output 24/32bpp image buffer            
 88   // width, height: output image's dimensions     
 89   // channels_in_file: will be 3 or 4             
 90   // desired_channels: must be 3 or 4             
 91   //                                              
 92   // If the image is 24bpp and 32bpp is reques    
 93   // If the image is 32bpp and 24bpp is reques    
 94   //                                              
 95   // Returns FPNG_DECODE_SUCCESS on success, o    
 96   // If FPNG_DECODE_NOT_FPNG is returned, you     
 97   // If another error occurs, the file is like    
 98   int fpng_decode_memory(const void* pImage, u    
 99                                                   
100   int fpng_decode_file(const char* pFilename,     
101                                                   
102 } // namespace fpng                               
103 } // namespace tools                              
104                                                   
105 //G.Barrand specific:                             
106 #include "fpng.icc"                               
107                                                   
108 #include "sout"                                   
109                                                   
110 #include <ostream>                                
111                                                   
112 namespace tools {                                 
113 namespace fpng {                                  
114                                                   
115 inline bool write(std::ostream& a_out,            
116                   const std::string& a_file,      
117                   unsigned char* a_buffer,        
118                   unsigned int a_width,           
119                   unsigned int a_height,          
120                   unsigned int a_bpp) {           
121   if((a_bpp!=3)&&(a_bpp!=4)) {                    
122     a_out << "tools::fpng::write : bpp " << a_    
123     return false;                                 
124   }                                               
125   if(!fpng_encode_image_to_file(a_file.c_str()    
126     a_out << "tools::fpng::write : encode() fa    
127     return false;                                 
128   }                                               
129   return true;                                    
130 }                                                 
131                                                   
132 }}                                                
133                                                   
134 #endif //tools_fpng