GrafX2 2.9.3227
The ultimate 256-color painting program
|
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "global.h"
#include "graph.h"
#include "misc.h"
#include "errors.h"
#include "windows.h"
#include "screen.h"
#include "brush.h"
#include "tiles.h"
Macros | |
#define | NAN (-1.0e20F) |
#define | isnan(x) ((x)==NAN) |
Functions | |
void | Compute_clipped_dimensions (short *x, short *y, short *width, short *height) |
void | Compute_clipped_dimensions_zoom (short *x, short *y, short *width, short *height) |
void | Display_paintbrush (short x, short y, byte color) |
Display the paintbrush (preview : on screen only) More... | |
void | Draw_paintbrush (short x, short y, byte color) |
Draw the paintbrush in the image buffer. More... | |
byte | Realloc_brush (word new_brush_width, word new_brush_height, byte *new_brush, byte **old_brush) |
Allocates memory for a brush size change. More... | |
void | Hide_paintbrush (short x, short y) |
void | Capture_brush (short start_x, short start_y, short end_x, short end_y, short clear) |
Gets the brush from the picture. More... | |
void | Rotate_90_deg (void) |
Rotates the brush to the right. More... | |
void | Remap_brush (void) |
void | Outline_brush (void) |
Outline the brush, add 1 foreground-colored pixel on the edges. More... | |
void | Nibble_brush (void) |
Nibble the brush, remove 1 pixel on the edges and make it transparent (ie filled with back color). More... | |
void | Capture_brush_with_lasso (int vertices, short *points, short clear) |
Get brush from picture according to a freehand form. More... | |
void | Stretch_brush (short x1, short y1, short x2, short y2) |
Stretch the brush to fit the given rectangle. More... | |
void | Stretch_brush_preview (short x1, short y1, short x2, short y2) |
Stretch the brush to fit the given rectangle. More... | |
int | Min4 (long int a, long int b, long int c, long int d) |
Returns the minimum of 4 integers. More... | |
void | Pixel_in_distort_buffer (word x_pos, word y_pos, byte color) |
Draw a pixel in the target buffer. No clipping. More... | |
int | Max4 (long int a, long int b, long int c, long int d) |
Returns the maximum of 4 integers. More... | |
void | Draw_brush_linear_distort (unsigned long int tex_min_x, unsigned long int tex_min_y, unsigned long int tex_max_x, unsigned long int tex_max_y, long int x1, long int y1, long int x2, long int y2, long int x3, long int y3, long int x4, long int y4) |
void | Distort_brush_preview (short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4) |
Draws a distorted version of the brush, mapped over the given quad (picture coordinates). More... | |
void | Distort_brush (short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4) |
Modifies the current brush, mapping it over the given quad. More... | |
void | Interpolate_texture (int start_x, int start_y, int xt1, int yt1, int end_x, int end_y, int xt2, int yt2, int height) |
void | Compute_quad_texture (byte *texture, int texture_width, int x1, int y1, int xt1, int yt1, int x2, int y2, int xt2, int yt2, int x3, int y3, int xt3, int yt3, int x4, int y4, int xt4, int yt4, byte *buffer, int width, int height) |
void | Scale2x (byte **bitmap, int *width, int *height) |
void | Begin_brush_rotation (void) |
void | End_brush_rotation (void) |
void | Rotate_brush (float angle) |
Rotates the brush to the right from the given angle. More... | |
void | Draw_quad_texture_preview (byte *texture, int texture_width, int x1, int y1, int xt1, int yt1, int x2, int y2, int xt2, int yt2, int x3, int y3, int xt3, int yt3, int x4, int y4, int xt4, int yt4) |
void | Rotate_brush_preview (float angle) |
Stretch the brush to fit the given rectangle. More... | |
Variables | |
static byte * | Brush_rotate_buffer |
static int | Brush_rotate_width |
static int | Brush_rotate_height |
static Func_pixel | Pixel_for_distort |
static byte * | Distort_source |
static byte * | Distort_buffer |
static short | Distort_buffer_width |
float * | ScanY_Xt [2] |
float * | ScanY_Yt [2] |
float * | ScanY_X [2] |
#define NAN (-1.0e20F) |
#define isnan | ( | x | ) | ((x)==NAN) |
void Compute_clipped_dimensions | ( | short * | x, |
short * | y, | ||
short * | width, | ||
short * | height | ||
) |
References Limit_bottom, Limit_left, Limit_right, and Limit_top.
Referenced by Display_paintbrush(), Draw_paintbrush(), and Hide_paintbrush().
void Compute_clipped_dimensions_zoom | ( | short * | x, |
short * | y, | ||
short * | width, | ||
short * | height | ||
) |
References Limit_bottom_zoom, Limit_left_zoom, Limit_right_zoom, and Limit_top_zoom.
Referenced by Display_paintbrush(), Draw_paintbrush(), and Hide_paintbrush().
void Display_paintbrush | ( | short | x, |
short | y, | ||
byte | color | ||
) |
Display the paintbrush (preview : on screen only)
References Back_color, T_Document::backups, Brush, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_width, Compute_clipped_dimensions(), Compute_clipped_dimensions_zoom(), T_Document::current_layer, Display_brush_color, Display_brush_color_zoom, Display_brush_mono, Display_brush_mono_zoom, Fore_color, Horizontal_line_buffer, T_Page::Image_mode, IMAGE_MODE_C64FLI, IMAGE_MODE_MODE5, IMAGE_MODE_RASTER, Limit_bottom, Limit_left, Limit_right, Limit_top, T_Document::magnifier_factor, T_Document::magnifier_mode, T_Document::magnifier_offset_X, T_Document::magnifier_offset_Y, Main, MAX_PAINTBRUSH_SIZE, Menu_Y, Mouse_K, T_Document::offset_X, T_Document::offset_Y, T_List_of_pages::Pages, Paintbrush_height, Paintbrush_offset_X, Paintbrush_offset_Y, Paintbrush_shape, PAINTBRUSH_SHAPE_COLOR_BRUSH, PAINTBRUSH_SHAPE_MONO_BRUSH, PAINTBRUSH_SHAPE_NONE, PAINTBRUSH_SHAPE_POINT, Paintbrush_sprite, Paintbrush_width, Paintbrush_X, Paintbrush_Y, Pixel_preview, Update_part_of_screen(), and T_Document::X_zoom.
Referenced by Display_cursor().
void Draw_paintbrush | ( | short | x, |
short | y, | ||
byte | color | ||
) |
Draw the paintbrush in the image buffer.
References Back_color, T_Document::backups, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_width, Clear_brush, Clear_brush_scaled, Compute_clipped_dimensions(), Compute_clipped_dimensions_zoom(), Copy_part_of_image_to_another(), T_Document::current_layer, Display_pixel(), Effect_function, Horizontal_line_buffer, T_Document::image_height, T_Page::Image_mode, IMAGE_MODE_C64FLI, IMAGE_MODE_MODE5, IMAGE_MODE_RASTER, T_Document::image_width, T_Document::magnifier_factor, T_Document::magnifier_mode, T_Document::magnifier_offset_X, T_Document::magnifier_offset_Y, Main, Main_screen, Mask_mode, Mask_table, MAX_PAINTBRUSH_SIZE, Menu_Y, T_Document::offset_X, T_Document::offset_Y, T_List_of_pages::Pages, Paintbrush_height, Paintbrush_offset_X, Paintbrush_offset_Y, Paintbrush_shape, PAINTBRUSH_SHAPE_COLOR_BRUSH, PAINTBRUSH_SHAPE_MONO_BRUSH, PAINTBRUSH_SHAPE_NONE, PAINTBRUSH_SHAPE_POINT, Paintbrush_sprite, Paintbrush_width, Pixel_in_current_screen, Read_pixel_from_brush(), Read_pixel_from_current_layer(), Read_pixel_from_current_screen(), Read_pixel_from_spare_screen(), Shade_table, Shade_table_left, Smear_brush, Smear_brush_width, Smear_max_X, Smear_max_Y, Smear_min_X, Smear_min_Y, Smear_mode, Smear_start, Stencil, Stencil_mode, Update_part_of_screen(), and T_Document::X_zoom.
Referenced by Airbrush(), Centered_lines_12_7(), Freehand_mode1_1_0(), Freehand_mode1_2_0(), Freehand_mode2_1_0(), Freehand_mode2_1_2(), Freehand_mode2_2_0(), Freehand_mode2_2_2(), Freehand_mode3_1_0(), Freehand_Mode3_2_0(), K_line_0_6(), Line_0_5(), Pixel_figure_permanent(), and Polyform_12_0().
byte Realloc_brush | ( | word | new_brush_width, |
word | new_brush_height, | ||
byte * | new_brush, | ||
byte ** | old_brush | ||
) |
Allocates memory for a brush size change.
This function can return the old brush pixels which can then be used by the caller to fill the new brush. Data is not automatically copied or converted from the old brush to the new one here.
new_brush_width | new width of the brush |
new_brush_height | new height of the brush |
new_brush | Optionally, you can provide an already allocated new brush - otherwise, this function performs the allocation. |
old_brush | If the caller passes NULL, this function will free the old pixel data. If the caller provides the address of a (free) byte pointer, the function will make it point to the original pixel data, in this case it will be the caller's responsibility to free() it (after transferring pixels to Brush, usually). |
References Back_color, Brush, Brush_height, Brush_original_back_color, Brush_original_pixels, Brush_width, Error, MAX_PAINTBRUSH_SIZE, NULL, Smear_brush, Smear_brush_height, and Smear_brush_width.
Referenced by Button_Sieve_menu(), Button_Text(), Capture_brush(), Capture_brush_with_lasso(), Distort_brush(), Load_image(), Nibble_brush(), Outline_brush(), Restore_brush(), Rotate_90_deg(), Rotate_brush(), and Stretch_brush().
void Hide_paintbrush | ( | short | x, |
short | y | ||
) |
References Back_color, Brush, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_width, Clear_brush, Clear_brush_scaled, Compute_clipped_dimensions(), Compute_clipped_dimensions_zoom(), Horizontal_line_buffer, T_Document::image_width, Limit_bottom, Limit_left, Limit_right, Limit_top, T_Document::magnifier_factor, T_Document::magnifier_mode, T_Document::magnifier_offset_X, T_Document::magnifier_offset_Y, Main, Menu_Y, Mouse_K, T_Document::offset_X, T_Document::offset_Y, Paintbrush_height, Paintbrush_offset_X, Paintbrush_offset_Y, Paintbrush_shape, PAINTBRUSH_SHAPE_COLOR_BRUSH, PAINTBRUSH_SHAPE_MONO_BRUSH, PAINTBRUSH_SHAPE_POINT, Paintbrush_sprite, Paintbrush_width, Paintbrush_X, Paintbrush_Y, Pixel_preview, Read_pixel_from_current_screen(), Update_part_of_screen(), and T_Document::X_zoom.
Referenced by Hide_cursor().
void Capture_brush | ( | short | start_x, |
short | start_y, | ||
short | end_x, | ||
short | end_y, | ||
short | clear | ||
) |
Gets the brush from the picture.
start_x | left edge coordinate in the picture |
start_y | upper edge coordinate in the picture |
end_x | right edge coordinate in the picture |
end_y | bottom edge coordinate in the picture |
clear | If 1, the area is also cleared from the picture. |
References Back_color, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_original_palette, Brush_width, Copy_image_to_brush(), T_Document::image_height, T_Document::image_width, Main, NULL, T_Document::palette, Pixel_in_current_screen_with_preview, Realloc_brush(), Remap_brush(), Tilemap_draw(), T_Document::tilemap_mode, Tiling_offset_X, Tiling_offset_Y, and Update_part_of_screen().
Referenced by Brush_0_5(), and Init_program().
void Rotate_90_deg | ( | void | ) |
Rotates the brush to the right.
References Brush, Brush_colormap, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_original_pixels, Brush_width, Error, NULL, Realloc_brush(), Remap_general_lowlevel(), and Rotate_90_deg_lowlevel().
Referenced by Button_Brush_FX(), and Main_handler().
void Remap_brush | ( | void | ) |
References Back_color, Best_color_perceptual_except(), Brush, Brush_colormap, Brush_height, Brush_original_palette, Brush_original_pixels, Brush_width, Main, T_Document::palette, and Remap_general_lowlevel().
Referenced by Button_Brush_FX(), Button_Sieve_menu(), Button_Text(), Capture_brush(), Get_colors_from_brush(), Load_image(), and Main_handler().
void Outline_brush | ( | void | ) |
Outline the brush, add 1 foreground-colored pixel on the edges.
Edges are detected considering the backcolor as transparent.
References Back_color, Brush, Brush_colormap, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_original_palette, Brush_original_pixels, Brush_width, Copy_part_of_image_to_another(), Error, Fore_color, Main, NULL, T_Document::palette, Pixel_in_brush(), Realloc_brush(), and SWAP_PBYTES.
Referenced by Button_Brush_FX(), and Main_handler().
void Nibble_brush | ( | void | ) |
Nibble the brush, remove 1 pixel on the edges and make it transparent (ie filled with back color).
Edges are detected considering the backcolor as transparent.
References Back_color, Brush, Brush_colormap, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_original_palette, Brush_original_pixels, Brush_width, Copy_part_of_image_to_another(), Error, Main, NULL, T_Document::palette, Pixel_in_brush(), Realloc_brush(), and SWAP_PBYTES.
Referenced by Button_Brush_FX(), and Main_handler().
void Capture_brush_with_lasso | ( | int | vertices, |
short * | points, | ||
short | clear | ||
) |
Get brush from picture according to a freehand form.
vertices | number of points in the freehand form |
points | array of points coordinates |
clear | If set to 1, the captured area is also cleared from the picture. |
References Back_color, Brush, Brush_colormap, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_original_palette, Brush_original_pixels, Brush_width, Draw_line_general(), Error, T_Document::image_height, T_Document::image_width, Limit_bottom, Limit_left, Limit_right, Limit_top, Main, NULL, T_Document::palette, Pixel_figure_in_brush(), Pixel_in_brush(), Pixel_in_current_screen_with_preview, Polyfill_general(), Read_pixel_from_brush(), Read_pixel_from_current_layer(), Realloc_brush(), Set_Pixel_figure(), Tilemap_draw(), T_Document::tilemap_mode, Tiling_offset_X, Tiling_offset_Y, Update_part_of_screen(), and xor_lut.
Referenced by Polybrush_12_8().
void Stretch_brush | ( | short | x1, |
short | y1, | ||
short | x2, | ||
short | y2 | ||
) |
Stretch the brush to fit the given rectangle.
References Brush, Brush_colormap, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_original_pixels, Brush_width, Error, NULL, Realloc_brush(), Remap_general_lowlevel(), and Rescale().
Referenced by Main_handler(), and Stretch_brush_2_7().
void Stretch_brush_preview | ( | short | x1, |
short | y1, | ||
short | x2, | ||
short | y2 | ||
) |
Stretch the brush to fit the given rectangle.
Uses fast approximation for the preview while drawing the rectangle on screen.
References Back_color, Brush_height, Brush_width, Limit_left, Limit_top, Limit_visible_bottom, Limit_visible_right, Max(), Min(), Pixel_preview, Read_pixel_from_brush(), and Update_part_of_screen().
Referenced by Stretch_brush_0_7(), and Stretch_brush_1_7().
int Min4 | ( | long int | a, |
long int | b, | ||
long int | c, | ||
long int | d | ||
) |
Returns the minimum of 4 integers.
Referenced by Distort_brush(), and Draw_brush_linear_distort().
Draw a pixel in the target buffer. No clipping.
References Distort_buffer, and Distort_buffer_width.
Referenced by Distort_brush().
int Max4 | ( | long int | a, |
long int | b, | ||
long int | c, | ||
long int | d | ||
) |
Returns the maximum of 4 integers.
Referenced by Distort_brush(), and Draw_brush_linear_distort().
void Draw_brush_linear_distort | ( | unsigned long int | tex_min_x, |
unsigned long int | tex_min_y, | ||
unsigned long int | tex_max_x, | ||
unsigned long int | tex_max_y, | ||
long int | x1, | ||
long int | y1, | ||
long int | x2, | ||
long int | y2, | ||
long int | x3, | ||
long int | y3, | ||
long int | x4, | ||
long int | y4 | ||
) |
References Back_color, Brush_width, Distort_source, Draw_brush_linear_distort(), Max4(), Min4(), and Pixel_for_distort.
Referenced by Distort_brush(), Distort_brush_preview(), and Draw_brush_linear_distort().
void Distort_brush_preview | ( | short | x1, |
short | y1, | ||
short | x2, | ||
short | y2, | ||
short | x3, | ||
short | y3, | ||
short | x4, | ||
short | y4 | ||
) |
Draws a distorted version of the brush, mapped over the given quad (picture coordinates).
Remap the brush palette to the nearest color in the picture one.
References Brush, Brush_height, Brush_width, Distort_source, Draw_brush_linear_distort(), Pixel_figure_preview(), and Pixel_for_distort.
Referenced by Distort_brush_1_0(), and Distort_brush_1_9().
void Distort_brush | ( | short | x1, |
short | y1, | ||
short | x2, | ||
short | y2, | ||
short | x3, | ||
short | y3, | ||
short | x4, | ||
short | y4 | ||
) |
Modifies the current brush, mapping it over the given quad.
Replace the brush by a distorted version of itself.
References Back_color, Brush, Brush_colormap, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_original_pixels, Brush_width, Distort_buffer, Distort_buffer_width, Distort_source, Draw_brush_linear_distort(), Error, Max(), Max4(), Min4(), NULL, Pixel_for_distort, Pixel_in_distort_buffer(), Realloc_brush(), and Remap_general_lowlevel().
Referenced by Distort_brush_2_8().
void Interpolate_texture | ( | int | start_x, |
int | start_y, | ||
int | xt1, | ||
int | yt1, | ||
int | end_x, | ||
int | end_y, | ||
int | xt2, | ||
int | yt2, | ||
int | height | ||
) |
References isnan, ScanY_X, ScanY_Xt, and ScanY_Yt.
Referenced by Compute_quad_texture(), and Draw_quad_texture_preview().
void Compute_quad_texture | ( | byte * | texture, |
int | texture_width, | ||
int | x1, | ||
int | y1, | ||
int | xt1, | ||
int | yt1, | ||
int | x2, | ||
int | y2, | ||
int | xt2, | ||
int | yt2, | ||
int | x3, | ||
int | y3, | ||
int | xt3, | ||
int | yt3, | ||
int | x4, | ||
int | y4, | ||
int | xt4, | ||
int | yt4, | ||
byte * | buffer, | ||
int | width, | ||
int | height | ||
) |
References Back_color, Interpolate_texture(), Min(), NAN, NULL, Round(), ScanY_X, ScanY_Xt, and ScanY_Yt.
Referenced by Rotate_brush().
void Scale2x | ( | byte ** | bitmap, |
int * | width, | ||
int * | height | ||
) |
Referenced by Begin_brush_rotation().
void Begin_brush_rotation | ( | void | ) |
References Brush_height, Brush_original_pixels, Brush_rotate_buffer, Brush_rotate_height, Brush_rotate_width, Brush_width, and Scale2x().
Referenced by Start_operation_stack().
void End_brush_rotation | ( | void | ) |
References Brush_original_pixels, Brush_rotate_buffer, and NULL.
Referenced by Start_operation_stack().
void Rotate_brush | ( | float | angle | ) |
Rotates the brush to the right from the given angle.
References Brush, Brush_colormap, Brush_height, Brush_offset_X, Brush_offset_Y, Brush_original_pixels, Brush_rotate_buffer, Brush_rotate_height, Brush_rotate_width, Brush_width, Compute_quad_texture(), Error, Max(), Min(), NULL, Realloc_brush(), Remap_general_lowlevel(), and Transform_point().
Referenced by Rotate_brush_2_5().
void Draw_quad_texture_preview | ( | byte * | texture, |
int | texture_width, | ||
int | x1, | ||
int | y1, | ||
int | xt1, | ||
int | yt1, | ||
int | x2, | ||
int | y2, | ||
int | xt2, | ||
int | yt2, | ||
int | x3, | ||
int | y3, | ||
int | xt3, | ||
int | yt3, | ||
int | x4, | ||
int | y4, | ||
int | xt4, | ||
int | yt4 | ||
) |
References Back_color, Brush_colormap, Interpolate_texture(), Limit_bottom, Limit_left, Limit_right, Limit_top, Max(), Min(), NAN, NULL, Pixel_preview, Round(), ScanY_X, ScanY_Xt, and ScanY_Yt.
Referenced by Rotate_brush_preview().
void Rotate_brush_preview | ( | float | angle | ) |
Stretch the brush to fit the given rectangle.
Uses fast approximation for the preview while changing the angle.
References Brush_height, Brush_rotate_buffer, Brush_rotate_height, Brush_rotate_width, Brush_rotation_center_X, Brush_rotation_center_Y, Brush_width, Draw_quad_texture_preview(), Max(), Min(), Transform_point(), and Update_part_of_screen().
Referenced by Rotate_brush_0_5(), and Rotate_brush_1_5().
|
static |
Referenced by Begin_brush_rotation(), End_brush_rotation(), Rotate_brush(), and Rotate_brush_preview().
|
static |
Referenced by Begin_brush_rotation(), Rotate_brush(), and Rotate_brush_preview().
|
static |
Referenced by Begin_brush_rotation(), Rotate_brush(), and Rotate_brush_preview().
|
static |
Referenced by Distort_brush(), Distort_brush_preview(), and Draw_brush_linear_distort().
|
static |
Referenced by Distort_brush(), Distort_brush_preview(), and Draw_brush_linear_distort().
|
static |
Referenced by Distort_brush(), and Pixel_in_distort_buffer().
|
static |
Referenced by Distort_brush(), and Pixel_in_distort_buffer().
float* ScanY_Xt[2] |
Referenced by Compute_quad_texture(), Draw_quad_texture_preview(), and Interpolate_texture().
float* ScanY_Yt[2] |
Referenced by Compute_quad_texture(), Draw_quad_texture_preview(), and Interpolate_texture().
float* ScanY_X[2] |
Referenced by Compute_quad_texture(), Draw_quad_texture_preview(), and Interpolate_texture().