GrafX2 2.9.3227
The ultimate 256-color painting program
|
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "const.h"
#include "struct.h"
#include "global.h"
#include "misc.h"
#include "engine.h"
#include "readline.h"
#include "buttons.h"
#include "pages.h"
#include "help.h"
#include "screen.h"
#include "errors.h"
#include "op_c.h"
#include "windows.h"
#include "input.h"
#include "graph.h"
#include "palette.h"
#include "shade.h"
Functions | |
static void | Component_unit (int count) |
void | Set_palette_RGB_scale (int scale) |
Choose the number of graduations for RGB components, from 2 to 256. More... | |
int | Get_palette_RGB_scale (void) |
void | Set_palette_Gamma (int gamma) |
Configure Gamma correction. More... | |
byte | Round_palette_component (byte comp) |
Round a 0-255 RGB component according to the RGB_scale and gamm correction. More... | |
static int | Decode_component (int comp) |
Turns a RGB component from 0-(RGB_scale-1) scale to 0-255 and apply reverse. More... | |
int | Encode_component (int comp) |
Turns a RGB component from 0-255 to 0-(RGB_scale-1) and apply Gamma correction. More... | |
static int | Add_encoded (int comp, int offset) |
Compute the component at a given distance from the current one. More... | |
void | Set_HSL (T_Palette start_palette, T_Palette end_palette, byte color, short diff_h, short diff_s, short diff_l) |
void | Set_red (byte color, short new_color, T_Palette palette) |
void | Set_green (byte color, short new_color, T_Palette palette) |
void | Set_blue (byte color, short new_color, T_Palette palette) |
void | Format_component (byte value, char *str) |
void | Spread_colors (short start, short end, T_Palette palette) |
void | Palette_edit_step () |
Backup before doing one self-complete change. More... | |
void | Palette_edit_select_range () |
Mode for incremental changes. More... | |
void | Palette_edit_alter_channel () |
Perform incremental change in RGB channel of some color(s). More... | |
void | Palette_edit_undo_redo () |
Undo. More... | |
void | Update_color_count (short *used_colors, dword *color_usage) |
void | Remap_zone_highlevel (short x1, short y1, short x2, short y2, byte *conversion_table) |
void | Remap_image_highlevel (byte *conversion_table) |
void | Swap (int with_remap, short block_1_start, short block_2_start, short block_size, T_Palette palette, dword *color_usage) |
void | Set_nice_menu_colors (dword *color_usage, int not_picture) |
Adds 4 menu colors in the current palette. More... | |
void | Reduce_palette (short *used_colors, int nb_colors_asked, T_Palette palette, dword *color_usage) |
void | Set_palette_slider (T_Scroller_button *slider, word nb_elements, word position, char *value, short x_pos) |
void | Display_sliders (T_Scroller_button *red_slider, T_Scroller_button *green_slider, T_Scroller_button *blue_slider, byte block_is_selected, T_Components *palette) |
void | Draw_all_palette_sliders (T_Scroller_button *red_slider, T_Scroller_button *green_slider, T_Scroller_button *blue_slider, T_Palette palette, byte start, byte end) |
int | Window_Histogram (unsigned char block_start, unsigned char block_end, dword *color_usage) |
void | Print_RGB_or_HSL (byte mode) |
void | Tag_used_colors (byte color, dword color_usage[]) |
void | Button_Palette (int btn) |
Open the palette menu and handles everything inside it. More... | |
void | Button_Secondary_palette (int btn) |
Open the secondary palette menu and handles it. More... | |
void | Set_clipboard_colors (int nb_colors, T_Components *colors) |
Put some colors in the clipboard. More... | |
int | Get_clipboard_colors (T_Palette palette, byte start_color) |
Get some RGB colors from clipboard. More... | |
const T_Components * | Favorite_GUI_color (byte color_index) |
Get the favorite color to use for GUI's black,dark,light or white. More... | |
Variables | |
static byte | Palette_view_is_RGB = 1 |
static float | Gamma = 1.0 |
static const int | COUNT_X = 138 |
static const int | COUNT_Y = 64 |
int | RGB_scale = 256 |
int | Color_count =256 |
int | Color_max =255 |
int | Color_halfstep =0 |
T_Components * | backup_palette |
T_Components * | temp_palette |
T_Components * | working_palette |
byte | Palette_undo_state = 0 |
byte | Palette_change_state = 0 |
static const int | NUMERIC_R_X = 216 |
static const int | NUMERIC_G_X = 243 |
static const int | NUMERIC_B_X = 270 |
static const int | NUMERIC_Y = 183 |
static const int | NUMERIC_BOX_X = 215 |
static const int | NUMERIC_BOX_Y = 181 |
static const int | NUMERIC_BOX_W = 81 |
static const int | NUMERIC_BOX_H = 12 |
int | Palette_clipboard_count =0 |
T_Palette | Palette_clipboard |
|
static |
References Color_count, Color_halfstep, and Color_max.
Referenced by Button_Palette(), and Set_palette_RGB_scale().
void Set_palette_RGB_scale | ( | int | scale | ) |
Choose the number of graduations for RGB components, from 2 to 256.
References Component_unit(), and RGB_scale.
Referenced by Analyze_command_line(), Button_Constraint_menu(), and Button_Secondary_palette().
int Get_palette_RGB_scale | ( | void | ) |
References RGB_scale.
Referenced by Compute_optimal_menu_colors(), and PI1_code_palette().
void Set_palette_Gamma | ( | int | gamma | ) |
Configure Gamma correction.
References Gamma.
Referenced by Analyze_command_line(), and Button_Constraint_menu().
Round a 0-255 RGB component according to the RGB_scale and gamm correction.
Scale a component (R, G or B) according to the current RGB graduations.
The result is also in the 0-255 range.
References Gamma, and RGB_scale.
Referenced by Compute_optimal_menu_colors(), Set_blue(), Set_green(), Set_nice_menu_colors(), Set_palette(), and Set_red().
|
static |
Turns a RGB component from 0-(RGB_scale-1) scale to 0-255 and apply reverse.
The passed value should come from Round_palette_component(), otherwise the rounding will be "down".
References Color_max, and Gamma.
Referenced by Add_encoded(), Button_Palette(), and Spread_colors().
int Encode_component | ( | int | comp | ) |
Turns a RGB component from 0-255 to 0-(RGB_scale-1) and apply Gamma correction.
Turns a RGB component from 0-255 to 0-(RGB_scale-1) with Gamma correction.
References Color_max, and Gamma.
Referenced by Add_encoded(), Display_sliders(), Draw_all_palette_sliders(), Spread_colors(), and Status_print_palette_color().
|
static |
Compute the component at a given distance from the current one.
Used by the add/remove and lighten/darken operations.
References Decode_component(), and Encode_component().
Referenced by Button_Palette().
void Set_HSL | ( | T_Palette | start_palette, |
T_Palette | end_palette, | ||
byte | color, | ||
short | diff_h, | ||
short | diff_s, | ||
short | diff_l | ||
) |
References HSL_to_RGB(), and RGB_to_HSL().
Referenced by Button_Palette().
References Round_palette_component().
Referenced by Button_Palette(), and Spread_colors().
References Round_palette_component().
Referenced by Button_Palette(), and Spread_colors().
References Round_palette_component().
Referenced by Button_Palette(), and Spread_colors().
void Format_component | ( | byte | value, |
char * | str | ||
) |
Referenced by Button_Palette(), Display_sliders(), and Draw_all_palette_sliders().
void Spread_colors | ( | short | start, |
short | end, | ||
T_Palette | palette | ||
) |
References Decode_component(), Encode_component(), Set_blue(), Set_green(), Set_palette(), and Set_red().
Referenced by Button_Palette().
void Palette_edit_step | ( | ) |
Backup before doing one self-complete change.
References backup_palette, Palette_change_state, Palette_undo_state, and working_palette.
Referenced by Button_Palette().
void Palette_edit_select_range | ( | ) |
void Palette_edit_alter_channel | ( | ) |
Perform incremental change in RGB channel of some color(s).
References backup_palette, Palette_change_state, temp_palette, and working_palette.
Referenced by Button_Palette().
void Palette_edit_undo_redo | ( | ) |
Undo.
References backup_palette, Palette_change_state, Palette_undo_state, temp_palette, and working_palette.
Referenced by Button_Palette().
void Update_color_count | ( | short * | used_colors, |
dword * | color_usage | ||
) |
References Count_used_colors(), COUNT_X, COUNT_Y, Cursor_shape, CURSOR_SHAPE_ARROW, CURSOR_SHAPE_HOURGLASS, Display_cursor(), Hide_cursor, MC_Black, MC_Light, Num2str, and Print_in_window().
Referenced by Button_Palette(), and Reduce_palette().
void Remap_zone_highlevel | ( | short | x1, |
short | y1, | ||
short | x2, | ||
short | y2, | ||
byte * | conversion_table | ||
) |
References Menu_factor_X, Menu_factor_Y, Pixel, Read_pixel, Window_height, Window_pos_X, Window_pos_Y, and Window_width.
Referenced by Remap_image_highlevel(), and Set_nice_menu_colors().
void Remap_image_highlevel | ( | byte * | conversion_table | ) |
References T_Document::backups, T_Page::Image, T_Bitmap::Image, T_Document::image_height, T_Page::Image_mode, IMAGE_MODE_ANIMATION, IMAGE_MODE_MODE5, IMAGE_MODE_RASTER, T_Document::image_width, T_Document::magnifier_factor, T_Document::magnifier_mode, Main, Menu_factor_X, Menu_Y_before_window, T_Page::Nb_layers, T_List_of_pages::Pages, T_Image::Pixels, Remap_general_lowlevel(), Remap_window_backgrounds(), Remap_zone_highlevel(), Screen_width, T_Document::separator_position, SEPARATOR_WIDTH, T_Page::Transparent_color, T_Document::visible_image, and T_Document::X_zoom.
Referenced by Button_Palette(), Reduce_palette(), Set_nice_menu_colors(), and Swap().
void Swap | ( | int | with_remap, |
short | block_1_start, | ||
short | block_2_start, | ||
short | block_size, | ||
T_Palette | palette, | ||
dword * | color_usage | ||
) |
References T_Components::B, T_Components::G, T_Components::R, Remap_image_highlevel(), SWAP_BYTES, SWAP_DWORDS, and temp_palette.
Referenced by Button_Palette().
void Set_nice_menu_colors | ( | dword * | color_usage, |
int | not_picture | ||
) |
Adds 4 menu colors in the current palette.
color_usage | An up-to-date color usage table (byte[256]) (read only) |
not_picture | 0 if the caller is the palette screen, 1 if it's a preview in the file selector. |
References T_Components::B, Best_color_nonexcluded(), Display_cursor(), Favorite_GUI_color(), T_Components::G, Hide_cursor, Main, T_Document::palette, T_Components::R, Remap_image_highlevel(), Remap_zone_highlevel(), Round_palette_component(), Screen_height, and Screen_width.
Referenced by Button_Palette().
void Reduce_palette | ( | short * | used_colors, |
int | nb_colors_asked, | ||
T_Palette | palette, | ||
dword * | color_usage | ||
) |
References COUNT_X, COUNT_Y, Display_cursor(), Hide_cursor, MC_Black, MC_Light, Num2str, Print_in_window(), Remap_image_highlevel(), Round_div(), and Update_color_count().
Referenced by Button_Palette().
void Set_palette_slider | ( | T_Scroller_button * | slider, |
word | nb_elements, | ||
word | position, | ||
char * | value, | ||
short | x_pos | ||
) |
References Compute_slider_cursor_length(), MC_Black, MC_Light, T_Scroller_button::Nb_elements, NUMERIC_Y, T_Scroller_button::Position, Print_counter(), and Window_draw_slider().
Referenced by Display_sliders().
void Display_sliders | ( | T_Scroller_button * | red_slider, |
T_Scroller_button * | green_slider, | ||
T_Scroller_button * | blue_slider, | ||
byte | block_is_selected, | ||
T_Components * | palette | ||
) |
References T_Components::B, Color_count, Color_max, Encode_component(), Fore_color, Format_component(), T_Components::G, NUMERIC_B_X, NUMERIC_G_X, NUMERIC_R_X, Palette_view_is_RGB, T_Components::R, RGB_to_HSL(), and Set_palette_slider().
Referenced by Button_Palette().
void Draw_all_palette_sliders | ( | T_Scroller_button * | red_slider, |
T_Scroller_button * | green_slider, | ||
T_Scroller_button * | blue_slider, | ||
T_Palette | palette, | ||
byte | start, | ||
byte | end | ||
) |
References Color_max, Display_cursor(), Encode_component(), Format_component(), Hide_cursor, MC_Black, MC_Light, NUMERIC_B_X, NUMERIC_G_X, NUMERIC_R_X, NUMERIC_Y, Palette_view_is_RGB, T_Scroller_button::Position, Print_counter(), RGB_to_HSL(), and Window_draw_slider().
Referenced by Button_Palette().
int Window_Histogram | ( | unsigned char | block_start, |
unsigned char | block_end, | ||
dword * | color_usage | ||
) |
References Close_window(), Display_cursor(), T_Special_button::Height, Hide_cursor, Key, KEY_ESC, KEY_RETURN, MC_Black, MC_Dark, MC_Light, Menu_factor_X, Mouse_K, Mouse_X, Num2str, Open_window(), T_Special_button::Pos_X, T_Special_button::Pos_Y, Print_in_window(), Quit_is_required, Update_window_area, Warning_message(), T_Special_button::Width, Window_click_in_rectangle(), Window_clicked_button(), Window_pos_X, Window_rectangle(), Window_set_normal_button(), and Window_set_special_button().
Referenced by Button_Palette().
void Print_RGB_or_HSL | ( | byte | mode | ) |
References MC_Dark, MC_Light, mode, and Print_in_window().
Referenced by Button_Palette().
References MC_Light, MC_White, Update_window_area, Window_palette_button_list, and Window_rectangle().
Referenced by Button_Palette().
void Button_Palette | ( | int | btn | ) |
Open the palette menu and handles everything inside it.
References Add_encoded(), T_Components::B, Back_color, Backup_layers(), backup_palette, T_Dropdown_button::Bottom_up, BUTTON_COLORPICKER, BUTTON_HELP, BUTTON_PALETTE, BUTTON_UNDO, Close_window(), Color_count, Color_max, Component_unit(), Compute_optimal_menu_colors(), Config, CONTEXT_PALETTE, Decode_component(), Display_cursor(), Display_grad_block_in_window(), Display_menu(), Display_sliders(), Draw_all_palette_sliders(), Draw_thingumajig(), Dropdown_activate(), T_Dropdown_button::Dropdown_width, End_of_modification(), T_Dropdown_button::First_item, Fore_color, Format_component(), T_Components::G, Get_clipboard_colors(), Get_color_behind_window(), T_Dropdown_button::Height, Hide_cursor, HSL_to_RGB(), Input_sticky_control, INPUT_TYPE_HEXA, Is_shortcut(), Key, KEY_b, KEY_BACKSPACE, KEY_c, KEY_d, KEY_DELETE, KEY_e, KEY_ESC, KEY_f, KEY_g, KEY_h, KEY_i, KEY_KP_MINUS, KEY_KP_PLUS, KEY_l, KEY_m, KEY_n, KEY_NONE, KEY_RETURN, KEY_s, KEY_t, KEY_u, KEY_w, KEY_x, L1, L2, L3, L4, LAYER_ALL, LAYER_NONE, LEFT_SIDE, Load_picture(), Main, MC_Black, MC_Dark, MC_Light, MC_White, Menu_factor_Y, Menu_Y_before_window, Mouse_K, Mouse_X, Mouse_Y, NULL, Num2str, T_Dropdown_choice::Number, NUMERIC_B_X, NUMERIC_BOX_H, NUMERIC_BOX_W, NUMERIC_BOX_X, NUMERIC_BOX_Y, NUMERIC_G_X, NUMERIC_R_X, NUMERIC_Y, Open_window(), T_Document::palette, Palette_edit_alter_channel(), Palette_edit_select_range(), Palette_edit_step(), Palette_edit_undo_redo(), Palette_view_is_RGB, Perceptual_lightness(), T_Dropdown_button::Pos_X, T_Dropdown_button::Pos_Y, T_Scroller_button::Position, Print_counter(), Print_in_window(), Print_RGB_or_HSL(), Quit_is_required, T_Components::R, Read_pixel, Readline(), Reduce_palette(), Remap_image_highlevel(), Remap_screen_after_menu_colors_change(), Reposition_palette(), Requester_window(), RGB_scale, RGB_to_HSL(), RIGHT_SIDE, T_Config::Safety_colors, Save_picture(), Screen_width, Select_button(), Set_blue(), Set_clipboard_colors(), Set_green(), Set_HSL(), Set_nice_menu_colors(), Set_palette(), Set_red(), SHORTCUT_COPY, SHORTCUT_PASTE, SPECIAL_NEXT_BACKCOLOR, SPECIAL_NEXT_FORECOLOR, SPECIAL_PREVIOUS_BACKCOLOR, SPECIAL_PREVIOUS_FORECOLOR, Spread_colors(), Swap(), SWAP_BYTES, SWAP_DWORDS, Tag_color_range(), Tag_used_colors(), temp_palette, Unselect_button(), Update_color_count(), Update_rect(), Update_window_area, Wait_click_in_palette(), Wait_end_of_click(), Window_attribute2, Window_clicked_button(), Window_display_frame_mono(), Window_draw_normal_bouton(), Window_draw_palette_bouton(), Window_draw_slider(), Window_dropdown_add_item(), Window_dropdown_clear_items(), Window_height, Window_help(), Window_Histogram(), Window_palette_button_list, Window_pos_Y, Window_rectangle(), Window_set_dropdown_button(), Window_set_normal_button(), Window_set_palette_button(), Window_set_repeatable_button(), Window_set_scroller_button(), and working_palette.
Referenced by Button_Select_forecolor().
void Button_Secondary_palette | ( | int | btn | ) |
Open the secondary palette menu and handles it.
References BUTTON_HELP, BUTTON_PAL_LEFT, BUTTON_PAL_RIGHT, BUTTON_PALETTE, BUTTON_RELEASED, Change_palette_cells(), Close_window(), Compute_optimal_menu_colors(), Config, Display_cursor(), Display_menu(), Display_sprite_in_menu(), Draw_menu_button(), Exclude_color, Gamma, Hide_cursor, Is_shortcut(), Key, KEY_b, KEY_ESC, KEY_NONE, KEY_RETURN, KEY_s, KEY_w, KEY_x, Main, MC_Black, MC_Dark, MC_Light, MENU_SPRITE_VERTICAL_PALETTE_SCROLL, Menu_tag_colors(), NULL, Num2str, Open_window(), T_Document::palette, T_Config::Palette_cells_X, T_Config::Palette_cells_Y, T_Config::Palette_vertical, Pixel_in_window(), T_Scroller_button::Position, Print_in_window(), Quit_is_required, RGB_scale, Set_palette(), Set_palette_RGB_scale(), Shade_settings_menu(), SPECIAL_EXCLUDE_COLORS_MENU, Unselect_button(), Update_window_area, Window_attribute2, Window_clicked_button(), Window_display_frame(), Window_draw_slider(), Window_help(), Window_set_horizontal_scroller_button(), Window_set_normal_button(), and Window_set_scroller_button().
void Set_clipboard_colors | ( | int | nb_colors, |
T_Components * | colors | ||
) |
Put some colors in the clipboard.
nb_colors | Number of colors to push |
colors | First color of the input array |
References Palette_clipboard, and Palette_clipboard_count.
Referenced by Button_Palette().
Get some RGB colors from clipboard.
palette | Target palette |
start_color | Index of first color to replace |
References Palette_clipboard, and Palette_clipboard_count.
Referenced by Button_Palette().
const T_Components * Favorite_GUI_color | ( | byte | color_index | ) |
Get the favorite color to use for GUI's black,dark,light or white.
References T_Components::B, T_Gui_skin::Color, T_Gui_skin::Default_palette, T_Components::G, Gfx, T_Components::R, and RGB_scale.
Referenced by Button_Constraint_menu(), Load_image(), and Set_nice_menu_colors().
|
static |
Referenced by Button_Palette(), Display_sliders(), and Draw_all_palette_sliders().
|
static |
Referenced by Button_Secondary_palette(), Decode_component(), Encode_component(), Round_palette_component(), and Set_palette_Gamma().
|
static |
Referenced by Reduce_palette(), and Update_color_count().
|
static |
Referenced by Reduce_palette(), and Update_color_count().
int RGB_scale = 256 |
int Color_count =256 |
Referenced by Button_Palette(), Component_unit(), and Display_sliders().
int Color_max =255 |
Referenced by Button_Palette(), Component_unit(), Decode_component(), Display_sliders(), Draw_all_palette_sliders(), and Encode_component().
int Color_halfstep =0 |
Referenced by Component_unit().
T_Components* backup_palette |
Referenced by Button_Palette(), Error_function(), Palette_edit_alter_channel(), Palette_edit_step(), and Palette_edit_undo_redo().
T_Components* temp_palette |
Referenced by Button_Palette(), Error_function(), Palette_edit_alter_channel(), Palette_edit_undo_redo(), and Swap().
T_Components* working_palette |
Referenced by Button_Palette(), Palette_edit_alter_channel(), Palette_edit_step(), and Palette_edit_undo_redo().
byte Palette_undo_state = 0 |
Referenced by Palette_edit_step(), and Palette_edit_undo_redo().
byte Palette_change_state = 0 |
Referenced by Palette_edit_alter_channel(), Palette_edit_select_range(), Palette_edit_step(), and Palette_edit_undo_redo().
|
static |
Referenced by Button_Palette(), Display_sliders(), and Draw_all_palette_sliders().
|
static |
Referenced by Button_Palette(), Display_sliders(), and Draw_all_palette_sliders().
|
static |
Referenced by Button_Palette(), Display_sliders(), and Draw_all_palette_sliders().
|
static |
Referenced by Button_Palette(), Draw_all_palette_sliders(), and Set_palette_slider().
|
static |
Referenced by Button_Palette().
|
static |
Referenced by Button_Palette().
|
static |
Referenced by Button_Palette().
|
static |
Referenced by Button_Palette().
int Palette_clipboard_count =0 |
Referenced by Get_clipboard_colors(), and Set_clipboard_colors().
T_Palette Palette_clipboard |
Referenced by Get_clipboard_colors(), and Set_clipboard_colors().