GrafX2 2.9.3227
The ultimate 256-color painting program
pages.c File Reference
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
#include "gfx2mem.h"
#include "global.h"
#include "pages.h"
#include "errors.h"
#include "loadsave.h"
#include "misc.h"
#include "windows.h"
#include "tiles.h"
#include "graph.h"
#include "layers.h"
#include "unicode.h"
+ Include dependency graph for pages.c:

Functions

T_PageNew_page (int nb_layers)
 Allocate and initialize a new page. More...
 
byteNew_layer (long pixel_size)
 Allocate a new layer. More...
 
void Free_layer (T_Page *page, int layer)
 Free a layer. More...
 
byteDup_layer (byte *layer)
 Duplicate a layer (new reference) More...
 
T_Gradient_arrayDup_gradient (T_Page *page)
 Adds a shared reference to the gradient data of another page. Pass NULL for new. More...
 
void Download_infos_page_main (T_Page *page)
 INDIVIDUAL PAGES. More...
 
void Redraw_layered_image (void)
 
void Update_depth_buffer (void)
 
void Redraw_spare_image (void)
 
void Redraw_current_layer (void)
 
void Upload_infos_page (T_Document *doc)
 
void Download_infos_page_spare (T_Page *page)
 
void Update_FX_feedback (byte with_feedback)
 Must be called after changing the head of Main_backups list, or Main_current_layer. More...
 
void Clear_page (T_Page *page)
 
void Copy_S_page (T_Page *dest, T_Page *source)
 
void Init_list_of_pages (T_List_of_pages *list)
 GESTION DES LISTES DE PAGES. More...
 
int Allocate_list_of_pages (T_List_of_pages *list)
 
void Backward_in_list_of_pages (T_List_of_pages *list)
 
void Advance_in_list_of_pages (T_List_of_pages *list)
 
void Free_last_page_of_list (T_List_of_pages *list)
 
int Create_new_page (T_Page *new_page, T_List_of_pages *list, int layer)
 
void Change_page_number_of_list (T_List_of_pages *list, int number)
 
void Free_page_of_a_list (T_List_of_pages *list)
 
void Update_screen_targets (void)
 
int Update_buffers (int width, int height)
 Update all the special image buffers, if necessary. More...
 
int Update_spare_buffers (int width, int height)
 Update all the special image buffers of the spare page, if necessary. More...
 
int Init_all_backup_lists (enum IMAGE_MODES image_mode, int width, int height)
 GESTION DES BACKUPS. More...
 
void Set_number_of_backups (int nb_backups)
 
int Backup_new_image (int layers, int width, int height)
 
int Backup_with_new_dimensions (int width, int height)
 
int Backup_in_place (int width, int height)
 Resizes a backup step in-place (doesn't add a Undo/Redo step). More...
 
int Backup_and_resize_the_spare (int width, int height)
 
void Backup (void)
 Backup with a new copy for the working layer, and references for all others. More...
 
void Backup_layers (int layer)
 Backup with a new copy of some layers (the others are references). More...
 
int Dup_layer_if_shared (T_Page *page, int layer)
 Backs up a layer, unless it's already different from previous history step. More...
 
void Backup_the_spare (int layer)
 Backup the spare image, the one you don't see. More...
 
void Check_layers_limits ()
 
void Undo (void)
 
void Redo (void)
 
void Free_current_page (void)
 
void End_of_modification (void)
 
byte Add_layer (T_List_of_pages *list, int layer)
 Add a new layer to latest page of a list. Returns 0 on success. More...
 
byte Delete_layer (T_List_of_pages *list, int layer)
 Delete a layer from the latest page of a list. Returns 0 on success. More...
 
byte Merge_layer (void)
 Merges the current layer onto the one below it. More...
 
void Switch_layer_mode (enum IMAGE_MODES new_mode)
 

Variables

T_Bitmap Main_visible_image_backup
 Array of two images, that contains the "flattened" version of the visible layers. More...
 
T_Bitmap Main_visible_image_depth_buffer
 The index of visible pixels Main page T_Document.visible_image. More...
 
static dword Last_backed_up_layers =0
 GESTION DES PAGES. More...
 
long Stats_pages_number =0
 Total number of unique bitmaps (layers, animation frames, backups) More...
 
long long Stats_pages_memory =0
 Total memory used by bitmaps (layers, animation frames, backups) More...
 
byteFX_feedback_screen
 Pointer to the image to read, while drawing. More...
 

Function Documentation

◆ New_page()

◆ New_layer()

byte * New_layer ( long  pixel_size)

◆ Free_layer()

void Free_layer ( T_Page page,
int  layer 
)

◆ Dup_layer()

byte * Dup_layer ( byte layer)

Duplicate a layer (new reference)

References NULL.

Referenced by Create_new_page().

◆ Dup_gradient()

T_Gradient_array * Dup_gradient ( T_Page page)

Adds a shared reference to the gradient data of another page. Pass NULL for new.

References T_Page::Gradients, NULL, and T_Gradient_array::Used.

Referenced by Allocate_list_of_pages(), Backup_new_image(), Backup_with_new_dimensions(), and Copy_S_page().

◆ Download_infos_page_main()

◆ Redraw_layered_image()

◆ Update_depth_buffer()

◆ Redraw_spare_image()

◆ Redraw_current_layer()

◆ Upload_infos_page()

◆ Download_infos_page_spare()

◆ Update_FX_feedback()

◆ Clear_page()

◆ Copy_S_page()

◆ Init_list_of_pages()

void Init_list_of_pages ( T_List_of_pages list)

GESTION DES LISTES DE PAGES.

LISTS OF PAGES.

References T_List_of_pages::List_size, NULL, and T_List_of_pages::Pages.

Referenced by Init_program().

◆ Allocate_list_of_pages()

◆ Backward_in_list_of_pages()

void Backward_in_list_of_pages ( T_List_of_pages list)

◆ Advance_in_list_of_pages()

void Advance_in_list_of_pages ( T_List_of_pages list)

◆ Free_last_page_of_list()

◆ Create_new_page()

◆ Change_page_number_of_list()

void Change_page_number_of_list ( T_List_of_pages list,
int  number 
)

◆ Free_page_of_a_list()

◆ Update_screen_targets()

◆ Update_buffers()

◆ Update_spare_buffers()

int Update_spare_buffers ( int  width,
int  height 
)

◆ Init_all_backup_lists()

◆ Set_number_of_backups()

void Set_number_of_backups ( int  nb_backups)

◆ Backup_new_image()

◆ Backup_with_new_dimensions()

◆ Backup_in_place()

int Backup_in_place ( int  width,
int  height 
)

Resizes a backup step in-place (doesn't add a Undo/Redo step).

Should only be called after an actual backup, because it loses the current. pixels. This function is meant to be used from within Lua scripts.

References T_Document::backups, Download_infos_page_main(), Free_layer(), GFX2_malloc, T_Page::Height, T_Bitmap::Height, T_Page::Image, T_Bitmap::Image, T_Page::Image_mode, IMAGE_MODE_ANIMATION, Main, Main_visible_image_depth_buffer, T_Page::Nb_layers, New_layer(), NULL, T_List_of_pages::Pages, T_Image::Pixels, T_Page::Transparent_color, Update_screen_targets(), T_Document::visible_image, T_Page::Width, and T_Bitmap::Width.

◆ Backup_and_resize_the_spare()

◆ Backup()

◆ Backup_layers()

◆ Dup_layer_if_shared()

int Dup_layer_if_shared ( T_Page page,
int  layer 
)

Backs up a layer, unless it's already different from previous history step.

References Free_layer(), T_Page::Height, T_Page::Image, New_layer(), T_Page::Next, T_Image::Pixels, and T_Page::Width.

◆ Backup_the_spare()

◆ Check_layers_limits()

◆ Undo()

◆ Redo()

◆ Free_current_page()

◆ End_of_modification()

void End_of_modification ( void  )

References T_Document::backups, Config, T_Document::edits_since_safety_backup, T_Config::FX_Feedback, T_Bitmap::Image, T_Document::image_height, T_Page::Image_mode, IMAGE_MODE_ANIMATION, T_Document::image_width, Main, Main_visible_image_backup, T_List_of_pages::Pages, Rotate_safety_backups(), Update_buffers(), Update_FX_feedback(), Update_screen_targets(), and T_Document::visible_image.

Referenced by Airbrush_0_2(), Brush_0_5(), Button_Anim_time(), Button_Clear(), Button_Clear_with_backcolor(), Button_Constraint_menu(), Button_Layer_add(), Button_Layer_down(), Button_Layer_duplicate(), Button_Layer_menu(), Button_Layer_merge(), Button_Layer_remove(), Button_Layer_set_transparent(), Button_Layer_up(), Button_Page(), Button_Palette(), Button_Reload(), Button_Resolution(), Button_Transform_menu(), Centered_lines_12_7(), Curve_4_points_2_9(), Curve_finalize(), Empty_circle_0_5(), Empty_ellipse_0_5(), Empty_rectangle_0_5(), Fill_1_0(), Fill_2_0(), Fill_general(), Filled_circle_0_5(), Filled_contour_0_8(), Filled_ellipse_0_5(), Filled_polyform_12_8(), Filled_rectangle_0_5(), Free_current_page(), Freehand_mode12_0_2(), Freehand_mode3_0_1(), Get_colors_from_brush(), Grad_circle_0_6(), Grad_circle_12_8(), Grad_ellipse_0_6(), Grad_ellipse_12_8(), Grad_rectangle_0_9(), Init_all_backup_lists(), Init_program(), K_line_12_7(), Line_0_5(), Load_picture(), Main_handler(), Polybrush_12_8(), Polyfill_12_9(), Polyform_12_8(), Polygon_12_9(), Redo(), Replace_1_0(), Replace_2_0(), Scroll_0_5(), and Undo().

◆ Add_layer()

◆ Delete_layer()

byte Delete_layer ( T_List_of_pages list,
int  layer 
)

Delete a layer from the latest page of a list. Returns 0 on success.

References T_Document::backups, T_Document::current_layer, Free_layer(), T_Page::Image, T_Document::layers_visible, Main, T_Page::Nb_layers, T_List_of_pages::Pages, and Spare.

Referenced by Button_Layer_remove(), and Merge_layer().

◆ Merge_layer()

◆ Switch_layer_mode()

Variable Documentation

◆ Main_visible_image_backup

T_Bitmap Main_visible_image_backup

Array of two images, that contains the "flattened" version of the visible layers.

The pixels of visible layers, flattened copy, used for no-feedback effects.

Referenced by Backup_with_new_dimensions(), End_of_modification(), Init_all_backup_lists(), Program_shutdown(), Scroll_12_0(), Update_buffers(), and Update_screen_targets().

◆ Main_visible_image_depth_buffer

◆ Last_backed_up_layers

dword Last_backed_up_layers =0
static

GESTION DES PAGES.

Bitfield which records which layers are backed up in Page 0.

Referenced by Advance_in_list_of_pages(), Backward_in_list_of_pages(), Redo(), and Undo().

◆ Stats_pages_number

long Stats_pages_number =0

Total number of unique bitmaps (layers, animation frames, backups)

STATISTICS.

Referenced by Button_Stats(), Free_layer(), and New_layer().

◆ Stats_pages_memory

long long Stats_pages_memory =0

Total memory used by bitmaps (layers, animation frames, backups)

Referenced by Button_Stats(), Free_layer(), and New_layer().

◆ FX_feedback_screen

byte* FX_feedback_screen

Pointer to the image to read, while drawing.

It's either the last history layer page when FX feedback is on, or the history page before it when FX feedback is off.

Referenced by Read_pixel_from_feedback_screen(), and Update_FX_feedback().