GrafX2 2.9.3227
The ultimate 256-color painting program
misc.c File Reference
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <math.h>
#include "struct.h"
#include "global.h"
#include "errors.h"
#include "buttons.h"
#include "engine.h"
#include "misc.h"
#include "osdep.h"
#include "keyboard.h"
#include "screen.h"
#include "windows.h"
#include "palette.h"
#include "input.h"
#include "graph.h"
#include "pages.h"
+ Include dependency graph for misc.c:

Functions

word Count_used_colors (dword *usage)
 Count used palette indexes in the whole picture Return the total number of different colors Fill in "usage" with the count for each color. More...
 
word Count_used_colors_screen_area (dword *usage, word start_x, word start_y, word width, word height)
 Same as Count_used_colors, but use a block screen memory instead of picture data. More...
 
word Count_used_colors_area (dword *usage, word start_x, word start_y, word width, word height)
 Same as Count_used_colors, but for a given rectangle in the picture only. More...
 
const T_ComponentsGet_current_palette (void)
 
void Set_palette (T_Palette palette)
 
void Set_color (byte color, byte red, byte green, byte blue)
 
void Wait_end_of_click (void)
 
void Clear_current_image_with_stencil (byte color, byte *stencil)
 
void Clear_current_image (byte color)
 
void Init_chrono (dword delay)
 
void Pixel_in_brush (word x, word y, byte color)
 
byte Read_pixel_from_brush (word x, word y)
 
void Copy_part_of_image_to_another (byte *source, word source_x, word source_y, word width, word height, word source_width, byte *dest, word dest_x, word dest_y, word destination_width)
 
byte Read_pixel_from_spare_screen (word x, word y)
 
void Rotate_90_deg_lowlevel (byte *source, byte *dest, short width, short height)
 Rotate a pixel buffer by 90 degrees, clockwise. More...
 
void Rotate_270_deg_lowlevel (byte *source, byte *dest, short width, short height)
 Rotate a pixel buffer by 90 degrees, counter-clockwise. More...
 
void Remap_general_lowlevel (byte *conversion_table, byte *in_buffer, byte *out_buffer, short width, short height, short buffer_width)
 
void Copy_image_to_brush (short start_x, short start_y, short Brush_width, short Brush_height, word image_width)
 
byte Read_pixel_from_feedback_screen (word x, word y)
 
dword Round_div (dword numerator, dword divisor)
 
byte Effect_sieve (word x, word y)
 
void Replace_colors_within_limits (byte *replace_table)
 
byte Read_pixel_from_backup_screen (word x, word y)
 
byte Effect_interpolated_colorize (word x, word y, byte color)
 
byte Effect_additive_colorize (word x, word y, byte color)
 
byte Effect_substractive_colorize (word x, word y, byte color)
 
byte Effect_alpha_colorize (word x, word y, byte color)
 
void Check_timer (void)
 
void Flip_Y_lowlevel (byte *src, short width, short height)
 Inverts a pixel buffer, according to a horizontal axis. More...
 
void Flip_X_lowlevel (byte *src, short width, short height)
 Inverts a pixel buffer, according to a vertical axis. More...
 
void Rotate_180_deg_lowlevel (byte *src, short width, short height)
 Rotate a pixel buffer by 180 degrees. More...
 
void Rescale (byte *src_buffer, short src_width, short src_height, byte *dst_buffer, short dst_width, short dst_height, short x_flipped, short y_flipped)
 Copies an image to another, rescaling it and optionally flipping it. More...
 
void Scroll_picture (byte *main_src, byte *main_dest, short x_offset, short y_offset)
 
void Zoom_a_line (byte *original_line, byte *zoomed_line, word factor, word width)
 
short Round (float value)
 
short Round_div_max (short numerator, short divisor)
 
int Min (int a, int b)
 
int Max (int a, int b)
 
double Fround (double n, unsigned d)
 
const char * Mode_label (int mode)
 
int Convert_videomode_arg (const char *argument)
 

Variables

static T_Palette Current_palette
 

Function Documentation

◆ Count_used_colors()

word Count_used_colors ( dword usage)

Count used palette indexes in the whole picture Return the total number of different colors Fill in "usage" with the count for each color.

References T_Document::backups, T_Page::Image, T_Document::image_height, T_Document::image_width, Main, T_Page::Nb_layers, T_List_of_pages::Pages, and T_Image::Pixels.

Referenced by Button_Stats(), Convert_to_dhgr(), Convert_to_hgr(), Find_recog(), Get_colors_from_brush(), Load_image(), Save_CEL(), Save_KCF(), and Update_color_count().

◆ Count_used_colors_screen_area()

word Count_used_colors_screen_area ( dword usage,
word  start_x,
word  start_y,
word  width,
word  height 
)

Same as Count_used_colors, but use a block screen memory instead of picture data.

Used to count colors in the loading screen.

References Get_Screen_pixel().

◆ Count_used_colors_area()

word Count_used_colors_area ( dword usage,
word  start_x,
word  start_y,
word  width,
word  height 
)

Same as Count_used_colors, but for a given rectangle in the picture only.

Used bu the C64 block constraint checker.

References T_Document::image_width, Main, and Main_screen.

◆ Get_current_palette()

const T_Components * Get_current_palette ( void  )

References Current_palette.

Referenced by Error_function().

◆ Set_palette()

◆ Set_color()

void Set_color ( byte  color,
byte  red,
byte  green,
byte  blue 
)

References Current_palette, and GFX2_SetPalette().

Referenced by Button_Skins().

◆ Wait_end_of_click()

◆ Clear_current_image_with_stencil()

◆ Clear_current_image()

◆ Init_chrono()

void Init_chrono ( dword  delay)

◆ Pixel_in_brush()

void Pixel_in_brush ( word  x,
word  y,
byte  color 
)

◆ Read_pixel_from_brush()

byte Read_pixel_from_brush ( word  x,
word  y 
)

◆ Copy_part_of_image_to_another()

void Copy_part_of_image_to_another ( byte source,
word  source_x,
word  source_y,
word  width,
word  height,
word  source_width,
byte dest,
word  dest_x,
word  dest_y,
word  destination_width 
)

◆ Read_pixel_from_spare_screen()

◆ Rotate_90_deg_lowlevel()

void Rotate_90_deg_lowlevel ( byte source,
byte dest,
short  width,
short  height 
)

Rotate a pixel buffer by 90 degrees, clockwise.

Parameters
sourceSource pixel buffer.
destDestination pixel buffer.
widthWidth of the original buffer (height of the destination one).
heightHeight of the original buffer (width of the destination one).

Referenced by Button_Transform_menu(), and Rotate_90_deg().

◆ Rotate_270_deg_lowlevel()

void Rotate_270_deg_lowlevel ( byte source,
byte dest,
short  width,
short  height 
)

Rotate a pixel buffer by 90 degrees, counter-clockwise.

Parameters
sourceSource pixel buffer.
destDestination pixel buffer.
widthWidth of the original buffer (height of the destination one).
heightHeight of the original buffer (width of the destination one).

Referenced by Button_Transform_menu().

◆ Remap_general_lowlevel()

void Remap_general_lowlevel ( byte conversion_table,
byte in_buffer,
byte out_buffer,
short  width,
short  height,
short  buffer_width 
)

◆ Copy_image_to_brush()

void Copy_image_to_brush ( short  start_x,
short  start_y,
short  Brush_width,
short  Brush_height,
word  image_width 
)

◆ Read_pixel_from_feedback_screen()

◆ Round_div()

dword Round_div ( dword  numerator,
dword  divisor 
)

◆ Effect_sieve()

byte Effect_sieve ( word  x,
word  y 
)

References Sieve, Sieve_height, and Sieve_width.

Referenced by Display_pixel().

◆ Replace_colors_within_limits()

◆ Read_pixel_from_backup_screen()

byte Read_pixel_from_backup_screen ( word  x,
word  y 
)

◆ Effect_interpolated_colorize()

byte Effect_interpolated_colorize ( word  x,
word  y,
byte  color 
)

◆ Effect_additive_colorize()

byte Effect_additive_colorize ( word  x,
word  y,
byte  color 
)

◆ Effect_substractive_colorize()

byte Effect_substractive_colorize ( word  x,
word  y,
byte  color 
)

◆ Effect_alpha_colorize()

byte Effect_alpha_colorize ( word  x,
word  y,
byte  color 
)

◆ Check_timer()

void Check_timer ( void  )

◆ Flip_Y_lowlevel()

void Flip_Y_lowlevel ( byte src,
short  width,
short  height 
)

Inverts a pixel buffer, according to a horizontal axis.

Parameters
srcPointer to the pixel buffer to process.
widthWidth of the buffer.
heightHeight of the buffer.

Referenced by Button_Brush_FX(), Button_Transform_menu(), Main_handler(), and Rotate_180_deg_lowlevel().

◆ Flip_X_lowlevel()

void Flip_X_lowlevel ( byte src,
short  width,
short  height 
)

Inverts a pixel buffer, according to a vertical axis.

Parameters
srcPointer to the pixel buffer to process.
widthWidth of the buffer.
heightHeight of the buffer.

Referenced by Button_Brush_FX(), Button_Transform_menu(), Main_handler(), and Rotate_180_deg_lowlevel().

◆ Rotate_180_deg_lowlevel()

void Rotate_180_deg_lowlevel ( byte src,
short  width,
short  height 
)

Rotate a pixel buffer by 180 degrees.

Parameters
srcThe pixel buffer (source and destination).
widthWidth of the buffer.
heightHeight of the buffer.

References Flip_X_lowlevel(), and Flip_Y_lowlevel().

Referenced by Button_Brush_FX(), Button_Transform_menu(), and Main_handler().

◆ Rescale()

void Rescale ( byte src_buffer,
short  src_width,
short  src_height,
byte dst_buffer,
short  dst_width,
short  dst_height,
short  x_flipped,
short  y_flipped 
)

Copies an image to another, rescaling it and optionally flipping it.

Parameters
src_bufferOriginal image (address of first byte)
src_widthOriginal image's width in pixels
src_heightOriginal image's height in pixels
dst_bufferDestination image (address of first byte)
dst_widthDestination image's width in pixels
dst_heightDestination image's height in pixels
x_flippedBoolean, true to flip the image horizontally
y_flippedBoolean, true to flip the image vertically

Referenced by Button_Transform_menu(), Store_brush(), and Stretch_brush().

◆ Scroll_picture()

void Scroll_picture ( byte main_src,
byte main_dest,
short  x_offset,
short  y_offset 
)

◆ Zoom_a_line()

◆ Round()

◆ Round_div_max()

short Round_div_max ( short  numerator,
short  divisor 
)

Referenced by Pre_load().

◆ Min()

◆ Max()

◆ Fround()

double Fround ( double  n,
unsigned  d 
)

Referenced by Readline_ex_unicode().

◆ Mode_label()

const char * Mode_label ( int  mode)

References mode, and Video_mode.

Referenced by Convert_videomode_arg(), Display_syntax(), and Save_INI().

◆ Convert_videomode_arg()

int Convert_videomode_arg ( const char *  argument)

References Mode_label(), Nb_video_modes, and Video_mode.

Referenced by Init_program(), and Load_INI().

Variable Documentation

◆ Current_palette

T_Palette Current_palette
static