GrafX2 2.9.3227
The ultimate 256-color painting program
|
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <png.h>
#include "gfx2log.h"
#include "gfx2mem.h"
#include "buttons.h"
#include "const.h"
#include "errors.h"
#include "global.h"
#include "keycodes.h"
#include "io.h"
#include "loadsave.h"
#include "loadsavefuncs.h"
#include "misc.h"
#include "osdep.h"
#include "graph.h"
#include "op_c.h"
#include "pages.h"
#include "palette.h"
#include "screen.h"
#include "struct.h"
#include "windows.h"
#include "engine.h"
#include "brush.h"
#include "setup.h"
#include "filesel.h"
#include "unicode.h"
#include "fileformats.h"
#include "bitcount.h"
Data Structures | |
struct | T_String_list |
Functions | |
void | Load_Recoil_Image (T_IO_Context *) |
static void | Load_ClipBoard_Image (T_IO_Context *) |
static void | Save_ClipBoard_Image (T_IO_Context *) |
unsigned int | Nb_known_formats (void) |
Total number of known file formats. More... | |
void | Set_pixel (T_IO_Context *context, short x_pos, short y_pos, byte color) |
Set the color of a pixel (on load) More... | |
void | Fill_canvas (T_IO_Context *context, byte color) |
Fill the entire current layer/frame of an image being loaded with a color. More... | |
void | Set_pixel_24b (T_IO_Context *context, short x_pos, short y_pos, byte r, byte g, byte b) |
Chargement des pixels dans le buffer 24b. More... | |
void | Set_palette_fake_24b (T_Palette palette) |
void | Set_frame_duration (T_IO_Context *context, int duration) |
Function to call when loading an image's duration. More... | |
int | Get_frame_duration (T_IO_Context *context) |
Function to call to get an image's duration for saving. More... | |
void | Set_image_mode (T_IO_Context *context, enum IMAGE_MODES mode) |
Function to set a specific image mode. More... | |
enum IMAGE_MODES | Get_image_mode (T_IO_Context *context) |
get the current image mode More... | |
void | Pre_load (T_IO_Context *context, short width, short height, long file_size, int format, enum PIXEL_RATIO ratio, byte bpp) |
Generic allocation and similar stuff, done at beginning of image load, as soon as size is known. More... | |
void | Load_image (T_IO_Context *context) |
High-level picture loading function. More... | |
void | Save_image (T_IO_Context *context) |
High-level picture saving function. More... | |
T_GFX2_Surface * | Load_surface (const char *filename, const char *directory, T_Gradient_array *gradients) |
Load an arbitrary Surface. More... | |
void | Emergency_backup (const char *fname, byte *source, int width, int height, T_Palette *palette) |
Saves an image. More... | |
void | Image_emergency_backup () |
Function which attempts to save backups of the images (main and spare), called in case of SIGSEGV. More... | |
const T_Format * | Get_fileformat (byte format) |
byte | Get_pixel (T_IO_Context *context, short x, short y) |
Query the color of a pixel (to save) More... | |
void | Destroy_context (T_IO_Context *context) |
Cleans up resources. More... | |
void | Init_context_preview (T_IO_Context *context, const char *file_name, const char *file_directory) |
Setup for loading a preview in fileselector. More... | |
void | Init_context_backup_image (T_IO_Context *context, const char *file_name, const char *file_directory) |
void | Init_context_layered_image (T_IO_Context *context, const char *file_name, const char *file_directory) |
Setup for loading/saving the current main image. More... | |
void | Init_context_brush (T_IO_Context *context, const char *file_name, const char *file_directory) |
Setup for loading/saving the flattened version of current main image. More... | |
void | Init_context_surface (T_IO_Context *context, const char *file_name, const char *file_directory) |
void | Set_saving_layer (T_IO_Context *context, int layer) |
Function to call when need to switch layers. More... | |
void | Set_loading_layer (T_IO_Context *context, int layer) |
Function to call when need to switch layers. More... | |
static void | Add_backup_file (const char *full_name, const char *file_name) |
Adds a file to Backups_main or Backups_spare lists, if it's a backup. More... | |
int | String_compare (const void *a, const void *b) |
String comparer for sorting. More... | |
byte | Process_backups (T_String_list **list) |
Reload safety backups, by loading several files in the right order. More... | |
int | Check_recovery (void) |
Checks if there are any pending safety backups, and then opens them. More... | |
void | Rotate_safety_backups (void) |
Makes a safety backup periodically. More... | |
void | Delete_safety_backups (void) |
Remove safety backups. Need to call on normal program exit. More... | |
Variables | |
const T_Format | File_formats [] |
Array of the known file formats. More... | |
T_String_list * | Backups_main = NULL |
A list of files, used for scanning a directory. More... | |
T_String_list * | Backups_spare = NULL |
A list of files, used for scanning a directory. More... | |
const int | Rotation_safety_backup = 8 |
const int | Min_interval_for_safety_backup = 30000 |
const int | Min_edits_for_safety_backup = 10 |
const int | Max_interval_for_safety_backup = 60000 |
const int | Max_edits_for_safety_backup = 30 |
byte | Safety_backup_active = 0 |
Global indicator that tells if the safety backup system is active. More... | |
void Load_Recoil_Image | ( | T_IO_Context * | context | ) |
References T_Config::Clear_palette, T_IO_Context::Comment, COMMENT_SIZE, Config, File_error, File_length_file(), T_IO_Context::File_name, T_IO_Context::File_name_unicode, FORMAT_MISC, GFX2_Log(), GFX2_malloc, GFX2_WARNING, NULL, Open_file_read(), T_IO_Context::Palette, PIXEL_SIMPLE, PIXEL_TALL, PIXEL_WIDE, Pre_load(), Read_bytes(), RECOIL_ReadFile(), Set_pixel(), Set_pixel_24b(), and Unicode_strlen().
Referenced by Load_image().
|
static |
References count_set_bits(), count_trailing_zeros(), DEFAULT_FILEFORMAT, Extract_filename(), Extract_path(), T_IO_Context::File_directory, File_error, File_exists(), T_IO_Context::File_name, T_IO_Context::Format, format, FORMAT_CLIPBOARD, Get_input(), get_tiff_paste_board(), GFX2_DEBUG, GFX2_ERROR, GFX2_Get_Window_Handle(), GFX2_INFO, GFX2_Log(), GFX2_malloc, GFX2_WARNING, Load_PNG_Sub(), Load_TIFF_from_memory(), NULL, T_IO_Context::Palette, PIXEL_SIMPLE, Pre_load(), Set_pixel(), Set_pixel_24b(), X11_display, and X11_window.
Referenced by Load_image().
|
static |
References File_error, Get_pixel(), GFX2_ERROR, GFX2_Get_Window_Handle(), GFX2_Log(), GFX2_WARNING, T_IO_Context::Height, NULL, T_IO_Context::Palette, Save_PNG_Sub(), Save_TIFF_to_memory(), set_tiff_paste_board(), T_IO_Context::Width, X11_display, and X11_window.
Referenced by Save_image().
unsigned int Nb_known_formats | ( | void | ) |
Total number of known file formats.
References File_formats.
Referenced by Button_Load_or_Save(), Get_fileformat(), and Load_image().
void Set_pixel | ( | T_IO_Context * | context, |
short | x_pos, | ||
short | y_pos, | ||
byte | color | ||
) |
Set the color of a pixel (on load)
References T_IO_Context::Buffer_image, CONTEXT_BRUSH, CONTEXT_MAIN_IMAGE, CONTEXT_PALETTE, CONTEXT_PREVIEW, CONTEXT_PREVIEW_PALETTE, CONTEXT_SURFACE, T_IO_Context::Current_layer, T_IO_Context::Height, Menu_factor_X, T_IO_Context::Pitch, Pixel_in_current_screen, Pixel_ratio, PIXEL_TALL, PIXEL_TALL2, PIXEL_TALL3, PIXEL_WIDE, PIXEL_WIDE2, T_IO_Context::Preview_bitmap, T_IO_Context::Preview_factor_X, T_IO_Context::Preview_factor_Y, T_IO_Context::Preview_usage, PREVIEW_WIDTH, T_IO_Context::Ratio, Set_GFX2_Surface_pixel(), T_IO_Context::Surface, T_IO_Context::Transparent_color, T_IO_Context::Type, and T_IO_Context::Width.
Referenced by Draw_IFF_line(), Draw_PCX_line(), GIF_new_pixel(), Load_BMP_Pixels(), Load_C64_fli(), Load_C64_hires(), Load_C64_multi(), Load_CA1(), Load_CEL(), Load_ClipBoard_Image(), Load_CM5(), Load_FLI(), Load_GOS(), Load_GRB(), Load_HGR(), Load_IMG(), Load_INFO(), Load_MOTO(), Load_MSX(), Load_NEO(), Load_PC1(), Load_PCX(), Load_PI1(), Load_PKM(), Load_PNG_Sub(), Load_PPH(), Load_Recoil_Image(), Load_SCR(), Load_SCx(), Load_TIFF_image(), Load_TNY(), PBM_Decode(), and SGX_Load_Picture().
void Fill_canvas | ( | T_IO_Context * | context, |
byte | color | ||
) |
Fill the entire current layer/frame of an image being loaded with a color.
References T_Document::backups, T_IO_Context::Buffer_image, CONTEXT_BRUSH, CONTEXT_MAIN_IMAGE, CONTEXT_PALETTE, CONTEXT_PREVIEW, CONTEXT_PREVIEW_PALETTE, CONTEXT_SURFACE, T_IO_Context::Current_layer, T_Document::current_layer, T_IO_Context::Height, T_Page::Height, T_Page::Image, Main, Menu_factor_X, Menu_factor_Y, T_List_of_pages::Pages, T_IO_Context::Pitch, T_Image::Pixels, T_IO_Context::Preview_bitmap, PREVIEW_HEIGHT, PREVIEW_WIDTH, T_IO_Context::Type, and T_Page::Width.
Referenced by Load_GIF().
void Set_pixel_24b | ( | T_IO_Context * | context, |
short | x_pos, | ||
short | y_pos, | ||
byte | r, | ||
byte | g, | ||
byte | b | ||
) |
Chargement des pixels dans le buffer 24b.
Set the color of a 24bit pixel (on load)
References T_Components::B, T_IO_Context::Buffer_image_24b, CONTEXT_BRUSH, CONTEXT_MAIN_IMAGE, CONTEXT_PALETTE, CONTEXT_PREVIEW, CONTEXT_PREVIEW_PALETTE, CONTEXT_SURFACE, T_Components::G, T_IO_Context::Height, Menu_factor_X, T_IO_Context::Preview_bitmap, T_IO_Context::Preview_factor_X, T_IO_Context::Preview_factor_Y, T_IO_Context::Preview_usage, PREVIEW_WIDTH, T_Components::R, T_IO_Context::Type, and T_IO_Context::Width.
Referenced by Draw_IFF_line(), Draw_IFF_line_HAM(), Draw_IFF_line_PCHG(), Load_BMP_Pixels(), Load_ClipBoard_Image(), Load_PCX(), Load_PNG_Sub(), Load_Recoil_Image(), and Load_TIFF_image().
void Set_palette_fake_24b | ( | T_Palette | palette | ) |
Referenced by Load_image().
void Set_frame_duration | ( | T_IO_Context * | context, |
int | duration | ||
) |
Function to call when loading an image's duration.
References T_Document::backups, CONTEXT_MAIN_IMAGE, T_IO_Context::Current_layer, T_Image::Duration, T_Page::Image, Main, T_List_of_pages::Pages, and T_IO_Context::Type.
Referenced by Load_FLI(), Load_GIF(), and Load_IFF().
int Get_frame_duration | ( | T_IO_Context * | context | ) |
Function to call to get an image's duration for saving.
References T_Document::backups, CONTEXT_MAIN_IMAGE, T_IO_Context::Current_layer, T_Image::Duration, T_Page::Image, Main, T_List_of_pages::Pages, and T_IO_Context::Type.
Referenced by Save_GIF().
void Set_image_mode | ( | T_IO_Context * | context, |
enum IMAGE_MODES | mode | ||
) |
Function to set a specific image mode.
References Any_effect_active(), T_Document::backups, BUTTON_EFFECTS, CONTEXT_MAIN_IMAGE, Draw_menu_button(), T_Page::Image_mode, IMAGE_MODE_ANIMATION, Main, mode, T_List_of_pages::Pages, Selected_Constraint_Mode, T_IO_Context::Type, and Update_screen_targets().
Referenced by Load_C64(), Load_CM5(), Load_FLI(), Load_GIF(), Load_GPX(), Load_HGR(), Load_IFF(), Load_INFO(), Load_MOTO(), Load_PRG(), and Load_TIFF_Sub().
enum IMAGE_MODES Get_image_mode | ( | T_IO_Context * | context | ) |
get the current image mode
References T_Document::backups, CONTEXT_MAIN_IMAGE, T_Page::Image_mode, IMAGE_MODE_LAYERED, Main, T_List_of_pages::Pages, and T_IO_Context::Type.
Referenced by Load_FLI().
void Pre_load | ( | T_IO_Context * | context, |
short | width, | ||
short | height, | ||
long | file_size, | ||
int | format, | ||
enum PIXEL_RATIO | ratio, | ||
byte | bpp | ||
) |
Generic allocation and similar stuff, done at beginning of image load, as soon as size is known.
References T_IO_Context::Background_transparent, Backup_new_image(), T_IO_Context::bpp, T_IO_Context::Buffer_image, T_IO_Context::Buffer_image_24b, T_IO_Context::Comment, Compute_optimal_menu_colors(), Config, CONTEXT_BRUSH, CONTEXT_MAIN_IMAGE, CONTEXT_PALETTE, CONTEXT_PREVIEW, CONTEXT_PREVIEW_PALETTE, CONTEXT_SURFACE, T_Document::current_layer, File_error, T_IO_Context::Format, format, Get_fileformat(), GFX2_malloc, T_IO_Context::Height, T_Document::layers_visible, Main, T_Config::Maximize_preview, MC_Black, MC_Light, Menu_factor_X, Menu_factor_Y, Message_out_of_memory(), T_IO_Context::Nb_layers, New_GFX2_Surface(), Num2str, T_IO_Context::Original_height, T_IO_Context::Original_width, T_IO_Context::Palette, T_Format::Palette_only, T_IO_Context::Pitch, Pixel_ratio, PIXEL_TALL, PIXEL_TALL2, PIXEL_TALL3, PIXEL_WIDE, PIXEL_WIDE2, T_IO_Context::Preview_bitmap, T_IO_Context::Preview_factor_X, T_IO_Context::Preview_factor_Y, PREVIEW_HEIGHT, T_IO_Context::Preview_pos_X, T_IO_Context::Preview_pos_Y, PREVIEW_WIDTH, Print_in_window(), T_IO_Context::Ratio, Round_div_max(), Set_loading_layer(), T_IO_Context::Surface, T_IO_Context::Target_address, T_IO_Context::Transparent_color, T_IO_Context::Type, Update_window_area, T_IO_Context::Width, Window_pos_X, Window_pos_Y, and Window_rectangle().
Referenced by Load_2GS(), Load_BMP(), Load_C64(), Load_CA1(), Load_CEL(), Load_ClipBoard_Image(), Load_CM5(), Load_FLI(), Load_GIF(), Load_GOS(), Load_GPX(), Load_GRB(), Load_HGR(), Load_ICO(), Load_IFF(), Load_IMG(), Load_INFO(), Load_MOTO(), Load_MSX(), Load_NEO(), Load_PC1(), Load_PCX(), Load_PI1(), Load_PKM(), Load_PNG_Sub(), Load_PPH(), Load_PRG(), Load_Recoil_Image(), Load_SCR(), Load_SCx(), Load_SGX(), Load_TIFF_Sub(), and Load_TNY().
void Load_image | ( | T_IO_Context * | context | ) |
High-level picture loading function.
References T_Components::B, Back_color, T_IO_Context::Background_transparent, T_Page::Background_transparent, Backup_layers(), T_Document::backups, T_IO_Context::bpp, Brush_original_palette, T_IO_Context::Buffer_image, T_IO_Context::Buffer_image_24b, T_IO_Context::Color_cycles, T_IO_Context::Comment, T_Page::Comment, Compute_optimal_menu_colors(), Config, CONTEXT_BRUSH, CONTEXT_MAIN_IMAGE, CONTEXT_PALETTE, CONTEXT_PREVIEW, CONTEXT_PREVIEW_PALETTE, CONTEXT_SURFACE, Convert_24b_bitmap_to_256(), Count_used_colors(), T_Document::current_layer, Cursor_shape, CURSOR_SHAPE_HOURGLASS, T_IO_Context::Cycle_range, DEFAULT_FILEFORMAT, Display_cursor(), Download_infos_page_main(), T_Color_cycle::End, T_Gradient_range::End, Error, Favorite_GUI_color(), T_IO_Context::File_directory, T_Page::File_directory, File_error, File_formats, T_IO_Context::File_name, T_IO_Context::File_name_unicode, T_Document::fileformat, T_Page::Filename, T_Page::Filename_unicode, Flush_update(), T_IO_Context::Format, format, FORMAT_ALL_FILES, FORMAT_CLIPBOARD, T_Components::G, Get_fileformat(), GFX2_ERROR, GFX2_Log(), GFX2_WARNING, T_Page::Gradients, T_IO_Context::Height, Hide_cursor, T_Page::Image, T_Document::image_height, T_Document::image_is_modified, T_Page::Image_mode, IMAGE_MODE_ANIMATION, T_Document::image_width, T_Color_cycle::Inverse, T_Gradient_range::Inverse, LAYER_NONE, T_Document::layers_visible, Load_ClipBoard_Image(), Load_Recoil_Image(), Main, MC_Black, MC_Light, MC_Window, Menu_factor_X, Nb_known_formats(), T_IO_Context::Nb_layers, NULL, Open_file_read(), T_IO_Context::Original_file_directory, T_IO_Context::Original_file_name, T_List_of_pages::Pages, T_GFX2_Surface::palette, T_IO_Context::Palette, T_Page::Palette, T_Document::palette, T_Format::Palette_only, Pixel, Pixel_ratio, PIXEL_TALL, PIXEL_TALL2, PIXEL_TALL3, PIXEL_WIDE, PIXEL_WIDE2, T_GFX2_Surface::pixels, T_Image::Pixels, T_IO_Context::Preview_bitmap, T_IO_Context::Preview_factor_X, T_IO_Context::Preview_factor_Y, PREVIEW_HEIGHT, T_IO_Context::Preview_pos_X, T_IO_Context::Preview_pos_Y, T_IO_Context::Preview_usage, PREVIEW_WIDTH, Print_in_window(), T_Components::R, T_Gradient_array::Range, T_IO_Context::Ratio, Realloc_brush(), Remap_brush(), Remap_screen_after_menu_colors_change(), T_Config::Safety_colors, Set_palette(), Set_palette_fake_24b(), T_Color_cycle::Speed, T_Gradient_range::Speed, T_Color_cycle::Start, T_Gradient_range::Start, T_IO_Context::Surface, T_IO_Context::Transparent_color, T_Page::Transparent_color, T_IO_Context::Type, Unicode_strdup(), Update_window_area, T_IO_Context::Width, and Window_rectangle().
Referenced by Button_Load_or_Save(), Button_Reload(), Init_program(), Load_picture(), Load_surface(), Main_handler(), and Process_backups().
void Save_image | ( | T_IO_Context * | context | ) |
High-level picture saving function.
References T_Document::backups, Close_window(), Confirmation_box(), CONTEXT_BRUSH, CONTEXT_MAIN_IMAGE, CONTEXT_PALETTE, CONTEXT_PREVIEW, CONTEXT_PREVIEW_PALETTE, CONTEXT_SURFACE, T_Document::current_layer, Display_cursor(), Error, File_error, T_IO_Context::Format, format, FORMAT_CLIPBOARD, Get_fileformat(), T_Page::Image, T_Bitmap::Image, T_Page::Image_mode, IMAGE_MODE_ANIMATION, KEY_ESC, KEY_NONE, Main, MC_Black, MC_Light, T_IO_Context::Nb_layers, T_Page::Nb_layers, Open_window(), T_List_of_pages::Pages, T_Image::Pixels, Print_in_window(), Save_ClipBoard_Image(), T_IO_Context::Target_address, T_IO_Context::Type, Update_window_area, T_Document::visible_image, Window_clicked_button(), Window_height, Window_set_normal_button(), and Window_width.
Referenced by Button_Autosave(), Button_Load_or_Save(), Button_Quit_local_function(), Main_handler(), Rotate_safety_backups(), and Save_picture().
T_GFX2_Surface * Load_surface | ( | const char * | filename, |
const char * | directory, | ||
T_Gradient_array * | gradients | ||
) |
Load an arbitrary Surface.
filename | file to load. |
directory | path of the file to load. if NULL, filename have to be a full path name |
gradients | Pass the address of a target T_Gradient_array if you want the gradients, NULL otherwise |
References T_IO_Context::Color_cycles, T_IO_Context::Cycle_range, Destroy_context(), T_Color_cycle::End, T_Gradient_range::End, Init_context_surface(), T_Color_cycle::Inverse, T_Gradient_range::Inverse, Load_image(), NULL, T_Gradient_array::Range, T_Color_cycle::Speed, T_Gradient_range::Speed, T_Color_cycle::Start, T_Gradient_range::Start, and T_IO_Context::Surface.
Referenced by Define_icon(), Load_font(), Load_graphics(), and Render_text_SFont().
void Emergency_backup | ( | const char * | fname, |
byte * | source, | ||
int | width, | ||
int | height, | ||
T_Palette * | palette | ||
) |
Saves an image.
This routine will only be called when all hope is lost, memory thrashed, etc It's the last chance to save anything, but the code has to be extremely careful, anything could happen. The chosen format is IMG since it's extremely simple, difficult to make it create an unusable image.
References Config_directory, File_error, Filepath_append_to_dir(), T_IMG_Header::Filler1, T_IMG_Header::Filler2, NULL, Write_byte(), Write_bytes(), and Write_word_le().
Referenced by Image_emergency_backup().
void Image_emergency_backup | ( | void | ) |
Function which attempts to save backups of the images (main and spare), called in case of SIGSEGV.
It will save an image only if it has just one layer... otherwise, the risk of flattening a layered image (or saving just one detail layer) is too high.
References BACKUP_FILE_EXTENSION, T_Document::backups, Emergency_backup(), T_Bitmap::Image, T_Document::image_height, T_Document::image_width, Main, Main_screen, T_Page::Nb_layers, T_List_of_pages::Pages, T_Document::palette, SAFETYBACKUP_PREFIX_A, SAFETYBACKUP_PREFIX_B, Spare, and T_Document::visible_image.
References File_formats, format, FORMAT_GIF, and Nb_known_formats().
Referenced by Button_Load_or_Save(), Load_image(), Load_picture(), Pre_load(), Read_list_of_files(), Save_image(), and Save_picture().
byte Get_pixel | ( | T_IO_Context * | context, |
short | x, | ||
short | y | ||
) |
Query the color of a pixel (to save)
References T_IO_Context::Pitch, and T_IO_Context::Target_address.
Referenced by C64_FLI(), Current_layer_count_used_colors(), Encode_C64_hires(), Encode_C64_multicolor(), GIF_next_pixel(), mode0interlace(), mode1interlace(), mode2interlace(), mode3interlace(), Save_2GS(), Save_BMP(), Save_CA1(), Save_CEL(), Save_ClipBoard_Image(), Save_CM5(), Save_GIF(), Save_HGR(), Save_ICO(), Save_IFF(), Save_IMG(), Save_MOTO(), Save_MSX(), Save_NEO(), Save_PC1(), Save_PCX(), Save_PI1(), Save_PKM(), Save_SCx(), Save_SGX_Sub(), and Save_XPM().
void Destroy_context | ( | T_IO_Context * | context | ) |
Cleans up resources.
References T_IO_Context::Buffer_image, T_IO_Context::Buffer_image_24b, T_IO_Context::File_directory, T_IO_Context::File_name, T_IO_Context::File_name_unicode, T_IO_Context::Original_file_directory, T_IO_Context::Original_file_name, and T_IO_Context::Preview_bitmap.
Referenced by Button_Autosave(), Button_Load_or_Save(), Button_Quit_local_function(), Button_Reload(), Init_program(), Load_picture(), Load_surface(), Main_handler(), Process_backups(), Rotate_safety_backups(), and Save_picture().
void Init_context_preview | ( | T_IO_Context * | context, |
const char * | file_name, | ||
const char * | file_directory | ||
) |
Setup for loading a preview in fileselector.
References CONTEXT_PREVIEW, T_IO_Context::File_directory, T_IO_Context::File_name, NULL, and T_IO_Context::Type.
Referenced by Button_Load_or_Save().
void Init_context_backup_image | ( | T_IO_Context * | context, |
const char * | file_name, | ||
const char * | file_directory | ||
) |
References Init_context_layered_image().
Referenced by Process_backups(), and Rotate_safety_backups().
void Init_context_layered_image | ( | T_IO_Context * | context, |
const char * | file_name, | ||
const char * | file_directory | ||
) |
Setup for loading/saving the current main image.
References T_IO_Context::Background_transparent, T_Page::Background_transparent, T_Document::backups, T_IO_Context::Color_cycles, T_IO_Context::Comment, T_Page::Comment, CONTEXT_MAIN_IMAGE, T_IO_Context::Cycle_range, T_Color_cycle::End, T_Gradient_range::End, T_IO_Context::File_directory, T_IO_Context::File_name, T_Document::fileformat, T_IO_Context::Format, T_Page::Gradients, T_IO_Context::Height, T_Page::Image, T_Document::image_height, T_Document::image_width, T_Color_cycle::Inverse, T_Gradient_range::Inverse, Main, T_IO_Context::Nb_layers, T_Page::Nb_layers, NULL, T_List_of_pages::Pages, T_IO_Context::Palette, T_Document::palette, T_IO_Context::Pitch, Pixel_ratio, T_Image::Pixels, T_Gradient_array::Range, T_IO_Context::Ratio, T_Color_cycle::Speed, T_Gradient_range::Speed, T_Color_cycle::Start, T_Gradient_range::Start, T_IO_Context::Target_address, T_IO_Context::Transparent_color, T_Page::Transparent_color, T_IO_Context::Type, and T_IO_Context::Width.
Referenced by Button_Autosave(), Button_Quit_local_function(), Button_Reload(), Init_context_backup_image(), Init_program(), Load_picture(), Main_handler(), and Save_picture().
void Init_context_brush | ( | T_IO_Context * | context, |
const char * | file_name, | ||
const char * | file_directory | ||
) |
Setup for loading/saving the flattened version of current main image.
Setup for loading/saving the user's brush
References Back_color, T_IO_Context::Background_transparent, Brush, Brush_fileformat, Brush_height, Brush_width, CONTEXT_BRUSH, T_IO_Context::File_directory, T_IO_Context::File_name, T_IO_Context::Format, T_IO_Context::Height, Main, T_IO_Context::Nb_layers, NULL, T_IO_Context::Palette, T_Document::palette, T_IO_Context::Pitch, PIXEL_SIMPLE, T_IO_Context::Ratio, T_IO_Context::Target_address, T_IO_Context::Transparent_color, T_IO_Context::Type, and T_IO_Context::Width.
Referenced by Load_picture(), Main_handler(), and Save_picture().
void Init_context_surface | ( | T_IO_Context * | context, |
const char * | file_name, | ||
const char * | file_directory | ||
) |
References T_IO_Context::Background_transparent, CONTEXT_SURFACE, DEFAULT_FILEFORMAT, T_IO_Context::File_directory, T_IO_Context::File_name, T_IO_Context::Format, T_IO_Context::Nb_layers, NULL, PIXEL_SIMPLE, T_IO_Context::Ratio, T_IO_Context::Transparent_color, and T_IO_Context::Type.
Referenced by Load_surface().
void Set_saving_layer | ( | T_IO_Context * | context, |
int | layer | ||
) |
Function to call when need to switch layers.
References T_Document::backups, CONTEXT_MAIN_IMAGE, T_IO_Context::Current_layer, T_Page::Image, Main, T_IO_Context::Nb_layers, T_Page::Nb_layers, T_List_of_pages::Pages, T_Image::Pixels, T_IO_Context::Target_address, and T_IO_Context::Type.
Referenced by C64_FLI(), Save_C64(), Save_CM5(), Save_GIF(), Save_HGR(), Save_PRG(), and Save_TIFF_Sub().
void Set_loading_layer | ( | T_IO_Context * | context, |
int | layer | ||
) |
Function to call when need to switch layers.
References Add_layer(), T_Document::backups, CONTEXT_MAIN_IMAGE, T_IO_Context::Current_layer, T_Document::current_layer, T_Page::Image, T_Document::layers_visible, Main, T_IO_Context::Nb_layers, T_Page::Nb_layers, T_List_of_pages::Pages, T_Image::Pixels, T_IO_Context::Target_address, T_IO_Context::Type, and Update_pixel_renderer().
Referenced by Load_C64_fli(), Load_CM5(), Load_FLI(), Load_GIF(), Load_HGR(), Load_IFF(), Load_INFO(), Load_MSX(), Load_TIFF_Sub(), and Pre_load().
|
static |
Adds a file to Backups_main or Backups_spare lists, if it's a backup.
References Backups_main, Backups_spare, GFX2_malloc, Main, T_String_list::Next, T_Document::safety_backup_prefix, Spare, and T_String_list::String.
Referenced by Check_recovery(), and Delete_safety_backups().
int String_compare | ( | const void * | a, |
const void * | b | ||
) |
String comparer for sorting.
Referenced by Process_backups().
byte Process_backups | ( | T_String_list ** | list | ) |
Reload safety backups, by loading several files in the right order.
References Config, Config_directory, Destroy_context(), Display_all_screen(), GFX2_malloc, T_Document::image_is_modified, Init_context_backup_image(), Load_image(), Main, T_Config::Max_undo_pages, T_String_list::Next, NULL, Redraw_layered_image(), T_String_list::String, and String_compare().
Referenced by Check_recovery().
int Check_recovery | ( | void | ) |
Checks if there are any pending safety backups, and then opens them.
References Add_backup_file(), Backups_main, Backups_spare, Button_Page(), BUTTON_PAGE, Compute_limits(), Compute_paintbrush_coordinates(), Config_directory, Create_lock_file(), For_each_file(), Main, NULL, T_Document::offset_X, T_Document::offset_Y, Process_backups(), and Safety_backup_active.
Referenced by Init_program().
void Rotate_safety_backups | ( | void | ) |
Makes a safety backup periodically.
References BACKUP_FILE_EXTENSION, T_Document::backups, Config_directory, Destroy_context(), T_Document::edits_since_safety_backup, T_Page::File_directory, T_Page::Filename, T_IO_Context::Format, FORMAT_GIF, GFX2_GetTicks(), GFX2_malloc, Init_context_backup_image(), Main, Max_edits_for_safety_backup, Max_interval_for_safety_backup, Min_edits_for_safety_backup, Min_interval_for_safety_backup, NULL, T_IO_Context::Original_file_directory, T_IO_Context::Original_file_name, T_List_of_pages::Pages, Remove_path(), Rotation_safety_backup, Safety_backup_active, T_Document::safety_backup_prefix, T_Document::safety_number, Save_image(), and T_Document::time_of_safety_backup.
Referenced by End_of_modification().
void Delete_safety_backups | ( | void | ) |
Remove safety backups. Need to call on normal program exit.
References Add_backup_file(), Backups_main, Backups_spare, Change_directory(), Config_directory, For_each_file(), T_String_list::Next, NULL, Release_lock_file(), Safety_backup_active, and T_String_list::String.
Referenced by Program_shutdown().
const T_Format File_formats[] |
Array of the known file formats.
Referenced by Button_Load_or_Save(), Get_fileformat(), Load_image(), and Nb_known_formats().
T_String_list* Backups_main = NULL |
A list of files, used for scanning a directory.
Referenced by Add_backup_file(), Check_recovery(), and Delete_safety_backups().
T_String_list* Backups_spare = NULL |
A list of files, used for scanning a directory.
Referenced by Add_backup_file(), Check_recovery(), and Delete_safety_backups().
const int Rotation_safety_backup = 8 |
Referenced by Rotate_safety_backups().
const int Min_interval_for_safety_backup = 30000 |
Referenced by Rotate_safety_backups().
const int Min_edits_for_safety_backup = 10 |
Referenced by Rotate_safety_backups().
const int Max_interval_for_safety_backup = 60000 |
Referenced by Rotate_safety_backups().
const int Max_edits_for_safety_backup = 30 |
Referenced by Rotate_safety_backups().
byte Safety_backup_active = 0 |
Global indicator that tells if the safety backup system is active.
Referenced by Check_recovery(), Delete_safety_backups(), and Rotate_safety_backups().