GrafX2 2.9.3227
The ultimate 256-color painting program

Portable Network Graphics. More...

+ Collaboration diagram for PNG format:

Data Structures

struct  PNG_memory_buffer
 Private structure used in PNG_memory_read() and PNG_memory_write() More...
 

Functions

void Test_PNG (T_IO_Context *context, FILE *file)
 Test for PNG format. More...
 
static int PNG_read_unknown_chunk (png_structp ptr, png_unknown_chunkp chunk)
 Callback to handle our private chunks. More...
 
static void PNG_memory_read (png_structp png_ptr, png_bytep p, png_size_t count)
 read from memory buffer More...
 
void Load_PNG_Sub (T_IO_Context *context, FILE *file, const char *memory_buffer, unsigned long memory_buffer_size)
 Read PNG format file. More...
 
void Load_PNG (T_IO_Context *context)
 Read PNG format files. More...
 
static void PNG_memory_write (png_structp png_ptr, png_bytep p, png_size_t count)
 Write to memory buffer. More...
 
static void PNG_memory_flush (png_structp png_ptr)
 do nothing More...
 
void Save_PNG_Sub (T_IO_Context *context, FILE *file, char **buffer, unsigned long *buffer_size)
 Save a PNG to file or memory. More...
 
void Save_PNG (T_IO_Context *context)
 Save a PNG file. More...
 

Detailed Description

Portable Network Graphics.

We make use of libpng : http://www.libpng.org/pub/png/libpng.html

Function Documentation

◆ Test_PNG()

void Test_PNG ( T_IO_Context context,
FILE *  file 
)

Test for PNG format.

The 8 byte signature at the start of file is tested

References File_error, and Read_bytes().

◆ PNG_read_unknown_chunk()

static int PNG_read_unknown_chunk ( png_structp  ptr,
png_unknown_chunkp  chunk 
)
static

Callback to handle our private chunks.

We have one private chunk at the moment :

  • "crNg" which is similar to a CRNG chunk in an IFF file

References T_IO_Context::Color_cycles, T_IO_Context::Cycle_range, T_Color_cycle::End, flags, GFX2_DEBUG, GFX2_Log(), GFX2_LogHexDump(), T_Color_cycle::Inverse, T_Color_cycle::Speed, T_Color_cycle::Start, and SWAP_BYTES.

Referenced by Load_PNG_Sub().

◆ PNG_memory_read()

static void PNG_memory_read ( png_structp  png_ptr,
png_bytep  p,
png_size_t  count 
)
static

read from memory buffer

References PNG_memory_buffer::buffer, GFX2_DEBUG, GFX2_Log(), NULL, and PNG_memory_buffer::size.

Referenced by Load_PNG_Sub().

◆ Load_PNG_Sub()

◆ Load_PNG()

void Load_PNG ( T_IO_Context context)

Read PNG format files.

just read/test the header and call Load_PNG_Sub()

References File_error, Load_PNG_Sub(), NULL, Open_file_read(), and Read_bytes().

◆ PNG_memory_write()

static void PNG_memory_write ( png_structp  png_ptr,
png_bytep  p,
png_size_t  count 
)
static

Write to memory buffer.

References PNG_memory_buffer::buffer, File_error, GFX2_DEBUG, GFX2_ERROR, GFX2_Log(), and NULL.

Referenced by Save_PNG_Sub().

◆ PNG_memory_flush()

static void PNG_memory_flush ( png_structp  png_ptr)
static

do nothing

References PNG_memory_buffer::buffer, GFX2_DEBUG, and GFX2_Log().

Referenced by Save_PNG_Sub().

◆ Save_PNG_Sub()

void Save_PNG_Sub ( T_IO_Context context,
FILE *  file,
char **  buffer,
unsigned long *  buffer_size 
)

◆ Save_PNG()

void Save_PNG ( T_IO_Context context)

Save a PNG file.

References File_error, NULL, Open_file_write(), Remove_file(), and Save_PNG_Sub().