GrafX2 2.9.3227
The ultimate 256-color painting program
misc.h File Reference

Miscellanous unsorted functions. More...

#include <stdio.h>
#include "struct.h"
#include "global.h"
+ Include dependency graph for misc.h:
+ This graph shows which files directly or indirectly include this file:

Macros

#define SWAP_BYTES(a, b)   { byte c=a; a=b; b=c;}
 
#define SWAP_WORDS(a, b)   { word c=a; a=b; b=c;}
 
#define SWAP_DWORDS(a, b)   { dword c=a; a=b; b=c;}
 
#define SWAP_SHORTS(a, b)   { short c=a; a=b; b=c;}
 
#define SWAP_FLOATS(a, b)   { float c=a; a=b; b=c;}
 
#define SWAP_PBYTES(a, b)   { byte * c=a; a=b; b=c;}
 
#define Num2str(a, b, c)   snprintf(b,sizeof(b),"%*lu",(int)c,(unsigned long)(a))
 
#define Dec2str(a, b, c)   sprintf(b,"%.*f",c,(double)(a))
 

Functions

void Copy_image_to_brush (short start_x, short start_y, short Brush_width, short Brush_height, word image_width)
 
void Remap_general_lowlevel (byte *conversion_table, byte *in_buffer, byte *out_buffer, short width, short height, short buffer_width)
 
void Scroll_picture (byte *main_src, byte *main_dest, short x_offset, short y_offset)
 
void Wait_end_of_click (void)
 
void Set_color (byte color, byte red, byte green, byte blue)
 
const T_ComponentsGet_current_palette (void)
 
void Set_palette (T_Palette palette)
 
void Clear_current_image (byte color)
 
void Clear_current_image_with_stencil (byte color, byte *stencil)
 
dword Round_div (dword numerator, dword divisor)
 
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_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...
 
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...
 
void Pixel_in_brush (word x, word y, byte color)
 
byte Read_pixel_from_spare_screen (word x, word y)
 
byte Read_pixel_from_backup_screen (word x, word y)
 
byte Read_pixel_from_feedback_screen (word x, word y)
 
byte Read_pixel_from_brush (word x, word y)
 
void Init_chrono (dword delay)
 
void Check_timer (void)
 
void Replace_colors_within_limits (byte *replace_table)
 
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)
 
byte Effect_sieve (word x, word y)
 
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_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 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 Zoom_a_line (byte *original_line, byte *zoomed_line, word factor, word width)
 
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)
 
short Round (float value)
 
short Round_div_max (short numerator, short divisor)
 
double Fround (double n, unsigned d)
 
int Min (int a, int b)
 
int Max (int a, int b)
 
const char * Mode_label (int mode)
 
int Convert_videomode_arg (const char *argument)
 

Variables

GFX2_GLOBAL byte Timer_state
 
GFX2_GLOBAL dword Timer_delay
 
GFX2_GLOBAL dword Timer_start
 

Detailed Description

Miscellanous unsorted functions.

Macro Definition Documentation

◆ SWAP_BYTES

#define SWAP_BYTES (   a,
 
)    { byte c=a; a=b; b=c;}

◆ SWAP_WORDS

#define SWAP_WORDS (   a,
 
)    { word c=a; a=b; b=c;}

◆ SWAP_DWORDS

#define SWAP_DWORDS (   a,
 
)    { dword c=a; a=b; b=c;}

◆ SWAP_SHORTS

#define SWAP_SHORTS (   a,
 
)    { short c=a; a=b; b=c;}

◆ SWAP_FLOATS

#define SWAP_FLOATS (   a,
 
)    { float c=a; a=b; b=c;}

◆ SWAP_PBYTES

#define SWAP_PBYTES (   a,
 
)    { byte * c=a; a=b; b=c;}

◆ Num2str

#define Num2str (   a,
  b,
 
)    snprintf(b,sizeof(b),"%*lu",(int)c,(unsigned long)(a))

◆ Dec2str

#define Dec2str (   a,
  b,
 
)    sprintf(b,"%.*f",c,(double)(a))

Function Documentation

◆ Copy_image_to_brush()

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

◆ Remap_general_lowlevel()

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

◆ Scroll_picture()

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

◆ Wait_end_of_click()

◆ Set_color()

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

References Current_palette, and GFX2_SetPalette().

Referenced by Button_Skins().

◆ Get_current_palette()

const T_Components * Get_current_palette ( void  )

References Current_palette.

Referenced by Error_function().

◆ Set_palette()

◆ Clear_current_image()

◆ Clear_current_image_with_stencil()

◆ Round_div()

dword Round_div ( dword  numerator,
dword  divisor 
)

◆ 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_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.

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

◆ Pixel_in_brush()

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

◆ Read_pixel_from_spare_screen()

◆ Read_pixel_from_backup_screen()

byte Read_pixel_from_backup_screen ( word  x,
word  y 
)

◆ Read_pixel_from_feedback_screen()

◆ Read_pixel_from_brush()

byte Read_pixel_from_brush ( word  x,
word  y 
)

◆ Init_chrono()

void Init_chrono ( dword  delay)

◆ Check_timer()

void Check_timer ( void  )

◆ Replace_colors_within_limits()

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

◆ Effect_sieve()

byte Effect_sieve ( word  x,
word  y 
)

References Sieve, Sieve_height, and Sieve_width.

Referenced by Display_pixel().

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

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

◆ Zoom_a_line()

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

◆ Round()

◆ Round_div_max()

short Round_div_max ( short  numerator,
short  divisor 
)

Referenced by Pre_load().

◆ Fround()

double Fround ( double  n,
unsigned  d 
)

Referenced by Readline_ex_unicode().

◆ Min()

◆ Max()

◆ 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

◆ Timer_state

GFX2_GLOBAL byte Timer_state

Referenced by Button_Load_or_Save(), and Check_timer().

◆ Timer_delay

GFX2_GLOBAL dword Timer_delay

Referenced by Check_timer(), and Init_chrono().

◆ Timer_start

GFX2_GLOBAL dword Timer_start

Referenced by Check_timer(), and Init_chrono().