GrafX2 2.9.3227
The ultimate 256-color painting program
Test, Load and Save functions

The Test, Load and Save function for each supported file formats are referenced in File_formats. More...

+ Collaboration diagram for Test, Load and Save functions:

Modules

 Amstrad CPC/CPC+ picture formats
 Support for Amstrad CPC/CPC+ picture formats.
 
 Bitmap and icon files
 .BMP/.ICO/.CUR files from OS/2 or Windows
 
 SCx format
 ColoRix VGA Paint SCx File Format.
 
 GIF format
 Graphics Interchange Format.
 
 Interchange File Format
 Interchange File Format (Electronic Arts)
 
 MSX picture formats
 MODE2 : 256x192 Support for the MSX pictures.
 
 PNG format
 Portable Network Graphics.
 
 Atari ST picture formats
 Support for Atari ST picture formats.
 
 TIFF
 Tagged Image File Format.
 

Functions

void Test_PKM (T_IO_Context *, FILE *)
 
void Load_PKM (T_IO_Context *)
 
void Save_PKM (T_IO_Context *)
 
void Test_LBM (T_IO_Context *, FILE *)
 
void Test_PBM (T_IO_Context *, FILE *)
 
void Test_ACBM (T_IO_Context *, FILE *)
 
void Load_IFF (T_IO_Context *)
 Load IFF picture (PBM/ILBM/ACBM) or animation. More...
 
void Save_IFF (T_IO_Context *)
 Save IFF file (LBM or PBM) More...
 
void Test_GIF (T_IO_Context *, FILE *)
 Test if a file is GIF format. More...
 
void Load_GIF (T_IO_Context *)
 Load GIF file. More...
 
void Save_GIF (T_IO_Context *)
 Save a GIF file. More...
 
void Test_PCX (T_IO_Context *, FILE *)
 
void Load_PCX (T_IO_Context *)
 
void Save_PCX (T_IO_Context *)
 
void Test_BMP (T_IO_Context *, FILE *)
 Test for BMP format. More...
 
void Load_BMP (T_IO_Context *)
 Load BMP file. More...
 
void Save_BMP (T_IO_Context *)
 Save BMP file. More...
 
void Test_IMG (T_IO_Context *, FILE *)
 
void Load_IMG (T_IO_Context *)
 
void Save_IMG (T_IO_Context *)
 
void Test_SCx (T_IO_Context *, FILE *)
 Test if a file is SCx format. More...
 
void Load_SCx (T_IO_Context *)
 Read a SCx file. More...
 
void Save_SCx (T_IO_Context *)
 Save a SCx file. More...
 
void Test_CEL (T_IO_Context *, FILE *)
 
void Load_CEL (T_IO_Context *)
 
void Save_CEL (T_IO_Context *)
 
void Test_KCF (T_IO_Context *, FILE *)
 
void Load_KCF (T_IO_Context *)
 
void Save_KCF (T_IO_Context *)
 
void Test_PAL (T_IO_Context *, FILE *)
 
void Load_PAL (T_IO_Context *)
 
void Save_PAL (T_IO_Context *)
 
void Test_GPL (T_IO_Context *, FILE *)
 Test for GPL (Gimp Palette) file format. More...
 
void Load_GPL (T_IO_Context *)
 Load GPL (Gimp Palette) file format. More...
 
void Save_GPL (T_IO_Context *)
 Save GPL (Gimp Palette) file format. More...
 
void Test_PI1 (T_IO_Context *, FILE *)
 Test for Degas file format. More...
 
void Load_PI1 (T_IO_Context *)
 Load Degas file format. More...
 
void Save_PI1 (T_IO_Context *)
 Save a PI1 Degas uncompressed picture. More...
 
void Test_PC1 (T_IO_Context *, FILE *)
 Test for Degas Elite Compressed format. More...
 
void Load_PC1 (T_IO_Context *)
 Load Degas Elite compressed files. More...
 
void Save_PC1 (T_IO_Context *)
 Save a Degas Elite compressed picture. More...
 
void Test_CA1 (T_IO_Context *, FILE *)
 test for CrackArt format. More...
 
void Load_CA1 (T_IO_Context *)
 
void Save_CA1 (T_IO_Context *)
 Save a 320x200 16c picture in CrackArt format. More...
 
void Test_TNY (T_IO_Context *, FILE *)
 
void Load_TNY (T_IO_Context *)
 
void Save_TNY (T_IO_Context *)
 Save in Tiny compressed format. More...
 
void Test_NEO (T_IO_Context *, FILE *)
 NeoChrome Format : More...
 
void Load_NEO (T_IO_Context *)
 Load Neochrome file format. More...
 
void Save_NEO (T_IO_Context *)
 Save in NeoChrome format. More...
 
void Test_C64 (T_IO_Context *, FILE *)
 Test for a C64 picture file. More...
 
void Load_C64 (T_IO_Context *)
 Load C64 pictures formats. More...
 
void Save_C64 (T_IO_Context *)
 Save C64 picture. More...
 
void Test_PRG (T_IO_Context *, FILE *)
 Test for a C64 auto-load machine language program which could be a picture. More...
 
void Load_PRG (T_IO_Context *)
 Load C64 autoload pictures. More...
 
void Save_PRG (T_IO_Context *)
 Save autoloading C64 picture. More...
 
void Test_GPX (T_IO_Context *, FILE *)
 
void Load_GPX (T_IO_Context *)
 
void Test_SCR (T_IO_Context *, FILE *)
 Test for SCR file (Amstrad CPC) More...
 
void Load_SCR (T_IO_Context *)
 Load Advanced OCP Art Studio files (Amstrad CPC) More...
 
void Save_SCR (T_IO_Context *)
 Save Amstrad SCR file. More...
 
void Test_CM5 (T_IO_Context *, FILE *)
 Test for CM5 - Amstrad CPC "Mode 5" picture. More...
 
void Load_CM5 (T_IO_Context *)
 Load Amstrad CPC "Mode 5" picture. More...
 
void Save_CM5 (T_IO_Context *)
 Save a CPC Mode 5 picture. More...
 
void Test_PPH (T_IO_Context *, FILE *)
 Amstrad CPC 'PPH' for Perfect Pix. More...
 
void Load_PPH (T_IO_Context *)
 
void Save_PPH (T_IO_Context *)
 Not yet implemented. More...
 
void Test_GOS (T_IO_Context *, FILE *)
 Test for GO1/GO2/KIT - Amstrad Plus Graphos. More...
 
void Load_GOS (T_IO_Context *)
 Load GO1/GO2/KIT - Amstrad CPC Plus Graphos. More...
 
void Save_GOS (T_IO_Context *)
 
void Test_SGX (T_IO_Context *, FILE *)
 Test for SGX file (SymbOS) More...
 
void Load_SGX (T_IO_Context *)
 
void Save_SGX (T_IO_Context *)
 
void Save_XPM (T_IO_Context *)
 
void Test_ICO (T_IO_Context *, FILE *)
 
void Load_ICO (T_IO_Context *)
 
void Save_ICO (T_IO_Context *)
 
void Test_PNG (T_IO_Context *, FILE *)
 Test for PNG format. More...
 
void Load_PNG (T_IO_Context *)
 Read PNG format files. More...
 
void Save_PNG (T_IO_Context *)
 Save a PNG file. 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 Save_PNG_Sub (T_IO_Context *context, FILE *file, char **buffer, unsigned long *buffer_size)
 Save a PNG to file or memory. More...
 
void Test_INFO (T_IO_Context *, FILE *)
 
void Load_INFO (T_IO_Context *)
 
void Test_FLI (T_IO_Context *, FILE *)
 Test for the Autodesk Animator FLI/FLC format. More...
 
void Load_FLI (T_IO_Context *)
 Load file in the Autodesk Animator FLI/FLC format. More...
 
void Test_MOTO (T_IO_Context *, FILE *)
 Test for Thomson file. More...
 
void Load_MOTO (T_IO_Context *)
 Load a picture for Thomson TO8/TO8D/TO9/TO9+/MO6. More...
 
void Save_MOTO (T_IO_Context *)
 Save a picture in MAP or BIN Thomson MO/TO file format. More...
 
void Test_HGR (T_IO_Context *, FILE *)
 Test for an Apple II HGR or DHGR raw file. More...
 
void Load_HGR (T_IO_Context *)
 Load HGR (280x192) or DHGR (560x192) Apple II pictures. More...
 
void Save_HGR (T_IO_Context *)
 Save HGR (280x192) or DHGR (560x192) Apple II pictures. More...
 
void Test_TIFF (T_IO_Context *, FILE *)
 test for a valid TIFF More...
 
void Load_TIFF (T_IO_Context *)
 Load TIFF from file. More...
 
void Save_TIFF (T_IO_Context *)
 Save TIFF. More...
 
void Load_TIFF_from_memory (T_IO_Context *, const void *, unsigned long)
 Load TIFF from memory. More...
 
void Save_TIFF_to_memory (T_IO_Context *, void **, unsigned long *)
 Save TIFF to memory. More...
 
void Test_GRB (T_IO_Context *, FILE *)
 Test for a HP-48 Grob file. More...
 
void Load_GRB (T_IO_Context *)
 
void Test_MSX (T_IO_Context *, FILE *)
 
void Load_MSX (T_IO_Context *)
 Load a MSX Screen 2 picture. More...
 
void Save_MSX (T_IO_Context *)
 Save MSX .SC2 file. More...
 
void Test_2GS (T_IO_Context *, FILE *)
 Test for an Apple 2 GS picture file. More...
 
void Load_2GS (T_IO_Context *)
 
void Save_2GS (T_IO_Context *)
 

Detailed Description

The Test, Load and Save function for each supported file formats are referenced in File_formats.

Function Documentation

◆ Test_PKM()

◆ Load_PKM()

◆ Save_PKM()

◆ Test_LBM()

void Test_LBM ( T_IO_Context context,
FILE *  f 
)

References Test_IFF().

◆ Test_PBM()

void Test_PBM ( T_IO_Context context,
FILE *  f 
)

References Test_IFF().

◆ Test_ACBM()

void Test_ACBM ( T_IO_Context context,
FILE *  f 
)

References Test_IFF().

◆ Load_IFF()

void Load_IFF ( T_IO_Context context)

Load IFF picture (PBM/ILBM/ACBM) or animation.

Todo:
DRNG IFF chunk is read, but complex color cycling are not implemented.

References T_IFF_AnimHeader::abstime, T_Components::B, T_IO_Context::Background_transparent, T_IFF_Header::BitPlanes, T_IFF_AnimHeader::bits, T_Config::Clear_palette, T_IO_Context::Color_cycles, COLOR_CYCLING_SPEED_MAX, T_IO_Context::Comment, COMMENT_SIZE, T_IFF_Header::Compression, Config, CONTEXT_PALETTE, CONTEXT_PREVIEW, CONTEXT_PREVIEW_PALETTE, T_IO_Context::Cycle_range, Draw_IFF_line(), Draw_IFF_line_HAM(), T_Color_cycle::End, File_error, File_length_file(), flags, format, FORMAT_ACBM, FORMAT_LBM, FORMAT_PBM, T_Components::G, GFX2_DEBUG, GFX2_ERROR, GFX2_INFO, GFX2_Log(), GFX2_LogHexDump(), GFX2_malloc, GFX2_WARNING, T_IFF_AnimHeader::h, T_IFF_Header::Height, T_IO_Context::Height, IFF_Set_EHB_Palette(), IMAGE_MODE_ANIMATION, T_IFF_AnimHeader::interleave, T_Color_cycle::Inverse, LBM_Decode(), T_IFF_Header::Mask, T_IFF_AnimHeader::mask, T_IFF_PCHG_Palette::Next, NULL, Open_file_read(), T_IFF_AnimHeader::operation, T_IO_Context::Original_height, Original_screen_X, Original_screen_Y, T_IO_Context::Original_width, T_IFF_AnimHeader::pad0, T_IFF_Header::Pad1, T_IFF_PCHG_Palette::Palette, T_IO_Context::Palette, PBM_Decode(), T_IO_Context::Pitch, PIXEL_SIMPLE, PIXEL_TALL, PIXEL_TALL3, PIXEL_WIDE, Pre_load(), T_Components::R, RAST_chunk_decode(), Read_byte(), Read_bytes(), Read_dword_be(), Read_word_be(), T_IFF_AnimHeader::reltime, Set_frame_duration(), Set_IFF_color(), Set_image_mode(), Set_loading_layer(), T_Color_cycle::Speed, T_Color_cycle::Start, T_IFF_PCHG_Palette::StartLine, SWAP_BYTES, T_IO_Context::Target_address, T_IFF_Header::Transp_col, T_IO_Context::Transparent_color, T_IO_Context::Type, T_IFF_AnimHeader::w, T_IFF_Header::Width, T_IO_Context::Width, T_IFF_AnimHeader::x, T_IFF_Header::X_aspect, T_IFF_Header::X_org, T_IFF_Header::X_screen, T_IFF_AnimHeader::y, T_IFF_Header::Y_aspect, T_IFF_Header::Y_org, and T_IFF_Header::Y_screen.

◆ Save_IFF()

◆ Test_GIF()

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().

◆ 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().

◆ Save_GIF()

void Save_GIF ( T_IO_Context context)

Save a GIF file.

  • "Netscape" animation extension :
      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 terminator 
    see http://www.vurdalakov.net/misc/gif/netscape-looping-application-extension
  • GrafX2 extension to store IMAGE_MODES :
      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 
    See also
    Constraint_mode_label()
  • "CRNG" Color cycing extension :
      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 
  • If requested, write a specific extension for storing original file path. This is used by the backup system. The format is :
      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().

◆ Test_PCX()

◆ Load_PCX()

◆ Save_PCX()

◆ Test_BMP()

◆ Load_BMP()

◆ Save_BMP()

◆ Test_IMG()

◆ Load_IMG()

◆ Save_IMG()

◆ Test_SCx()

◆ Load_SCx()

◆ Save_SCx()

◆ Test_CEL()

◆ Load_CEL()

◆ Save_CEL()

◆ Test_KCF()

◆ Load_KCF()

◆ Save_KCF()

◆ Test_PAL()

void Test_PAL ( T_IO_Context context,
FILE *  file 
)

◆ Load_PAL()

◆ Save_PAL()

void Save_PAL ( T_IO_Context context)

◆ Test_GPL()

void Test_GPL ( T_IO_Context context,
FILE *  file 
)

Test for GPL (Gimp Palette) file format.

References File_error, File_length_file(), and Read_bytes().

◆ Load_GPL()

void Load_GPL ( T_IO_Context context)

Load GPL (Gimp Palette) file format.

Todo:
set grafx2 columns setting to match.
Todo:
analyze color names to build shade table

References T_IO_Context::Comment, File_error, GFX2_DEBUG, GFX2_Log(), NULL, Open_file_read(), T_IO_Context::Palette, Read_byte_line(), and skip_padding().

◆ Save_GPL()

void Save_GPL ( T_IO_Context context)

Save GPL (Gimp Palette) file format.

References File_error, T_IO_Context::File_name, NULL, Open_file_write(), T_IO_Context::Palette, and Remove_file().

◆ Test_PI1()

void Test_PI1 ( T_IO_Context context,
FILE *  file 
)

Test for Degas file format.

References File_error, File_length_file(), and Read_word_be().

◆ Load_PI1()

◆ Save_PI1()

void Save_PI1 ( T_IO_Context context)

◆ Test_PC1()

void Test_PC1 ( T_IO_Context context,
FILE *  file 
)

Test for Degas Elite Compressed format.

References File_error, File_length_file(), and Read_word_be().

◆ Load_PC1()

◆ Save_PC1()

void Save_PC1 ( T_IO_Context context)

◆ Test_CA1()

void Test_CA1 ( T_IO_Context context,
FILE *  file 
)

test for CrackArt format.

Test that the files starts with the "CA" signature, then 1 byte for the compressed flag (0 or 1), then 1 byte for the resolution (0=low, 1=med, 2=high)

References File_error, and Read_bytes().

◆ Load_CA1()

◆ Save_CA1()

void Save_CA1 ( T_IO_Context context)

◆ Test_TNY()

void Test_TNY ( T_IO_Context context,
FILE *  file 
)

◆ Load_TNY()

◆ Save_TNY()

void Save_TNY ( T_IO_Context context)

Save in Tiny compressed format.

Todo:
support medium and high resolution

fill the buffer with the special Tiny Stuff organization

See also
Load_TNY

References File_error, NULL, Open_file_write(), T_IO_Context::Palette, PI1_16p_to_8b(), PI1_code_palette(), T_IO_Context::Pitch, Remove_file(), T_IO_Context::Target_address, WORDS_EQU, Write_byte(), Write_bytes(), and Write_word_be().

◆ Test_NEO()

void Test_NEO ( T_IO_Context context,
FILE *  file 
)

NeoChrome Format :

1 word          flag word [always 0]
1 word          resolution [0 = low res, 1 = medium res, 2 = high res]
16 words        palette
12 bytes        filename [usually "        .   "]
1 word          color animation limits.  High bit (bit 15) set if color
                animation data is valid.  Low byte contains color animation
                limits (4 most significant bits are left/lower limit,
                4 least significant bits are right/upper limit).
1 word          color animation speed and direction.  High bit (bit 15) set
                if animation is on.  Low order byte is # vblanks per step.
                If negative, scroll is left (decreasing).  Number of vblanks
                between cycles is |x| - 1
1 word          # of color steps (as defined in previous word) to display
                picture before going to the next.  (For use in slide shows)
1 word          image X offset [unused, always 0]
1 word          image Y offset [unused, always 0]
1 word          image width [unused, always 320]
1 word          image height [unused, always 200]
33 words        reserved for future expansion
32000 bytes     pixel data

Dali *.SD0 (ST low resolution) .SD1 (ST medium resolution) .SD2 (ST high resolution)

Files do not seem to have any resolution or bit plane info stored in them. The file extension seems to be the only way to determine the contents.

1 long file id? [always 0] 16 words palette 92 bytes reserved? [usually 0]

References File_error, File_length_file(), and Read_word_be().

◆ Load_NEO()

◆ Save_NEO()

◆ Test_C64()

◆ Load_C64()

◆ Save_C64()

◆ Test_PRG()

void Test_PRG ( T_IO_Context context,
FILE *  file 
)

Test for a C64 auto-load machine language program which could be a picture.

References C64_isBinaryProgram(), File_error, File_length_file(), and Read_word_le().

◆ Load_PRG()

◆ Save_PRG()

◆ Test_GPX()

void Test_GPX ( T_IO_Context context,
FILE *  file 
)

References File_error, and Read_bytes().

◆ Load_GPX()

◆ Test_SCR()

void Test_SCR ( T_IO_Context context,
FILE *  file 
)

Test for SCR file (Amstrad CPC)

SCR file format is originally from "Advanced OCP Art Studio" : http://www.cpcwiki.eu/index.php/Format:Advanced_OCP_Art_Studio_File_Formats

.WIN "window" format is also supported.

SCR files are normally just a dump of the 16K of video memory. So they are essentially 16 kilobytes of pixel data without any header. To make things more fun, there is an optional compression. This all makes detection a bit fuzzy. However there are various things we can still check:

  • Presence of a valid PAL file. If the PAL file is not there the pixel data may still be valid. The PAL file size depends on the screen mode (number of colors).
  • An AMSDOS header is a good indication but in some cases it may not be there.
  • Some tools embed the palette and mode (and usually some kind of loader code) in the SCR file, we can also detect these.
Todo:
the palette data can be hidden in the 48 "empty" bytes every 2048 bytes of a standard resolution SCR file. So we should detect the hidden Z80 code and load them. Load address of file is C000. Z80 code :
C7D0: 3a d0 d7 cd 1c bd 21 d1 d7 46 48 cd 38 bc af 21 | :.....!..FH.8..!
C7E0: d1 d7 46 48 f5 e5 cd 32 bc e1 f1 23 3c fe 10 20 | ..FH...2...#<..
C7F0: f1 c3 18 bb 00 00 00 00 00 00 00 00 00 00 00 00 | ................
mode and palette :
D7D0: 00 1a 00 0c 03 0b 01 0d 17 10 02 0f 09 19 06 00 | ................
https://gitlab.com/GrafX2/grafX2/merge_requests/121#note_119964168

References sgx_data::context, CPC_check_AMSDOS(), sgx_data::file, File_error, File_length_file(), sgx_data::file_size, GFX2_DEBUG, GFX2_Log(), GFX2_LogHexDump(), mode, NULL, Open_file_read_with_alternate_ext(), Read_byte(), and Read_bytes().

◆ Load_SCR()

void Load_SCR ( T_IO_Context context)

◆ Save_SCR()

void Save_SCR ( T_IO_Context context)

Save Amstrad SCR file.

guess mode from aspect ratio :

  • normal pixels are mode 1
  • wide pixels are mode 0
  • tall pixels are mode 2

Mode and palette are stored in a .PAL file for compatibility with OCP Art studio.

The picture color index should be 0-15, The CPC Hardware palette is expected to be set (indexes 64 to 95)

If the picture is using overscan (more than 16384 bytes) we produce a iMPdraw v2 format autoloading file. see http://orgams.wikidot.com/le-format-impdraw-v2

If the picture is not using overscan (standard resolutions, < 16384 screen buffer) a BASIC loader is saved.

Todo:

Add possibility to set R9 value

Add OCP packing support

References sgx_data::context, CPC_compare_colors(), CPC_is_CPC_old_color(), cpc_scr_simple_loader, CPC_set_HW_palette(), CPC_write_AMSDOS_header(), sgx_data::file, File_error, T_IO_Context::File_name, GFX2_DEBUG, GFX2_Log(), GFX2_WARNING, T_IO_Context::Height, impdraw_loader, NULL, Open_file_write(), Open_file_write_with_alternate_ext(), T_IO_Context::Palette, PIXEL_TALL, PIXEL_TALL2, PIXEL_TALL3, PIXEL_WIDE, PIXEL_WIDE2, T_IO_Context::Ratio, raw2crtc(), T_IO_Context::Width, Write_byte(), and Write_bytes().

◆ Test_CM5()

void Test_CM5 ( T_IO_Context context,
FILE *  file 
)

Test for CM5 - Amstrad CPC "Mode 5" picture.

This is a format designed by SyX. There is one .GFX file in the usual amstrad format and a .CM5 file with the palette, which varies over time.

CM5 file is 2049 bytes, GFX is 18432 bytes.

Todo:
check CM5 contains only valid values [0x40-0x5f]

References sgx_data::context, CPC_check_AMSDOS(), sgx_data::file, File_error, File_length_file(), sgx_data::file_size, NULL, and Open_file_read_with_alternate_ext().

◆ Load_CM5()

◆ Save_CM5()

void Save_CM5 ( T_IO_Context context)

Save a CPC Mode 5 picture.

Resolution is fixed to 288x256. The pictures uses 5 layers. 4 for defining the "inks" the 5th to select one of the 4 inks.

  • Layer 1 : 1 color Only
  • Layer 2 and 3 : 1 color/line
  • Layer 4 : 1 color / 48x1 block
  • Layer 5 : CPC mode 2 288x256 picture.

The .CM5 file contains the inks from layers 1-4, the .GFX file contains the pixel data in linear fashion

Todo:

Check picture has 5 layers

Check the constraints on the layers

See also
https://www.cpc-power.com/index.php?page=detail&num=12905

References sgx_data::context, sgx_data::file, File_error, Get_pixel(), Open_file_write(), Open_file_write_with_alternate_ext(), Set_saving_layer(), and Write_byte().

◆ Test_PPH()

void Test_PPH ( T_IO_Context context,
FILE *  file 
)

Amstrad CPC 'PPH' for Perfect Pix.

This is a format designed by Rhino. There are 3 modes:

  • Mode 'R': 1:1 pixels, 16 colors from the CPC 27 color palette. (this is implemented on CPC as two pictures with wide pixels, the "odd" one being shifted half a pixel to the right), and flipping)
  • Mode 'B0': wide pixels, up to 126 out of 378 colors. (this is implemented as two pictures with wide pixels, sharing the same 16 color palette, and flipping)
  • Mode 'B1': 1:1 pixels, 1 fixed color, up to 34 palettes of 9 colors (actually 4 colors + flipping)
  • The standard CPC formats can also be encapsulated into a PPH file.
See also
http://www.pouet.net/prod.php?which=67770#c766959

References sgx_data::context, sgx_data::file, File_error, File_length_file(), sgx_data::file_size, NULL, Open_file_read_with_alternate_ext(), and Read_bytes().

◆ Load_PPH()

◆ Save_PPH()

void Save_PPH ( T_IO_Context context)

Not yet implemented.

References sgx_data::context.

◆ Test_GOS()

void Test_GOS ( T_IO_Context context,
FILE *  file 
)

Test for GO1/GO2/KIT - Amstrad Plus Graphos.

This format is made of 3 files .KIT hold the palette in "Kit4096" format. There are 16 colors each stored as 12 bit RGB in RB0G order. .GO1 and GO2 hold each half of the picture (top and bottom) The file always cover the whole display of the Plus (192*272 mode 0 pixels) Only mode 0 is possible.

References sgx_data::context, CPC_check_AMSDOS(), sgx_data::file, File_error, File_length_file(), sgx_data::file_size, NULL, and Open_file_read_with_alternate_ext().

◆ Load_GOS()

◆ Save_GOS()

◆ Test_SGX()

void Test_SGX ( T_IO_Context context,
FILE *  file 
)

◆ Load_SGX()

◆ Save_SGX()

◆ Save_XPM()

◆ Test_ICO()

void Test_ICO ( T_IO_Context context,
FILE *  file 
)

References File_error, and Read_word_le().

◆ Load_ICO()

◆ Save_ICO()

◆ 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().

◆ 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().

◆ 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().

◆ Load_PNG_Sub()

◆ Save_PNG_Sub()

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

◆ Test_INFO()

void Test_INFO ( T_IO_Context context,
FILE *  file 
)

◆ Load_INFO()

◆ Test_FLI()

void Test_FLI ( T_IO_Context context,
FILE *  file 
)

Test for the Autodesk Animator FLI/FLC format.

Not to be confused with Commodore 64 FLI.

References File_error, Load_FLI_Header(), and T_FLIC_Header::type.

◆ Load_FLI()

◆ Test_MOTO()

void Test_MOTO ( T_IO_Context context,
FILE *  file 
)

◆ Load_MOTO()

void Load_MOTO ( T_IO_Context context)

Load a picture for Thomson TO8/TO8D/TO9/TO9+/MO6.

One of the supported format is the one produced by TGA2Teo :

  • Picture data is splitted into 2 files, one for each VRAM bank :
    • The first VRAM bank is called "forme" (shape). In 40col mode it stores pixels.
    • The second VRAM bank is called "couleur" (color). In 40col mode it store color indexes for foreground and background.
  • File extension is .BIN, character before extension is "P" for the first file, and "C" for the second.
  • The color palette is stored in both files after the data.

The mode is detected thanks to the number of color in the palette :

  • 2 colors is 80col (640x200)
  • 4 colors is bitmap4 (320x200 4 colors)
  • 16 colors is either bitmap16 (160x200 16colors) or 40col (320x200 16 colors with 2 unique colors in each 8x1 pixels block).

As it is not possible to disriminate bitmap16 and 40col, opening the "P" file sets bitmap16, opening the "C" file sets 40col.

This function also supports .MAP files (with optional TO-SNAP extension) and our own "autoloading" BIN files. See http://pulkomandy.tk/projects/GrafX2/wiki/Develop/FileFormats/MOTO for a detailled description.

References T_Config::Clear_palette, T_IO_Context::Comment, COMMENT_SIZE, Config, T_IO_Context::File_directory, File_error, File_length_file(), T_IO_Context::File_name, Filepath_append_to_dir(), FORMAT_MOTO, GFX2_DEBUG, GFX2_ERROR, GFX2_Log(), GFX2_malloc, IMAGE_MODE_THOMSON, mode, MOTO_Check_binary_file(), MOTO_gamma_correct_MOTO_to_RGB(), MOTO_MODE_40col, MOTO_MODE_80col, MOTO_MODE_bm16, MOTO_MODE_bm4, MOTO_set_MO5_palette(), MOTO_set_TO7_palette(), NULL, Open_file_read(), T_IO_Context::Palette, PIXEL_SIMPLE, PIXEL_TALL, PIXEL_WIDE, Pre_load(), Read_byte(), Read_bytes(), Read_word_be(), Set_image_mode(), and Set_pixel().

◆ Save_MOTO()

void Save_MOTO ( T_IO_Context context)

Save a picture in MAP or BIN Thomson MO/TO file format.

File format details : http://pulkomandy.tk/projects/GrafX2/wiki/Develop/FileFormats/MOTO

In the future we could support other resolution for .MAP format. And even in .BIN format, we could store less lines.

The 40col encoding algorithm is optimized for further vertical RLE packing. The "attibute" byte is kept as constant as possible between adjacent blocks.

For MO5 we use a different 40col algorithm to make sure the last pixel of a GPL and the first the next are both FORME or both FOND, else we get an ugly glitch on the EFGJ033 Gate Array MO5!

References T_IO_Context::Comment, DECB_BIN_Add_Chunk(), DECB_BIN_Add_End(), File_error, format, Get_pixel(), GFX2_DEBUG, GFX2_ERROR, GFX2_Log(), GFX2_malloc, T_IO_Context::Height, MACHINE_MO5, MACHINE_MO6, MACHINE_TO7, MACHINE_TO770, MACHINE_TO8, mode, MOTO_gamma_correct_RGB_to_MOTO(), MOTO_MAP_pack(), MOTO_MODE_40col, MOTO_MODE_80col, MOTO_MODE_bm16, MOTO_MODE_bm4, NULL, Open_file_write(), T_IO_Context::Palette, Program_version, Save_MOTO_window(), SVN_revision, Warning_message(), Warning_with_format(), and T_IO_Context::Width.

◆ Test_HGR()

void Test_HGR ( T_IO_Context context,
FILE *  file 
)

Test for an Apple II HGR or DHGR raw file.

References File_error, and File_length_file().

◆ Load_HGR()

void Load_HGR ( T_IO_Context context)

Load HGR (280x192) or DHGR (560x192) Apple II pictures.

Creates 2 layers :

  1. Monochrome
  2. Color

emulate "chat mauve" DHGR mixed mode. see http://boutillon.free.fr/Underground/Anim_Et_Graph/Extasie_Chat_Mauve_Reloaded/Extasie_Chat_Mauve_Reloaded.html

HGR emulation following the behaviour of a "Le Chat Mauve" RVB adapter for the Apple //c. Within the bit stream, the color of the middle pixel is :
111 \
110 }- white
011 /
010 \ _ color
101 /
000 \
001 }- black
100 /
Color depends on the selected palette for the current byte and the position of the pixel (odd or even).

References T_Config::Clear_palette, Config, CONTEXT_MAIN_IMAGE, DHGR_set_palette(), File_error, File_length_file(), FORMAT_HGR, GFX2_DEBUG, GFX2_LogHexDump(), GFX2_malloc, HGR_set_palette(), IMAGE_MODE_DHGR, IMAGE_MODE_HGR, NULL, Open_file_read(), T_IO_Context::Palette, PIXEL_SIMPLE, PIXEL_TALL, Pre_load(), Read_bytes(), Set_image_mode(), Set_loading_layer(), Set_pixel(), and T_IO_Context::Type.

◆ Save_HGR()

void Save_HGR ( T_IO_Context context)

Save HGR (280x192) or DHGR (560x192) Apple II pictures.

The data saved is the "monochrome" data from layer 1

References File_error, Get_pixel(), T_IO_Context::Height, NULL, Open_file_write(), Set_saving_layer(), Warning_message(), T_IO_Context::Width, and Write_bytes().

◆ Test_TIFF()

void Test_TIFF ( T_IO_Context context,
FILE *  file 
)

test for a valid TIFF

References File_error, and Read_bytes().

◆ Load_TIFF()

◆ Save_TIFF()

◆ Load_TIFF_from_memory()

void Load_TIFF_from_memory ( T_IO_Context context,
const void *  buffer,
unsigned long  size 
)

◆ Save_TIFF_to_memory()

void Save_TIFF_to_memory ( T_IO_Context context,
void **  buffer,
unsigned long *  size 
)

◆ Test_GRB()

void Test_GRB ( T_IO_Context context,
FILE *  file 
)

Test for a HP-48 Grob file.

References File_error, File_length_file(), GFX2_DEBUG, GFX2_Log(), Read_bytes(), and Read_HP48Address().

◆ Load_GRB()

◆ Test_MSX()

void Test_MSX ( T_IO_Context context,
FILE *  file 
)

◆ Load_MSX()

void Load_MSX ( T_IO_Context context)

Load a MSX Screen 2 picture.

TMS9918 Mode II VRAM layout :

  • 0000-17FF : Pattern table
  • 1800-1AFF : Name table
  • 1B00-1B7F : Sprite attributes
  • 1B80-1FFF : UNUSED (1B80-1BAF = Palette)
  • 2000-37FF : Color table
  • 3800-3FFF : Sprite patterns

References Check_MSX_BSAVE_format(), T_Config::Clear_palette, Config, File_error, File_length_file(), FORMAT_MSX, GFX2_DEBUG, GFX2_Log(), MSX_set_palette(), Open_file_read(), T_IO_Context::Palette, PIXEL_SIMPLE, Pre_load(), Read_bytes(), Set_loading_layer(), Set_pixel(), and T_IO_Context::Transparent_color.

◆ Save_MSX()

void Save_MSX ( T_IO_Context context)

Save MSX .SC2 file.

Uses the BSAVE/BLOAD file format. equivalent to BSAVE "FILE.SC2",&H0,&H37FF,S

The MSX pictures are 256x192 pixels with a 15 colors fixed palette. Color #0 is transparent.

See also
https://www.msx.org/wiki/BSAVE
https://lospec.com/palette-list/msx
Todo:
save sprites

References File_error, Get_pixel(), GFX2_Log(), GFX2_WARNING, NULL, Open_file_write(), Write_byte(), Write_bytes(), and Write_word_le().

◆ Test_2GS()

void Test_2GS ( T_IO_Context context,
FILE *  file 
)

Test for an Apple 2 GS picture file.

References File_error, File_length_file(), Read_bytes(), and Read_dword_le().

◆ Load_2GS()

◆ Save_2GS()