GrafX2 2.9.3227
The ultimate 256-color painting program
|
Graphics Interchange Format. More...
Data Structures | |
struct | T_GIF_LSDB |
Logical Screen Descriptor Block. More... | |
struct | T_GIF_IDB |
Image Descriptor Block. More... | |
struct | T_GIF_GCE |
Graphic Control Extension. More... | |
struct | T_GIF_context |
struct | gif_alphabet |
Enumerations | |
enum | DISPOSAL_METHOD { DISPOSAL_METHOD_UNDEFINED = 0 , DISPOSAL_METHOD_DO_NOT_DISPOSE = 1 , DISPOSAL_METHOD_RESTORE_BGCOLOR = 2 , DISPOSAL_METHOD_RESTORE_PREVIOUS = 3 } |
Functions | |
void | Test_GIF (T_IO_Context *context, FILE *file) |
Test if a file is GIF format. More... | |
static word | GIF_get_next_code (FILE *GIF_file, T_GIF_context *gif) |
Reads the next code (GIF.nb_bits bits) More... | |
static void | GIF_new_pixel (T_IO_Context *context, T_GIF_context *gif, T_GIF_IDB *idb, int is_transparent, byte color) |
Put a new pixel. More... | |
void | Load_GIF (T_IO_Context *context) |
Load GIF file. More... | |
static void | GIF_empty_buffer (FILE *file, T_GIF_context *gif, byte *GIF_buffer) |
Flush the buffer. More... | |
static void | GIF_set_code (FILE *GIF_file, T_GIF_context *gif, byte *GIF_buffer, word Code) |
Write a code (GIF_nb_bits bits) More... | |
static byte | GIF_next_pixel (T_IO_Context *context, T_GIF_context *gif, T_GIF_IDB *idb) |
Read the next pixel. More... | |
void | Save_GIF (T_IO_Context *context) |
Save a GIF file. More... | |
Graphics Interchange Format.
The GIF format uses LZW compression and stores indexed color pictures up to 256 colors. It has the ability to store several pictures in the same file : GrafX2 takes advantage of this feature for storing layered images and animations.
GrafX2 implements GIF89a : https://www.w3.org/Graphics/GIF/spec-gif89a.txt
enum DISPOSAL_METHOD |
void Test_GIF | ( | T_IO_Context * | context, |
FILE * | file | ||
) |
Test if a file is GIF format.
checks if the signature (6 first bytes) is either GIF87a or GIF89a
References File_error, and Read_bytes().
|
static |
Reads the next code (GIF.nb_bits bits)
References T_GIF_context::current_code, File_error, GFX2_ERROR, GFX2_Log(), GFX2_WARNING, T_GIF_context::last_byte, T_GIF_context::nb_bits, Read_byte(), T_GIF_context::remainder_bits, and T_GIF_context::remainder_byte.
Referenced by Load_GIF().
|
static |
Put a new pixel.
References T_GIF_IDB::Image_height, T_GIF_IDB::Image_width, T_GIF_context::interlaced, T_GIF_context::pass, T_GIF_IDB::Pos_X, T_GIF_context::pos_X, T_GIF_IDB::Pos_Y, T_GIF_context::pos_Y, Set_pixel(), T_GIF_context::stop, and T_IO_Context::Transparent_color.
Referenced by Load_GIF().
void Load_GIF | ( | T_IO_Context * | context | ) |
Load GIF file.
References T_GIF_LSDB::Aspect, T_GIF_LSDB::Backcol, T_IO_Context::Background_transparent, T_Document::backups, T_Config::Clear_palette, T_IO_Context::Color_cycles, T_IO_Context::Comment, COMMENT_SIZE, Config, Constraint_mode_from_label(), CONTEXT_BRUSH, CONTEXT_MAIN_IMAGE, CONTEXT_PREVIEW, T_GIF_context::current_code, T_Document::current_layer, T_IO_Context::Cycle_range, T_GIF_GCE::Delay_time, DISPOSAL_METHOD_RESTORE_BGCOLOR, T_Color_cycle::End, File_error, File_length_file(), Fill_canvas(), flags, FORMAT_GIF, GFX2_DEBUG, GFX2_ERROR, GFX2_INFO, GFX2_Log(), GFX2_malloc, GIF_get_next_code(), GIF_new_pixel(), T_GIF_LSDB::Height, T_Page::Height, T_Page::Image, T_GIF_IDB::Image_height, T_Page::Image_mode, IMAGE_MODE_ANIMATION, T_GIF_IDB::Image_width, T_GIF_IDB::Indicator, T_GIF_context::interlaced, T_Color_cycle::Inverse, label, T_GIF_context::last_byte, Main, MAX, MIN, T_GIF_context::nb_bits, NULL, Open_file_read(), T_IO_Context::Original_file_directory, T_IO_Context::Original_file_name, Original_screen_X, Original_screen_Y, T_GIF_GCE::Packed_fields, T_List_of_pages::Pages, T_IO_Context::Palette, T_GIF_context::pass, PIXEL_SIMPLE, PIXEL_TALL, PIXEL_TALL3, PIXEL_WIDE, T_Image::Pixels, T_GIF_IDB::Pos_X, T_GIF_context::pos_X, T_GIF_IDB::Pos_Y, T_GIF_context::pos_Y, Pre_load(), Read_byte(), Read_bytes(), Read_word_be(), Read_word_le(), T_GIF_context::remainder_bits, T_GIF_context::remainder_byte, T_GIF_LSDB::Resol, Set_frame_duration(), Set_image_mode(), Set_loading_layer(), T_Color_cycle::Speed, T_Color_cycle::Start, T_GIF_context::stop, T_GIF_GCE::Transparent_color, T_IO_Context::Transparent_color, T_IO_Context::Type, T_GIF_LSDB::Width, and T_Page::Width.
Referenced by Test_Save().
|
static |
Flush the buffer.
References File_error, T_GIF_context::remainder_byte, and Write_bytes().
Referenced by GIF_set_code(), and Save_GIF().
|
static |
Write a code (GIF_nb_bits bits)
References GIF_empty_buffer(), T_GIF_context::last_byte, T_GIF_context::nb_bits, T_GIF_context::remainder_bits, and T_GIF_context::remainder_byte.
Referenced by Save_GIF().
|
static |
Read the next pixel.
References Get_pixel(), T_GIF_IDB::Image_height, T_GIF_IDB::Image_width, T_GIF_IDB::Pos_X, T_GIF_context::pos_X, T_GIF_IDB::Pos_Y, T_GIF_context::pos_Y, and T_GIF_context::stop.
Referenced by Save_GIF().
void Save_GIF | ( | T_IO_Context * | context | ) |
Save a GIF file.
0x21 Extension Label 0xFF Application Extension Label 0x0B Block Size "NETSCAPE" Application Identifier (8 bytes) "2.0" Application Authentication Code (3 bytes) 0x03 Sub-block Data Size 0xLL 01 to loop 0xSSSS (little endian) number of loops, 0 means infinite loop 0x00 Block terminatorsee http://www.vurdalakov.net/misc/gif/netscape-looping-application-extension
0x21 Extension Label 0xFF Application Extension Label 0x0B Block Size "GFX2MODE" Application Identifier (8 bytes) "2.6" Application Authentication Code (3 bytes) 0xll Sub-block Data Size string label 0x00 Block terminator
0x21 Extension Label 0xFF Application Extension Label 0x0B Block Size "CRNG\0\0\0\0" "CRNG" Application Identifier (8 bytes) "1.0" Application Authentication Code (3 bytes) 0xll Sub-block Data Size (6 bytes per color cycle) For each color cycle : 0xRRRR (big endian) Rate 0xFFFF (big endian) Flags 0xSS start (lower color index) 0xEE end (higher color index) 0x00 Block terminator
0x21 Extension Label 0xFF Application Extension Label 0x0B Block Size "GFX2PATH" "GFX2PATH" Application Identifier (8 bytes) "\0\0\0" Application Authentication Code (3 bytes) 0xll Sub-block Data Size : path size (including null) "..path.." path (null-terminated) 0xll Sub-block Data Size : filename size (including null) "..file.." file name (null-terminated) 0x00 Block terminator
References T_GIF_LSDB::Aspect, T_GIF_LSDB::Backcol, T_IO_Context::Background_transparent, T_Document::backups, T_GIF_GCE::Block_identifier, T_GIF_GCE::Block_size, T_GIF_GCE::Block_terminator, T_IO_Context::Color_cycles, T_IO_Context::Comment, Config, Constraint_mode_label(), CONTEXT_MAIN_IMAGE, T_IO_Context::Cycle_range, gif_alphabet::daughter, T_GIF_GCE::Delay_time, DISPOSAL_METHOD_DO_NOT_DISPOSE, DISPOSAL_METHOD_RESTORE_BGCOLOR, T_Color_cycle::End, File_error, flags, gif_alphabet::free, T_GIF_GCE::Function, Get_frame_duration(), Get_pixel(), GFX2_DEBUG, GFX2_Log(), GFX2_malloc, GIF_empty_buffer(), GIF_INVALID_CODE, GIF_next_pixel(), GIF_set_code(), T_GIF_LSDB::Height, T_IO_Context::Height, T_GIF_IDB::Image_height, T_Page::Image_mode, IMAGE_MODE_ANIMATION, T_GIF_IDB::Image_width, T_GIF_IDB::Indicator, T_Color_cycle::Inverse, label, T_GIF_context::last_byte, Main, gif_alphabet::max, T_GIF_context::nb_bits, T_GIF_IDB::Nb_bits_pixel, T_IO_Context::Nb_layers, NULL, Open_file_write(), T_IO_Context::Original_file_directory, T_IO_Context::Original_file_name, T_GIF_GCE::Packed_fields, T_List_of_pages::Pages, T_IO_Context::Palette, PIXEL_TALL, PIXEL_TALL2, PIXEL_TALL3, PIXEL_WIDE, PIXEL_WIDE2, T_GIF_IDB::Pos_X, T_GIF_context::pos_X, T_GIF_IDB::Pos_Y, T_GIF_context::pos_Y, gif_alphabet::prefix, T_IO_Context::Ratio, T_GIF_context::remainder_bits, T_GIF_context::remainder_byte, Remove_file(), T_GIF_LSDB::Resol, Screen_height, T_Config::Screen_size_in_GIF, Screen_width, Set_saving_layer(), gif_alphabet::sister, T_Color_cycle::Speed, T_Color_cycle::Start, T_GIF_context::stop, gif_alphabet::suffix, T_GIF_GCE::Transparent_color, T_IO_Context::Transparent_color, T_IO_Context::Type, T_GIF_LSDB::Width, T_IO_Context::Width, Write_byte(), Write_bytes(), Write_word_be(), and Write_word_le().