Converted all files to unix end of lines.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@928 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Adrien Destugues 2009-07-16 12:58:36 +00:00
parent e877292ca2
commit 97c8453dcd
46 changed files with 21383 additions and 21383 deletions

96
help.h
View File

@ -1,48 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file help.h ///@file help.h
/// Functions related to the help browser. The help data is in helpfile.h /// Functions related to the help browser. The help data is in helpfile.h
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef __HELP_H_ #ifndef __HELP_H_
#define __HELP_H_ #define __HELP_H_
/*! /*!
Called to open the help window with the keyboard shortcut. Called to open the help window with the keyboard shortcut.
If the mouse is over a button, its contextual help will be displayed. If the mouse is over a button, its contextual help will be displayed.
Else, the default helpscreen will be shown. Else, the default helpscreen will be shown.
*/ */
void Button_Help(void); void Button_Help(void);
/*! /*!
Displays and runs the "Statistics" window Displays and runs the "Statistics" window
*/ */
void Button_Stats(void); void Button_Stats(void);
/*! /*!
Displays and runs the "Help / About..." window Displays and runs the "Help / About..." window
@param section Number of the help section page to display (equals the button number the mouse was hovering for the contextual help), -1 for the main help page. @param section Number of the help section page to display (equals the button number the mouse was hovering for the contextual help), -1 for the main help page.
@param sub_section Help sub-section title (the page will be scrolled so this title is at the top). @param sub_section Help sub-section title (the page will be scrolled so this title is at the top).
*/ */
void Window_help(int section, const char * sub_section); void Window_help(int section, const char * sub_section);
#endif #endif

4866
helpfile.h

File diff suppressed because it is too large Load Diff

2668
hotkeys.c

File diff suppressed because it is too large Load Diff

84
init.h
View File

@ -1,42 +1,42 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file init.h ///@file init.h
/// Initialization (and some de-initialization) functions. /// Initialization (and some de-initialization) functions.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
T_Gui_skin *Load_graphics(const char * skin_file); T_Gui_skin *Load_graphics(const char * skin_file);
void Init_buttons(void); void Init_buttons(void);
void Init_operations(void); void Init_operations(void);
int Load_CFG(int reload_all); int Load_CFG(int reload_all);
int Save_CFG(void); int Save_CFG(void);
void Set_all_video_modes(void); void Set_all_video_modes(void);
void Set_config_defaults(void); void Set_config_defaults(void);
void Init_sighandler(void); void Init_sighandler(void);
extern char Gui_loading_error_message[512]; extern char Gui_loading_error_message[512];
/// ///
/// Loads a 8x8 monochrome font, the kind used in all menus and screens. /// Loads a 8x8 monochrome font, the kind used in all menus and screens.
/// This function allocates the memory, and returns a pointer to it when /// This function allocates the memory, and returns a pointer to it when
/// successful. /// successful.
/// If an error is encountered, it frees what needs it, prints an error message /// If an error is encountered, it frees what needs it, prints an error message
/// in ::Gui_loading_error_message, and returns NULL. /// in ::Gui_loading_error_message, and returns NULL.
byte * Load_font(const char * font_name); byte * Load_font(const char * font_name);

1300
keyboard.c

File diff suppressed because it is too large Load Diff

View File

@ -1,75 +1,75 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file keyboard.h ///@file keyboard.h
/// Functions to convert bewteen the SDL key formats and the keycode we use /// Functions to convert bewteen the SDL key formats and the keycode we use
/// in grafx2. /// in grafx2.
/// The keycode we're using is generalized to handle mouse and joystick shortcuts /// The keycode we're using is generalized to handle mouse and joystick shortcuts
/// as well. The format can be broken down as: /// as well. The format can be broken down as:
/// - 0x0000 + a number between 0 and SDLK_LAST (about 324) : the SDL "sym" key number. /// - 0x0000 + a number between 0 and SDLK_LAST (about 324) : the SDL "sym" key number.
/// - 0x0000 + SDLK_LAST+1: Mouse middle button. /// - 0x0000 + SDLK_LAST+1: Mouse middle button.
/// - 0x0000 + SDLK_LAST+2: Mouse wheel up. /// - 0x0000 + SDLK_LAST+2: Mouse wheel up.
/// - 0x0000 + SDLK_LAST+3: Mouse wheel down. /// - 0x0000 + SDLK_LAST+3: Mouse wheel down.
/// - 0x0000 + SDLK_LAST+4+B : Joystick button number "B", starting at B=0. /// - 0x0000 + SDLK_LAST+4+B : Joystick button number "B", starting at B=0.
/// - 0x0800 + a number between 0 and 0x7FF: The scancode key number, for keys which have no "sym", such as keys from multimedia keyboards, and "fn" and "Thinkpad" key for a laptop. /// - 0x0800 + a number between 0 and 0x7FF: The scancode key number, for keys which have no "sym", such as keys from multimedia keyboards, and "fn" and "Thinkpad" key for a laptop.
/// Add 0x1000 for the Shift modifier MOD_SHIFT /// Add 0x1000 for the Shift modifier MOD_SHIFT
/// Add 0x2000 for the Control modifier ::MOD_CONTROL /// Add 0x2000 for the Control modifier ::MOD_CONTROL
/// Add 0x4000 for the Alt modifier ::MOD_ALT /// Add 0x4000 for the Alt modifier ::MOD_ALT
/// Add 0x8000 for the "Meta" modifier ::MOD_META (On MacOS X it's the CMD key) /// Add 0x8000 for the "Meta" modifier ::MOD_META (On MacOS X it's the CMD key)
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/*! /*!
Convert an SDL keysym to an ANSI/ASCII character. Convert an SDL keysym to an ANSI/ASCII character.
This is used to type text and numeric values in input boxes. This is used to type text and numeric values in input boxes.
@param keysym SDL symbol to convert @param keysym SDL symbol to convert
*/ */
word Keysym_to_ANSI(SDL_keysym keysym); word Keysym_to_ANSI(SDL_keysym keysym);
/*! /*!
Convert an SDL keysym to an internal keycode number. Convert an SDL keysym to an internal keycode number.
This is needed because SDL tends to split the information across the unicode sym, the regular sym, and the raw keycode. This is needed because SDL tends to split the information across the unicode sym, the regular sym, and the raw keycode.
We also need to differenciate 1 (keypad) and 1 (regular keyboard), and some other things. We also need to differenciate 1 (keypad) and 1 (regular keyboard), and some other things.
See the notice at the beginning of keyboard.h for the format of a keycode. See the notice at the beginning of keyboard.h for the format of a keycode.
@param keysym SDL symbol to convert @param keysym SDL symbol to convert
*/ */
word Keysym_to_keycode(SDL_keysym keysym); word Keysym_to_keycode(SDL_keysym keysym);
/*! /*!
Helper function to convert between SDL system and the old coding for PC keycodes. Helper function to convert between SDL system and the old coding for PC keycodes.
This is only used to convert configuration files from the DOS version of This is only used to convert configuration files from the DOS version of
Grafx2, where keyboard codes are in in the IBM PC AT form. Grafx2, where keyboard codes are in in the IBM PC AT form.
@param scancode Scancode to convert @param scancode Scancode to convert
*/ */
word Key_for_scancode(word scancode); word Key_for_scancode(word scancode);
/*! /*!
Returns key name in a string. Used to display them in the helpscreens and in the keymapper window. Returns key name in a string. Used to display them in the helpscreens and in the keymapper window.
@param Key keycode of the key to translate, including modifiers @param Key keycode of the key to translate, including modifiers
*/ */
const char * Key_name(word Key); const char * Key_name(word Key);
/*! /*!
Gets the modifiers in our format from the SDL_Mod information. Gets the modifiers in our format from the SDL_Mod information.
Returns a combination of ::MOD_SHIFT, ::MOD_ALT, ::MOD_CONTROL Returns a combination of ::MOD_SHIFT, ::MOD_ALT, ::MOD_CONTROL
@param mod SDL modifiers state @param mod SDL modifiers state
*/ */
word Key_modifiers(SDLMod mod); word Key_modifiers(SDLMod mod);

View File

@ -1,57 +1,57 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file loadsave.h ///@file loadsave.h
/// Saving and loading different picture formats. /// Saving and loading different picture formats.
/// Also handles showing the preview in fileselectors. /// Also handles showing the preview in fileselectors.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void Pixel_load_in_current_screen(word x_pos,word y_pos,byte color); void Pixel_load_in_current_screen(word x_pos,word y_pos,byte color);
void Pixel_load_in_preview (word x_pos,word y_pos,byte color); void Pixel_load_in_preview (word x_pos,word y_pos,byte color);
void Pixel_load_in_brush (word x_pos,word y_pos,byte color); void Pixel_load_in_brush (word x_pos,word y_pos,byte color);
void Get_full_filename(char * filename, byte is_colorix_format); void Get_full_filename(char * filename, byte is_colorix_format);
/// ///
/// High-level picture loading function. /// High-level picture loading function.
/// Handles loading an image or a brush, or previewing only. /// Handles loading an image or a brush, or previewing only.
/// @param image true if the fileselector is the one for loading images (not brush) /// @param image true if the fileselector is the one for loading images (not brush)
void Load_image(byte image); void Load_image(byte image);
/// ///
/// High-level picture saving function. /// High-level picture saving function.
/// @param image true if the image should be saved (instead of the brush) /// @param image true if the image should be saved (instead of the brush)
void Save_image(byte image); void Save_image(byte image);
/// Data for an image file format. /// Data for an image file format.
typedef struct { typedef struct {
char *Extension; ///< Three-letter file extension char *Extension; ///< Three-letter file extension
Func_action Test; ///< Function which tests if the file is of this format Func_action Test; ///< Function which tests if the file is of this format
Func_action Load; ///< Function which loads an image of this format Func_action Load; ///< Function which loads an image of this format
Func_action Save; ///< Function which saves an image of this format Func_action Save; ///< Function which saves an image of this format
byte Backup_done; ///< Boolean, true if this format saves all the image, and considers it backed up. Set false for formats which only save the palette. byte Backup_done; ///< Boolean, true if this format saves all the image, and considers it backed up. Set false for formats which only save the palette.
byte Comment; ///< This file format allows a text comment byte Comment; ///< This file format allows a text comment
} T_Format; } T_Format;
/// Array of the known file formats /// Array of the known file formats
extern T_Format File_formats[NB_KNOWN_FORMATS]; extern T_Format File_formats[NB_KNOWN_FORMATS];
/// ///
/// Function which attempts to save backups of the images (main and spare), /// Function which attempts to save backups of the images (main and spare),
/// called in case of SIGSEGV. /// called in case of SIGSEGV.
void Image_emergency_backup(void); void Image_emergency_backup(void);

300
misc.h
View File

@ -1,150 +1,150 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file misc.h ///@file misc.h
/// Miscellanous unsorted functions. /// Miscellanous unsorted functions.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void Copy_image_to_brush(short start_x,short start_y,short Brush_width,short Brush_height,word image_width); 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 * buffer,short width,short height,short buffer_width); void Remap_general_lowlevel(byte * conversion_table,byte * buffer,short width,short height,short buffer_width);
void Scroll_picture(short x_offset,short y_offset); void Scroll_picture(short x_offset,short y_offset);
void Wait_end_of_click(void); void Wait_end_of_click(void);
void Set_color(byte color, byte red, byte green, byte blue); void Set_color(byte color, byte red, byte green, byte blue);
void Set_palette(T_Palette palette); void Set_palette(T_Palette palette);
void Palette_256_to_64(T_Palette palette); void Palette_256_to_64(T_Palette palette);
void Palette_64_to_256(T_Palette palette); void Palette_64_to_256(T_Palette palette);
void Hide_current_image(byte color); void Hide_current_image(byte color);
void Hide_current_image_with_stencil(byte color, byte * stencil); void Hide_current_image_with_stencil(byte color, byte * stencil);
void Slider_timer(byte speed); void Slider_timer(byte speed);
dword Round_div(dword numerator,dword divisor); dword Round_div(dword numerator,dword divisor);
word Count_used_colors(dword * usage); word Count_used_colors(dword * usage);
word Count_used_colors_area(dword* usage, word start_x, word start_y, word width, word height); word Count_used_colors_area(dword* usage, word start_x, word start_y, word width, word height);
void Pixel_in_current_screen (word x,word y,byte color); void Pixel_in_current_screen (word x,word y,byte color);
void Pixel_in_brush (word x,word y,byte color); void Pixel_in_brush (word x,word y,byte color);
byte Read_pixel_from_current_screen (word x,word y); byte Read_pixel_from_current_screen (word x,word y);
byte Read_pixel_from_spare_screen(word x,word y); byte Read_pixel_from_spare_screen(word x,word y);
byte Read_pixel_from_backup_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_feedback_screen (word x,word y);
byte Read_pixel_from_brush (word x,word y); byte Read_pixel_from_brush (word x,word y);
void Ellipse_compute_limites(short horizontal_radius,short vertical_radius); void Ellipse_compute_limites(short horizontal_radius,short vertical_radius);
// Calcule les valeurs suivantes en fonction des deux paramètres: // Calcule les valeurs suivantes en fonction des deux paramètres:
// //
// Ellipse_vertical_radius_squared // Ellipse_vertical_radius_squared
// Ellipse_horizontal_radius_squared // Ellipse_horizontal_radius_squared
// Ellipse_Limit_High // Ellipse_Limit_High
// Ellipse_Limit_Low // Ellipse_Limit_Low
byte Pixel_in_ellipse(void); byte Pixel_in_ellipse(void);
// Indique si le pixel se trouvant à Ellipse_cursor_X pixels // Indique si le pixel se trouvant à Ellipse_cursor_X pixels
// (Ellipse_cursor_X>0 = à droite, Ellipse_cursor_X<0 = à gauche) et à // (Ellipse_cursor_X>0 = à droite, Ellipse_cursor_X<0 = à gauche) et à
// Ellipse_cursor_Y pixels (Ellipse_cursor_Y>0 = en bas, // Ellipse_cursor_Y pixels (Ellipse_cursor_Y>0 = en bas,
// Ellipse_cursor_Y<0 = en haut) du centre se trouve dans l'ellipse en // Ellipse_cursor_Y<0 = en haut) du centre se trouve dans l'ellipse en
// cours. // cours.
byte Pixel_in_circle(void); byte Pixel_in_circle(void);
// Indique si le pixel se trouvant à Circle_cursor_X pixels // Indique si le pixel se trouvant à Circle_cursor_X pixels
// (Circle_cursor_X>0 = à droite, Circle_cursor_X<0 = à gauche) et à // (Circle_cursor_X>0 = à droite, Circle_cursor_X<0 = à gauche) et à
// Circle_cursor_Y pixels (Circle_cursor_Y>0 = en bas, // Circle_cursor_Y pixels (Circle_cursor_Y>0 = en bas,
// Circle_cursor_Y<0 = en haut) du centre se trouve dans le cercle en // Circle_cursor_Y<0 = en haut) du centre se trouve dans le cercle en
// cours. // cours.
// Gestion du chrono dans les fileselects // Gestion du chrono dans les fileselects
void Init_chrono(dword delay); void Init_chrono(dword delay);
void Check_timer(void); void Check_timer(void);
void Replace_a_color(byte old_color, byte New_color); void Replace_a_color(byte old_color, byte New_color);
void Replace_colors_within_limits(byte * replace_table); void Replace_colors_within_limits(byte * replace_table);
byte Effect_interpolated_colorize (word x,word y,byte color); byte Effect_interpolated_colorize (word x,word y,byte color);
byte Effect_additive_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_substractive_colorize(word x,word y,byte color);
byte Effect_sieve(word x,word y); byte Effect_sieve(word x,word y);
/// ///
/// Inverts a pixel buffer, according to a horizontal axis. /// Inverts a pixel buffer, according to a horizontal axis.
/// @param src Pointer to the pixel buffer to process. /// @param src Pointer to the pixel buffer to process.
/// @param width Width of the buffer. /// @param width Width of the buffer.
/// @param height Height of the buffer. /// @param height Height of the buffer.
void Flip_Y_lowlevel(byte *src, short width, short height); void Flip_Y_lowlevel(byte *src, short width, short height);
/// ///
/// Inverts a pixel buffer, according to a vertical axis. /// Inverts a pixel buffer, according to a vertical axis.
/// @param src Pointer to the pixel buffer to process. /// @param src Pointer to the pixel buffer to process.
/// @param width Width of the buffer. /// @param width Width of the buffer.
/// @param height Height of the buffer. /// @param height Height of the buffer.
void Flip_X_lowlevel(byte *src, short width, short height); void Flip_X_lowlevel(byte *src, short width, short height);
/// ///
/// Rotate a pixel buffer by 90 degrees, clockwise. /// Rotate a pixel buffer by 90 degrees, clockwise.
/// @param source Source pixel buffer. /// @param source Source pixel buffer.
/// @param dest Destination pixel buffer. /// @param dest Destination pixel buffer.
/// @param width Width of the original buffer (height of the destination one). /// @param width Width of the original buffer (height of the destination one).
/// @param height Height of the original buffer (width of the destination one). /// @param height Height of the original buffer (width of the destination one).
void Rotate_90_deg_lowlevel(byte * source, byte * dest, short width, short height); void Rotate_90_deg_lowlevel(byte * source, byte * dest, short width, short height);
/// ///
/// Rotate a pixel buffer by 90 degrees, counter-clockwise. /// Rotate a pixel buffer by 90 degrees, counter-clockwise.
/// @param source Source pixel buffer. /// @param source Source pixel buffer.
/// @param dest Destination pixel buffer. /// @param dest Destination pixel buffer.
/// @param width Width of the original buffer (height of the destination one). /// @param width Width of the original buffer (height of the destination one).
/// @param height Height of the original buffer (width of the destination one). /// @param height Height of the original buffer (width of the destination one).
void Rotate_270_deg_lowlevel(byte * source, byte * dest, short width, short height); void Rotate_270_deg_lowlevel(byte * source, byte * dest, short width, short height);
/// ///
/// Rotate a pixel buffer by 180 degrees. /// Rotate a pixel buffer by 180 degrees.
/// @param src The pixel buffer (source and destination). /// @param src The pixel buffer (source and destination).
/// @param width Width of the buffer. /// @param width Width of the buffer.
/// @param height Height of the buffer. /// @param height Height of the buffer.
void Rotate_180_deg_lowlevel(byte *src, short width, short height); void Rotate_180_deg_lowlevel(byte *src, short width, short height);
/// ///
/// Copies an image to another, rescaling it and optionally flipping it. /// Copies an image to another, rescaling it and optionally flipping it.
/// @param src_buffer Original image (address of first byte) /// @param src_buffer Original image (address of first byte)
/// @param src_width Original image's width in pixels /// @param src_width Original image's width in pixels
/// @param src_height Original image's height in pixels /// @param src_height Original image's height in pixels
/// @param dst_buffer Destination image (address of first byte) /// @param dst_buffer Destination image (address of first byte)
/// @param dst_width Destination image's width in pixels /// @param dst_width Destination image's width in pixels
/// @param dst_height Destination image's height in pixels /// @param dst_height Destination image's height in pixels
/// @param x_flipped Boolean, true to flip the image horizontally /// @param x_flipped Boolean, true to flip the image horizontally
/// @param y_flipped Boolean, true to flip the image vertically /// @param y_flipped Boolean, true to flip the image vertically
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); 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);
void Zoom_a_line(byte * original_line,byte * zoomed_line,word factor,word width); 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); 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);
// -- Gestion du chrono -- // -- Gestion du chrono --
byte Timer_state; // State du chrono: 0=Attente d'un Xème de seconde byte Timer_state; // State du chrono: 0=Attente d'un Xème de seconde
// 1=Il faut afficher la preview // 1=Il faut afficher la preview
// 2=Plus de chrono à gerer pour l'instant // 2=Plus de chrono à gerer pour l'instant
dword Timer_delay; // Nombre de 18.2ème de secondes demandés dword Timer_delay; // Nombre de 18.2ème de secondes demandés
dword Timer_start; // Heure de départ du chrono dword Timer_start; // Heure de départ du chrono
byte New_preview_is_needed; // Booléen "Il faut relancer le chrono de preview" byte New_preview_is_needed; // Booléen "Il faut relancer le chrono de preview"
unsigned long Memory_free(void); unsigned long Memory_free(void);
void Num2str(dword number,char * str,byte nb_char); void Num2str(dword number,char * str,byte nb_char);
short Round(float value); short Round(float value);
short Round_div_max(short numerator,short divisor); short Round_div_max(short numerator,short divisor);
int Min(int a,int b); int Min(int a,int b);
int Max(int a,int b); int Max(int a,int b);
char* Mode_label(int mode); char* Mode_label(int mode);
int Convert_videomode_arg(const char *argument); int Convert_videomode_arg(const char *argument);

File diff suppressed because it is too large Load Diff

View File

@ -1,47 +1,47 @@
/* mountlist.h -- declarations for list of mounted file systems /* mountlist.h -- declarations for list of mounted file systems
Copyright (C) 1991, 1992, 1998, 2000, 2001, 2002, 2003, 2004, 2005 Copyright (C) 1991, 1992, 1998, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc. Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file mountlist.h ///@file mountlist.h
/// A function to enumerate the mounting points in the filesystem. /// A function to enumerate the mounting points in the filesystem.
/// Used to display them in fileselectors. /// Used to display them in fileselectors.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef MOUNTLIST_H_ #ifndef MOUNTLIST_H_
# define MOUNTLIST_H_ # define MOUNTLIST_H_
# include <stdbool.h> # include <stdbool.h>
# include <sys/types.h> # include <sys/types.h>
/* A mount table entry. */ /* A mount table entry. */
struct mount_entry struct mount_entry
{ {
char *me_devname; /* Device node name, including "/dev/". */ char *me_devname; /* Device node name, including "/dev/". */
char *me_mountdir; /* Mount point directory name. */ char *me_mountdir; /* Mount point directory name. */
char *me_type; /* "nfs", "4.2", etc. */ char *me_type; /* "nfs", "4.2", etc. */
dev_t me_dev; /* Device number of me_mountdir. */ dev_t me_dev; /* Device number of me_mountdir. */
unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */ unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */
unsigned int me_remote : 1; /* Nonzero for remote fileystems. */ unsigned int me_remote : 1; /* Nonzero for remote fileystems. */
unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */ unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */
struct mount_entry *me_next; struct mount_entry *me_next;
}; };
struct mount_entry *read_file_system_list (bool need_fs_type); struct mount_entry *read_file_system_list (bool need_fs_type);
#endif #endif

2452
op_c.c

File diff suppressed because it is too large Load Diff

430
op_c.h
View File

@ -1,215 +1,215 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file op_c.h ///@file op_c.h
/// Color reduction and color conversion (24b->8b, RGB<->HSL). /// Color reduction and color conversion (24b->8b, RGB<->HSL).
/// This is called op_c because half of the process was originally /// This is called op_c because half of the process was originally
/// coded in op_asm, in assembler. /// coded in op_asm, in assembler.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef _OP_C_H_ #ifndef _OP_C_H_
#define _OP_C_H_ #define _OP_C_H_
#include "struct.h" #include "struct.h"
//////////////////////////////////////////////// Définition des types de base //////////////////////////////////////////////// Définition des types de base
typedef T_Components * T_Bitmap24B; typedef T_Components * T_Bitmap24B;
typedef byte * T_Bitmap256; typedef byte * T_Bitmap256;
//////////////////////////////////////// Définition d'une table de conversion //////////////////////////////////////// Définition d'une table de conversion
typedef struct typedef struct
{ {
int nbb_r; // Nb de bits de précision sur les rouges int nbb_r; // Nb de bits de précision sur les rouges
int nbb_g; // Nb de bits de précision sur les verts int nbb_g; // Nb de bits de précision sur les verts
int nbb_b; // Nb de bits de précision sur les bleu int nbb_b; // Nb de bits de précision sur les bleu
int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r) int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r)
int rng_g; // Nb de valeurs sur les verts (= 1<<nbb_g) int rng_g; // Nb de valeurs sur les verts (= 1<<nbb_g)
int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b) int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b)
int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b) int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b)
int dec_g; // Coefficient multiplicateur d'accès dans la table (= nbb_b) int dec_g; // Coefficient multiplicateur d'accès dans la table (= nbb_b)
int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0) int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0)
int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r) int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r)
int red_g; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g) int red_g; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g)
int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b) int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b)
byte * table; byte * table;
} T_Conversion_table; } T_Conversion_table;
///////////////////////////////////////// Définition d'une table d'occurences ///////////////////////////////////////// Définition d'une table d'occurences
typedef struct typedef struct
{ {
int nbb_r; // Nb de bits de précision sur les rouges int nbb_r; // Nb de bits de précision sur les rouges
int nbb_g; // Nb de bits de précision sur les verts int nbb_g; // Nb de bits de précision sur les verts
int nbb_b; // Nb de bits de précision sur les bleu int nbb_b; // Nb de bits de précision sur les bleu
int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r) int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r)
int rng_g; // Nb de valeurs sur les verts (= 1<<nbb_g) int rng_g; // Nb de valeurs sur les verts (= 1<<nbb_g)
int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b) int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b)
int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b) int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b)
int dec_g; // Coefficient multiplicateur d'accès dans la table (= nbb_b) int dec_g; // Coefficient multiplicateur d'accès dans la table (= nbb_b)
int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0) int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0)
int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r) int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r)
int red_g; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g) int red_g; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g)
int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b) int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b)
int * table; int * table;
} T_Occurrence_table; } T_Occurrence_table;
///////////////////////////////////////// Définition d'un ensemble de couleur ///////////////////////////////////////// Définition d'un ensemble de couleur
typedef struct S_Cluster typedef struct S_Cluster
{ {
int occurences; // Nb total d'occurences des couleurs de l'ensemble int occurences; // Nb total d'occurences des couleurs de l'ensemble
// Grande couverture // Grande couverture
byte Rmin,Rmax; byte Rmin,Rmax;
byte Gmin,Vmax; byte Gmin,Vmax;
byte Bmin,Bmax; byte Bmin,Bmax;
// Couverture minimale // Couverture minimale
byte rmin,rmax; byte rmin,rmax;
byte vmin,vmax; byte vmin,vmax;
byte bmin,bmax; byte bmin,bmax;
byte plus_large; // Composante ayant la plus grande variation (0=red,1=green,2=blue) byte plus_large; // Composante ayant la plus grande variation (0=red,1=green,2=blue)
byte r,g,b; // color synthétisant l'ensemble byte r,g,b; // color synthétisant l'ensemble
byte h; // Chrominance byte h; // Chrominance
byte l; // Luminosité byte l; // Luminosité
struct S_Cluster* next; struct S_Cluster* next;
} T_Cluster; } T_Cluster;
//////////////////////////////////////// Définition d'un ensemble de clusters //////////////////////////////////////// Définition d'un ensemble de clusters
typedef struct typedef struct
{ {
int nb; int nb;
int nb_max; int nb_max;
T_Cluster * clusters; T_Cluster * clusters;
} T_Cluster_set; } T_Cluster_set;
///////////////////////////////////////////////////// Définition d'un dégradé ///////////////////////////////////////////////////// Définition d'un dégradé
typedef struct typedef struct
{ {
int nb_colors; // Nombre de couleurs dans le dégradé int nb_colors; // Nombre de couleurs dans le dégradé
float min; // Chrominance minimale du dégradé float min; // Chrominance minimale du dégradé
float max; // Chrominance maximale du dégradé float max; // Chrominance maximale du dégradé
float hue; // Chrominance moyenne du dégradé float hue; // Chrominance moyenne du dégradé
} T_Gradient; } T_Gradient;
///////////////////////////////////////// Définition d'un ensemble de dégradé ///////////////////////////////////////// Définition d'un ensemble de dégradé
typedef struct typedef struct
{ {
int nb; // Nombre de dégradés dans l'ensemble int nb; // Nombre de dégradés dans l'ensemble
int nb_max; // Nombre maximum de dégradés int nb_max; // Nombre maximum de dégradés
T_Gradient * gradients; // Les dégradés T_Gradient * gradients; // Les dégradés
} T_Gradient_set; } T_Gradient_set;
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
///////////////////////////// Méthodes de gestion des tables de conversion // ///////////////////////////// Méthodes de gestion des tables de conversion //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
T_Conversion_table * CT_new(int nbb_r,int nbb_g,int nbb_b); T_Conversion_table * CT_new(int nbb_r,int nbb_g,int nbb_b);
void CT_delete(T_Conversion_table * t); void CT_delete(T_Conversion_table * t);
byte CT_get(T_Conversion_table * t,int r,int g,int b); byte CT_get(T_Conversion_table * t,int r,int g,int b);
void CT_set(T_Conversion_table * t,int r,int g,int b,byte i); void CT_set(T_Conversion_table * t,int r,int g,int b,byte i);
void RGB_to_HSL(int r, int g,int b, byte* h, byte*s, byte* l); void RGB_to_HSL(int r, int g,int b, byte* h, byte*s, byte* l);
void HSL_to_RGB(byte h, byte s, byte l, byte* r, byte* g, byte* b); void HSL_to_RGB(byte h, byte s, byte l, byte* r, byte* g, byte* b);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/////////////////////////////// Méthodes de gestion des tables d'occurence // /////////////////////////////// Méthodes de gestion des tables d'occurence //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void OT_init(T_Occurrence_table * t); void OT_init(T_Occurrence_table * t);
T_Occurrence_table * OT_new(int nbb_r,int nbb_g,int nbb_b); T_Occurrence_table * OT_new(int nbb_r,int nbb_g,int nbb_b);
void OT_delete(T_Occurrence_table * t); void OT_delete(T_Occurrence_table * t);
int OT_get(T_Occurrence_table * t,int r,int g,int b); int OT_get(T_Occurrence_table * t,int r,int g,int b);
void OT_inc(T_Occurrence_table * t,int r,int g,int b); void OT_inc(T_Occurrence_table * t,int r,int g,int b);
void OT_count_occurrences(T_Occurrence_table * t,T_Bitmap24B image,int size); void OT_count_occurrences(T_Occurrence_table * t,T_Bitmap24B image,int size);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// Méthodes de gestion des clusters // ///////////////////////////////////////// Méthodes de gestion des clusters //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void Cluster_analyser(T_Cluster * c,T_Occurrence_table * to); void Cluster_analyser(T_Cluster * c,T_Occurrence_table * to);
void Cluster_split(T_Cluster * c,T_Cluster * c1,T_Cluster * c2,int hue,T_Occurrence_table * to); void Cluster_split(T_Cluster * c,T_Cluster * c1,T_Cluster * c2,int hue,T_Occurrence_table * to);
void Cluster_compute_hue(T_Cluster * c,T_Occurrence_table * to); void Cluster_compute_hue(T_Cluster * c,T_Occurrence_table * to);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
//////////////////////////// Méthodes de gestion des ensembles de clusters // //////////////////////////// Méthodes de gestion des ensembles de clusters //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void CS_Init(T_Cluster_set * cs,T_Occurrence_table * to); void CS_Init(T_Cluster_set * cs,T_Occurrence_table * to);
T_Cluster_set * CS_New(int nbmax,T_Occurrence_table * to); T_Cluster_set * CS_New(int nbmax,T_Occurrence_table * to);
void CS_Delete(T_Cluster_set * cs); void CS_Delete(T_Cluster_set * cs);
void CS_Get(T_Cluster_set * cs,T_Cluster * c); void CS_Get(T_Cluster_set * cs,T_Cluster * c);
void CS_Set(T_Cluster_set * cs,T_Cluster * c); void CS_Set(T_Cluster_set * cs,T_Cluster * c);
void CS_Generate(T_Cluster_set * cs,T_Occurrence_table * to); void CS_Generate(T_Cluster_set * cs,T_Occurrence_table * to);
void CS_Compute_colors(T_Cluster_set * cs,T_Occurrence_table * to); void CS_Compute_colors(T_Cluster_set * cs,T_Occurrence_table * to);
void CS_Generate_color_table_and_palette(T_Cluster_set * cs,T_Conversion_table * tc,T_Components * palette); void CS_Generate_color_table_and_palette(T_Cluster_set * cs,T_Conversion_table * tc,T_Components * palette);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
//////////////////////////// Méthodes de gestion des ensembles de dégradés // //////////////////////////// Méthodes de gestion des ensembles de dégradés //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void GS_Init(T_Gradient_set * ds,T_Cluster_set * cs); void GS_Init(T_Gradient_set * ds,T_Cluster_set * cs);
T_Gradient_set * GS_New(T_Cluster_set * cs); T_Gradient_set * GS_New(T_Cluster_set * cs);
void GS_Delete(T_Gradient_set * ds); void GS_Delete(T_Gradient_set * ds);
void GS_Generate(T_Gradient_set * ds,T_Cluster_set * cs); void GS_Generate(T_Gradient_set * ds,T_Cluster_set * cs);
// Convertie avec le plus de précision possible une image 24b en 256c // Convertie avec le plus de précision possible une image 24b en 256c
// Renvoie s'il y a eu une erreur ou pas.. // Renvoie s'il y a eu une erreur ou pas..
int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette); int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette);
#endif #endif

10226
operatio.c

File diff suppressed because it is too large Load Diff

View File

@ -1,219 +1,219 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file operatio.h ///@file operatio.h
/// Code for the operations, ie all drawing tools. /// Code for the operations, ie all drawing tools.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// Do some housekeeping before starting work on a operation. /// Do some housekeeping before starting work on a operation.
void Start_operation_stack(word new_operation); void Start_operation_stack(word new_operation);
/// Put a value on ::Operation_stack /// Put a value on ::Operation_stack
void Operation_push(short value); void Operation_push(short value);
/// Take a value off ::Operation_stack /// Take a value off ::Operation_stack
void Operation_pop(short * value); void Operation_pop(short * value);
//////////////////////////////////////////////////// OPERATION_CONTINUOUS_DRAW //////////////////////////////////////////////////// OPERATION_CONTINUOUS_DRAW
void Freehand_mode1_1_0(void); void Freehand_mode1_1_0(void);
void Freehand_mode1_1_2(void); void Freehand_mode1_1_2(void);
void Freehand_mode12_0_2(void); void Freehand_mode12_0_2(void);
void Freehand_mode1_2_0(void); void Freehand_mode1_2_0(void);
void Freehand_mode1_2_2(void); void Freehand_mode1_2_2(void);
///////////////////////////////////////////////// OPERATION_DISCONTINUOUS_DRAW ///////////////////////////////////////////////// OPERATION_DISCONTINUOUS_DRAW
void Freehand_mode2_1_0(void); void Freehand_mode2_1_0(void);
void Freehand_mode2_1_2(void); void Freehand_mode2_1_2(void);
void Freehand_mode2_2_0(void); void Freehand_mode2_2_0(void);
void Freehand_mode2_2_2(void); void Freehand_mode2_2_2(void);
////////////////////////////////////////////////////// OPERATION_POINT_DRAW ////////////////////////////////////////////////////// OPERATION_POINT_DRAW
void Freehand_mode3_1_0(void); void Freehand_mode3_1_0(void);
void Freehand_Mode3_2_0(void); void Freehand_Mode3_2_0(void);
void Freehand_mode3_0_1(void); void Freehand_mode3_0_1(void);
///////////////////////////////////////////////////////////// OPERATION_LINE ///////////////////////////////////////////////////////////// OPERATION_LINE
void Line_12_0(void); void Line_12_0(void);
void Line_12_5(void); void Line_12_5(void);
void Line_0_5(void); void Line_0_5(void);
///////////////////////////////////////////////////////////// OPERATION_MAGNIFY ///////////////////////////////////////////////////////////// OPERATION_MAGNIFY
void Magnifier_12_0(void); void Magnifier_12_0(void);
/////////////////////////////////////////////////// OPERATION_RECTANGLE_????? /////////////////////////////////////////////////// OPERATION_RECTANGLE_?????
void Rectangle_12_0(void); void Rectangle_12_0(void);
void Rectangle_12_5(void); void Rectangle_12_5(void);
void Empty_rectangle_0_5(void); void Empty_rectangle_0_5(void);
void Filled_rectangle_0_5(void); void Filled_rectangle_0_5(void);
////////////////////////////////////////////////////// OPERATION_CERCLE_????? ////////////////////////////////////////////////////// OPERATION_CERCLE_?????
void Circle_12_0(void); void Circle_12_0(void);
void Circle_12_5(void); void Circle_12_5(void);
void Empty_circle_0_5(void); void Empty_circle_0_5(void);
void Filled_circle_0_5(void); void Filled_circle_0_5(void);
///////////////////////////////////////////////////// OPERATION_ELLIPSE_????? ///////////////////////////////////////////////////// OPERATION_ELLIPSE_?????
void Ellipse_12_0(void); void Ellipse_12_0(void);
void Ellipse_12_5(void); void Ellipse_12_5(void);
void Empty_ellipse_0_5(void); void Empty_ellipse_0_5(void);
void Filled_ellipse_0_5(void); void Filled_ellipse_0_5(void);
////////////////////////////////////////////////////// OPERATION_GRAB_BRUSH ////////////////////////////////////////////////////// OPERATION_GRAB_BRUSH
void Brush_12_0(void); void Brush_12_0(void);
void Brush_12_5(void); void Brush_12_5(void);
void Brush_0_5(void); void Brush_0_5(void);
///////////////////////////////////////////////////// OPERATION_STRETCH_BRUSH ///////////////////////////////////////////////////// OPERATION_STRETCH_BRUSH
void Stretch_brush_12_0(void); void Stretch_brush_12_0(void);
void Stretch_brush_1_7(void); void Stretch_brush_1_7(void);
void Stretch_brush_0_7(void); void Stretch_brush_0_7(void);
void Stretch_brush_2_7(void); void Stretch_brush_2_7(void);
//////////////////////////////////////////////////// OPERATION_ROTATE_BRUSH //////////////////////////////////////////////////// OPERATION_ROTATE_BRUSH
void Rotate_brush_12_0(void); void Rotate_brush_12_0(void);
void Rotate_brush_1_5(void); void Rotate_brush_1_5(void);
void Rotate_brush_0_5(void); void Rotate_brush_0_5(void);
void Rotate_brush_2_5(void); void Rotate_brush_2_5(void);
///////////////////////////////////////////////////// OPERATION_DISTORT_BRUSH ///////////////////////////////////////////////////// OPERATION_DISTORT_BRUSH
void Distort_brush_0_0(void); void Distort_brush_0_0(void);
void Distort_brush_1_0(void); void Distort_brush_1_0(void);
void Distort_brush_2_0(void); void Distort_brush_2_0(void);
void Distort_brush_1_8(void); void Distort_brush_1_8(void);
void Distort_brush_2_8(void); void Distort_brush_2_8(void);
void Distort_brush_1_9(void); void Distort_brush_1_9(void);
void Distort_brush_0_9(void); void Distort_brush_0_9(void);
//////////////////////////////////////////////////////// OPERATION_POLYBRUSH //////////////////////////////////////////////////////// OPERATION_POLYBRUSH
void Polybrush_12_8(void); void Polybrush_12_8(void);
////////////////////////////////////////////////////////////// OPERATION_FILL ////////////////////////////////////////////////////////////// OPERATION_FILL
void Fill_1_0(void); void Fill_1_0(void);
void Fill_2_0(void); void Fill_2_0(void);
///////////////////////////////////////////////////////// OPERATION_REPLACE ///////////////////////////////////////////////////////// OPERATION_REPLACE
void Replace_1_0(void); void Replace_1_0(void);
void Replace_2_0(void); void Replace_2_0(void);
/////////////////////////////////////////////////////////// OPERATION_COLORPICK /////////////////////////////////////////////////////////// OPERATION_COLORPICK
void Pipette_0_0(void); void Pipette_0_0(void);
void Colorpicker_12_0(void); void Colorpicker_12_0(void);
void Colorpicker_1_1(void); void Colorpicker_1_1(void);
void Colorpicker_2_1(void); void Colorpicker_2_1(void);
void Colorpicker_0_1(void); void Colorpicker_0_1(void);
/////////////////////////////////////////////////////////// OPERATION_K_LIGNE /////////////////////////////////////////////////////////// OPERATION_K_LIGNE
void K_line_12_0(void); void K_line_12_0(void);
void K_line_12_6(void); void K_line_12_6(void);
void K_line_0_6(void); void K_line_0_6(void);
void K_line_12_7(void); void K_line_12_7(void);
/////////////////////////////////////////////////// OPERATION_COURBE_?_POINTS /////////////////////////////////////////////////// OPERATION_COURBE_?_POINTS
void Curve_34_points_1_0(void); void Curve_34_points_1_0(void);
void Curve_34_points_2_0(void); void Curve_34_points_2_0(void);
void Curve_34_points_1_5(void); void Curve_34_points_1_5(void);
void Curve_34_points_2_5(void); void Curve_34_points_2_5(void);
void Curve_4_points_0_5(void); void Curve_4_points_0_5(void);
void Curve_4_points_1_9(void); void Curve_4_points_1_9(void);
void Curve_4_points_2_9(void); void Curve_4_points_2_9(void);
void Curve_3_points_0_5(void); void Curve_3_points_0_5(void);
void Curve_3_points_0_11(void); void Curve_3_points_0_11(void);
void Curve_3_points_12_11(void); void Curve_3_points_12_11(void);
///////////////////////////////////////////////////////////// OPERATION_AIRBRUSH ///////////////////////////////////////////////////////////// OPERATION_AIRBRUSH
void Airbrush_1_0(void); void Airbrush_1_0(void);
void Airbrush_2_0(void); void Airbrush_2_0(void);
void Airbrush_12_2(void); void Airbrush_12_2(void);
void Airbrush_0_2(void); void Airbrush_0_2(void);
//////////////////////////////////////////////////////////// OPERATION_*POLY* //////////////////////////////////////////////////////////// OPERATION_*POLY*
void Polygon_12_0(void); void Polygon_12_0(void);
void Polygon_12_9(void); void Polygon_12_9(void);
void Polyfill_12_0(void); void Polyfill_12_0(void);
void Polyfill_0_8(void); void Polyfill_0_8(void);
void Polyfill_12_8(void); void Polyfill_12_8(void);
void Polyfill_12_9(void); void Polyfill_12_9(void);
void Polyform_12_0(void); void Polyform_12_0(void);
void Polyform_12_8(void); void Polyform_12_8(void);
void Polyform_0_8(void); void Polyform_0_8(void);
void Filled_polyform_12_0(void); void Filled_polyform_12_0(void);
void Filled_polyform_12_8(void); void Filled_polyform_12_8(void);
void Filled_polyform_0_8(void); void Filled_polyform_0_8(void);
void Filled_contour_0_8(void); void Filled_contour_0_8(void);
//////////////////////////////////////////////////////////// OPERATION_SCROLL //////////////////////////////////////////////////////////// OPERATION_SCROLL
void Scroll_12_0(void); void Scroll_12_0(void);
void Scroll_12_4(void); void Scroll_12_4(void);
void Scroll_0_4(void); void Scroll_0_4(void);
//////////////////////////////////////////////////// OPERATION_GRAD_CIRCLE //////////////////////////////////////////////////// OPERATION_GRAD_CIRCLE
void Grad_circle_12_0(void); void Grad_circle_12_0(void);
void Grad_circle_12_6(void); void Grad_circle_12_6(void);
void Grad_circle_0_6(void); void Grad_circle_0_6(void);
void Grad_circle_12_8(void); void Grad_circle_12_8(void);
void Grad_circle_or_ellipse_0_8(void); void Grad_circle_or_ellipse_0_8(void);
////////////////////////////////////////////////// OPERATION_GRAD_ELLIPSE ////////////////////////////////////////////////// OPERATION_GRAD_ELLIPSE
void Grad_ellipse_12_0(void); void Grad_ellipse_12_0(void);
void Grad_ellipse_12_6(void); void Grad_ellipse_12_6(void);
void Grad_ellipse_0_6(void); void Grad_ellipse_0_6(void);
void Grad_ellipse_12_8(void); void Grad_ellipse_12_8(void);
///////////////////////////////////////////////// OPERATION_GRAD_RECTANGLE ///////////////////////////////////////////////// OPERATION_GRAD_RECTANGLE
void Grad_rectangle_12_0(void); void Grad_rectangle_12_0(void);
void Grad_rectangle_12_5(void); void Grad_rectangle_12_5(void);
void Grad_rectangle_0_5(void); void Grad_rectangle_0_5(void);
void Grad_rectangle_0_7(void); void Grad_rectangle_0_7(void);
void Grad_rectangle_12_7(void); void Grad_rectangle_12_7(void);
void Grad_rectangle_12_9(void); void Grad_rectangle_12_9(void);
void Grad_rectangle_0_9(void); void Grad_rectangle_0_9(void);
/////////////////////////////////////////////////// OPERATION_CENTERED_LINES /////////////////////////////////////////////////// OPERATION_CENTERED_LINES
void Centered_lines_12_0(void); void Centered_lines_12_0(void);
void Centered_lines_12_3(void); void Centered_lines_12_3(void);
void Centered_lines_0_3(void); void Centered_lines_0_3(void);
void Centered_lines_12_7(void); void Centered_lines_12_7(void);
void Centered_lines_0_7(void); void Centered_lines_0_7(void);

186
pages.h
View File

@ -1,93 +1,93 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pages.h ///@file pages.h
/// Handler for the Undo/Redo system. /// Handler for the Undo/Redo system.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef _PAGES_H_ #ifndef _PAGES_H_
#define _PAGES_H_ #define _PAGES_H_
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/////////////////////////// GESTION DU BACKUP //////////////////////////// /////////////////////////// GESTION DU BACKUP ////////////////////////////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// ///
/// GESTION DES PAGES /// GESTION DES PAGES
/// ///
void Init_page(T_Page * page); void Init_page(T_Page * page);
void Download_infos_page_main(T_Page * page); void Download_infos_page_main(T_Page * page);
void Upload_infos_page_main(T_Page * page); void Upload_infos_page_main(T_Page * page);
void Download_infos_page_spare(T_Page * page); void Download_infos_page_spare(T_Page * page);
void Upload_infos_page_spare(T_Page * page); void Upload_infos_page_spare(T_Page * page);
void Download_infos_backup(T_List_of_pages * list); void Download_infos_backup(T_List_of_pages * list);
void Free_a_page(T_Page * page); void Free_a_page(T_Page * page);
void Copy_S_page(T_Page * dest,T_Page * source); void Copy_S_page(T_Page * dest,T_Page * source);
int Size_of_a_page(T_Page * page); int Size_of_a_page(T_Page * page);
/// ///
/// GESTION DES LISTES DE PAGES /// GESTION DES LISTES DE PAGES
/// ///
void Init_list_of_pages(T_List_of_pages * list); void Init_list_of_pages(T_List_of_pages * list);
int Allocate_list_of_pages(T_List_of_pages * list,int size); int Allocate_list_of_pages(T_List_of_pages * list,int size);
void Free_a_list_of_pages(T_List_of_pages * list); void Free_a_list_of_pages(T_List_of_pages * list);
int Size_of_a_list_of_pages(T_List_of_pages * list); int Size_of_a_list_of_pages(T_List_of_pages * list);
void Backward_in_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 Advance_in_list_of_pages(T_List_of_pages * list);
int New_page_is_possible(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list); int New_page_is_possible(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list);
void Free_last_page_of_list(T_List_of_pages * list); void Free_last_page_of_list(T_List_of_pages * list);
void Create_new_page(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list); void Create_new_page(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list);
void Change_page_number_of_list(T_List_of_pages * list,int number); 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 Free_page_of_a_list(T_List_of_pages * list);
/// ///
/// GESTION DES BACKUPS /// GESTION DES BACKUPS
/// ///
int Init_all_backup_lists(int size,int width,int height); int Init_all_backup_lists(int size,int width,int height);
void Set_number_of_backups(int nb_backups); void Set_number_of_backups(int nb_backups);
int Backup_with_new_dimensions(int upload,int width,int height); int Backup_with_new_dimensions(int upload,int width,int height);
int Backup_and_resize_the_spare(int width,int height); int Backup_and_resize_the_spare(int width,int height);
void Backup(void); void Backup(void);
void Undo(void); void Undo(void);
void Redo(void); void Redo(void);
void Free_current_page(void); void Free_current_page(void);
void Exchange_main_and_spare(void); void Exchange_main_and_spare(void);
/// ///
/// GESTION DES EMPRUNTS DE MEMOIRE DE PAGE /// GESTION DES EMPRUNTS DE MEMOIRE DE PAGE
/// ///
int Can_borrow_memory_from_page(int size); int Can_borrow_memory_from_page(int size);
void * Borrow_memory_from_page(int size); void * Borrow_memory_from_page(int size);
#endif #endif

4604
palette.c

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +1,42 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file palette.h ///@file palette.h
/// Palette screen, and some palette-related high-level functions. /// Palette screen, and some palette-related high-level functions.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// Open the palette menu and handles everything inside it. /// Open the palette menu and handles everything inside it.
void Button_Palette(void); void Button_Palette(void);
/// Open the secondary palette menu and handles it. /// Open the secondary palette menu and handles it.
void Button_Secondary_palette(void); void Button_Secondary_palette(void);
/// Choose the number of graduations for RGB components, from 2 to 256. /// Choose the number of graduations for RGB components, from 2 to 256.
void Set_palette_RGB_scale(int); void Set_palette_RGB_scale(int);
/// ///
/// Scale a component (R, G or B) according to the current RGB graduations. /// Scale a component (R, G or B) according to the current RGB graduations.
/// Returns the resulting value, in the [0-255] range. /// Returns the resulting value, in the [0-255] range.
byte Round_palette_component(byte comp); byte Round_palette_component(byte comp);
/*! /*!
Adds 4 menu colors in the current palette. Adds 4 menu colors in the current palette.
@param color_usage An up-to-date color usage table (byte[256]) (read only) @param color_usage An up-to-date color usage table (byte[256]) (read only)
@param not_picture 0 if the caller is the palette screen, 1 if it's a preview in the file selector. @param not_picture 0 if the caller is the palette screen, 1 if it's a preview in the file selector.
*/ */
void Set_nice_menu_colors(dword * color_usage,int not_picture); void Set_nice_menu_colors(dword * color_usage,int not_picture);

View File

@ -1,497 +1,497 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2008 Franck Charlet Copyright 2008 Franck Charlet
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h> #include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
#include "pxdouble.h" #include "pxdouble.h"
#include "pxwide.h" // for Display_transparent_line_on_screen_wide() #include "pxwide.h" // for Display_transparent_line_on_screen_wide()
#define ZOOMX 2 #define ZOOMX 2
#define ZOOMY 2 #define ZOOMY 2
void Pixel_double (word x,word y,byte color) void Pixel_double (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1)* VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+1)* VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1)* VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+1)* VIDEO_LINE_WIDTH + 1)=color;
} }
byte Read_pixel_double (word x,word y) byte Read_pixel_double (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX); return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
} }
void Block_double (word start_x,word start_y,word width,word height,byte color) void Block_double (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=start_x*ZOOMX; rectangle.x=start_x*ZOOMX;
rectangle.y=start_y*ZOOMY; rectangle.y=start_y*ZOOMY;
rectangle.w=width*ZOOMX; rectangle.w=width*ZOOMX;
rectangle.h=height*ZOOMY; rectangle.h=height*ZOOMY;
SDL_FillRect(Screen_SDL,&rectangle,color); SDL_FillRect(Screen_SDL,&rectangle,color);
} }
void Display_part_of_screen_double (word width,word height,word image_width) void Display_part_of_screen_double (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
int dy; int dy;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
{ {
// On fait une copie de la ligne // On fait une copie de la ligne
for (dy=width;dy>0;dy--) for (dy=width;dy>0;dy--)
{ {
*(dest+1)=*dest=*src; *(dest+1)=*dest=*src;
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
} }
// On double la ligne qu'on vient de copier // On double la ligne qu'on vient de copier
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
//Update_rect(0,0,width,height); //Update_rect(0,0,width,height);
} }
void Pixel_preview_normal_double (word x,word y,byte color) void Pixel_preview_normal_double (word x,word y,byte color)
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image /* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
* dans l'écran, en mode normal (pas en mode loupe) * dans l'écran, en mode normal (pas en mode loupe)
* Note: si on modifie cette procédure, il faudra penser à faire également * Note: si on modifie cette procédure, il faudra penser à faire également
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */ * la modif dans la procédure Pixel_Preview_Loupe_SDL. */
{ {
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) // if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
Pixel_double(x-Main_offset_X,y-Main_offset_Y,color); Pixel_double(x-Main_offset_X,y-Main_offset_Y,color);
} }
void Pixel_preview_magnifier_double (word x,word y,byte color) void Pixel_preview_magnifier_double (word x,word y,byte color)
{ {
// Affiche le pixel dans la partie non zoomée // Affiche le pixel dans la partie non zoomée
Pixel_double(x-Main_offset_X,y-Main_offset_Y,color); Pixel_double(x-Main_offset_X,y-Main_offset_Y,color);
// Regarde si on doit aussi l'afficher dans la partie zoomée // Regarde si on doit aussi l'afficher dans la partie zoomée
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom) && x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
{ {
// On est dedans // On est dedans
int height; int height;
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
if (Menu_Y - y_zoom < Main_magnifier_factor) if (Menu_Y - y_zoom < Main_magnifier_factor)
// On ne doit dessiner qu'un morceau du pixel // On ne doit dessiner qu'un morceau du pixel
// sinon on dépasse sur le menu // sinon on dépasse sur le menu
height = Menu_Y - y_zoom; height = Menu_Y - y_zoom;
else else
height = Main_magnifier_factor; height = Main_magnifier_factor;
Block_double( Block_double(
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
y_zoom, Main_magnifier_factor, height, color y_zoom, Main_magnifier_factor, height, color
); );
} }
} }
void Horizontal_XOR_line_double(word x_pos,word y_pos,word width) void Horizontal_XOR_line_double(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de dest: //On calcule la valeur initiale de dest:
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
int x; int x;
for (x=0;x<width*ZOOMX;x+=ZOOMX) for (x=0;x<width*ZOOMX;x+=ZOOMX)
*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+1)=*(dest+x)=~*(dest+x); *(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+1)=*(dest+x)=~*(dest+x);
} }
void Vertical_XOR_line_double(word x_pos,word y_pos,word height) void Vertical_XOR_line_double(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY; byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
for (i=height;i>0;i--) for (i=height;i>0;i--)
{ {
*dest=*(dest+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=~*dest; *dest=*(dest+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=~*dest;
dest+=VIDEO_LINE_WIDTH*ZOOMY; dest+=VIDEO_LINE_WIDTH*ZOOMY;
} }
} }
void Display_brush_color_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_color_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = height;y > 0; y--)
{ {
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+1) = *dest = *src; *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+1) = *dest = *src;
} }
// Pixel suivant // Pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Display_brush_mono_double(word x_pos, word y_pos, void Display_brush_mono_double(word x_pos, word y_pos,
word x_offset, word y_offset, word width, word height, word x_offset, word y_offset, word width, word height,
byte transp_color, byte color, word brush_width) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à
// l'écran // l'écran
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
//Pour chaque ligne //Pour chaque ligne
{ {
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*src!=transp_color) if (*src!=transp_color)
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=color; *(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=color;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=brush_width-width; src+=brush_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_double(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width) void Clear_brush_double(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
{ {
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
int x; int x;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
{ {
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*src; *(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*src;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
// Affiche une brosse (arbitraire) à l'écran // Affiche une brosse (arbitraire) à l'écran
void Display_brush_double(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_double(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = height;y > 0; y--)
{ {
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*src; *(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*src;
} }
// Pixel suivant // Pixel suivant
src++; dest+=ZOOMX; src++; dest+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
} }
void Remap_screen_double(word x_pos,word y_pos,word width,word height,byte * conversion_table) void Remap_screen_double(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// dest = coords a l'écran // dest = coords a l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
for(y=height;y>0;y--) for(y=height;y>0;y--)
{ {
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest= *(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=
conversion_table[*dest]; conversion_table[*dest];
dest +=ZOOMX; dest +=ZOOMX;
} }
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Display_line_on_screen_fast_double(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_fast_double(word x_pos,word y_pos,word width,byte * line)
/* On affiche toute une ligne de pixels telle quelle. */ /* On affiche toute une ligne de pixels telle quelle. */
/* Utilisée si le buffer contient déja des pixel doublés. */ /* Utilisée si le buffer contient déja des pixel doublés. */
{ {
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX); memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX); memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
} }
void Display_line_on_screen_double(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_double(word x_pos,word y_pos,word width,byte * line)
/* On affiche une ligne de pixels en les doublant. */ /* On affiche une ligne de pixels en les doublant. */
{ {
int x; int x;
byte *dest; byte *dest;
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*line; *(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*line;
dest+=ZOOMX; dest+=ZOOMX;
line++; line++;
} }
} }
void Display_transparent_mono_line_on_screen_double( void Display_transparent_mono_line_on_screen_double(
word x_pos, word y_pos, word width, byte* line, word x_pos, word y_pos, word width, byte* line,
byte transp_color, byte color) byte transp_color, byte color)
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX; byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
{ {
if (transp_color!=*line) if (transp_color!=*line)
{ {
*(dest+1)=*dest=color; *(dest+1)=*dest=color;
} }
line ++; // Pixel suivant line ++; // Pixel suivant
dest+=ZOOMX; dest+=ZOOMX;
} }
} }
void Read_line_screen_double(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_double(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX); memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
} }
void Display_part_of_screen_scaled_double( void Display_part_of_screen_scaled_double(
word width, // width non zoomée word width, // width non zoomée
word height, // height zoomée word height, // height zoomée
word image_width,byte * buffer) word image_width,byte * buffer)
{ {
byte* src = Main_screen + Main_magnifier_offset_Y * image_width byte* src = Main_screen + Main_magnifier_offset_Y * image_width
+ Main_magnifier_offset_X; + Main_magnifier_offset_X;
int y = 0; // Ligne en cours de traitement int y = 0; // Ligne en cours de traitement
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
while(1) while(1)
{ {
int x; int x;
// On éclate la ligne // On éclate la ligne
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
// On l'affiche Facteur fois, sur des lignes consécutives // On l'affiche Facteur fois, sur des lignes consécutives
x = Main_magnifier_factor; x = Main_magnifier_factor;
// Pour chaque ligne // Pour chaque ligne
do{ do{
// On affiche la ligne zoomée // On affiche la ligne zoomée
Display_line_on_screen_fast_double( Display_line_on_screen_fast_double(
Main_X_zoom, y, width*Main_magnifier_factor, Main_X_zoom, y, width*Main_magnifier_factor,
buffer buffer
); );
// On passe à la suivante // On passe à la suivante
y++; y++;
if(y==height) if(y==height)
{ {
Update_rect(Main_X_zoom,0, Update_rect(Main_X_zoom,0,
width*Main_magnifier_factor,height); width*Main_magnifier_factor,height);
return; return;
} }
x--; x--;
}while (x > 0); }while (x > 0);
src += image_width; src += image_width;
} }
// ATTENTION on n'arrive jamais ici ! // ATTENTION on n'arrive jamais ici !
} }
// Affiche une partie de la brosse couleur zoomée // Affiche une partie de la brosse couleur zoomée
void Display_brush_color_zoom_double(word x_pos,word y_pos, void Display_brush_color_zoom_double(word x_pos,word y_pos,
word x_offset,word y_offset, word x_offset,word y_offset,
word width, // width non zoomée word width, // width non zoomée
word end_y_pos,byte transp_color, word end_y_pos,byte transp_color,
word brush_width, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * buffer) byte * buffer)
{ {
byte* src = Brush+y_offset*brush_width + x_offset; byte* src = Brush+y_offset*brush_width + x_offset;
word y = y_pos; word y = y_pos;
byte bx; byte bx;
// Pour chaque ligne // Pour chaque ligne
while(1) while(1)
{ {
Zoom_a_line(src,buffer,Main_magnifier_factor,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche facteur fois la ligne zoomée // On affiche facteur fois la ligne zoomée
for(bx=Main_magnifier_factor;bx>0;bx--) for(bx=Main_magnifier_factor;bx>0;bx--)
{ {
Display_transparent_line_on_screen_wide(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color); Display_transparent_line_on_screen_wide(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color);
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {
return; return;
} }
} }
src += brush_width; src += brush_width;
} }
// ATTENTION zone jamais atteinte // ATTENTION zone jamais atteinte
} }
void Display_brush_mono_zoom_double(word x_pos, word y_pos, void Display_brush_mono_zoom_double(word x_pos, word y_pos,
word x_offset, word y_offset, word x_offset, word y_offset,
word width, // width non zoomée word width, // width non zoomée
word end_y_pos, word end_y_pos,
byte transp_color, byte color, byte transp_color, byte color,
word brush_width, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * buffer byte * buffer
) )
{ {
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
int y=y_pos*ZOOMY; int y=y_pos*ZOOMY;
//Pour chaque ligne à zoomer : //Pour chaque ligne à zoomer :
while(1) while(1)
{ {
int bx; int bx;
// src = Ligne originale // src = Ligne originale
// On éclate la ligne // On éclate la ligne
Zoom_a_line(src,buffer,Main_magnifier_factor,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche la ligne Facteur fois à l'écran (sur des // On affiche la ligne Facteur fois à l'écran (sur des
// lignes consécutives) // lignes consécutives)
bx = Main_magnifier_factor*ZOOMY; bx = Main_magnifier_factor*ZOOMY;
// Pour chaque ligne écran // Pour chaque ligne écran
do do
{ {
// On affiche la ligne zoomée // On affiche la ligne zoomée
Display_transparent_mono_line_on_screen_double( Display_transparent_mono_line_on_screen_double(
x_pos, y, width * Main_magnifier_factor, x_pos, y, width * Main_magnifier_factor,
buffer, transp_color, color buffer, transp_color, color
); );
// On passe à la ligne suivante // On passe à la ligne suivante
y++; y++;
// On vérifie qu'on est pas à la ligne finale // On vérifie qu'on est pas à la ligne finale
if(y == end_y_pos*ZOOMY) if(y == end_y_pos*ZOOMY)
{ {
Update_rect( x_pos, y_pos, Update_rect( x_pos, y_pos,
width * Main_magnifier_factor, end_y_pos - y_pos ); width * Main_magnifier_factor, end_y_pos - y_pos );
return; return;
} }
bx --; bx --;
} }
while (bx > 0); while (bx > 0);
// Passage à la ligne suivante dans la brosse aussi // Passage à la ligne suivante dans la brosse aussi
src+=brush_width; src+=brush_width;
} }
} }
void Clear_brush_scaled_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer) void Clear_brush_scaled_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
{ {
// En fait on va recopier l'image non zoomée dans la partie zoomée ! // En fait on va recopier l'image non zoomée dans la partie zoomée !
byte* src = Main_screen + y_offset * image_width + x_offset; byte* src = Main_screen + y_offset * image_width + x_offset;
int y = y_pos; int y = y_pos;
int bx; int bx;
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
while(1){ while(1){
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
bx=Main_magnifier_factor; bx=Main_magnifier_factor;
// Pour chaque ligne // Pour chaque ligne
do{ do{
Display_line_on_screen_fast_double(x_pos,y, Display_line_on_screen_fast_double(x_pos,y,
width * Main_magnifier_factor,buffer); width * Main_magnifier_factor,buffer);
// Ligne suivante // Ligne suivante
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {
Update_rect(x_pos,y_pos, Update_rect(x_pos,y_pos,
width*Main_magnifier_factor,end_y_pos-y_pos); width*Main_magnifier_factor,end_y_pos-y_pos);
return; return;
} }
bx--; bx--;
}while(bx!=0); }while(bx!=0);
src+= image_width; src+= image_width;
} }
} }

View File

@ -1,48 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxdouble.h ///@file pxdouble.h
/// Renderer for double pixels (2x2). /// Renderer for double pixels (2x2).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_double (word x,word y,byte color); void Pixel_double (word x,word y,byte color);
byte Read_pixel_double (word x,word y); byte Read_pixel_double (word x,word y);
void Block_double (word start_x,word start_y,word width,word height,byte color); void Block_double (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_double (word x,word y,byte color); void Pixel_preview_normal_double (word x,word y,byte color);
void Pixel_preview_magnifier_double (word x,word y,byte color); void Pixel_preview_magnifier_double (word x,word y,byte color);
void Horizontal_XOR_line_double (word x_pos,word y_pos,word width); void Horizontal_XOR_line_double (word x_pos,word y_pos,word width);
void Vertical_XOR_line_double (word x_pos,word y_pos,word height); void Vertical_XOR_line_double (word x_pos,word y_pos,word height);
void Display_brush_color_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_double (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_double (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_double (word width,word height,word image_width); void Display_part_of_screen_double (word width,word height,word image_width);
void Display_line_on_screen_double (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_double (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_double (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_double (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_double(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_double(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_double (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_double (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_line_on_screen_fast_double (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_double (word x_pos,word y_pos,word width,byte * line);

1064
pxquad.c

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxquad.h ///@file pxquad.h
/// Renderer for quadruple pixels (4x4). /// Renderer for quadruple pixels (4x4).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_quad (word x,word y,byte color); void Pixel_quad (word x,word y,byte color);
byte Read_pixel_quad (word x,word y); byte Read_pixel_quad (word x,word y);
void Block_quad (word start_x,word start_y,word width,word height,byte color); void Block_quad (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_quad (word x,word y,byte color); void Pixel_preview_normal_quad (word x,word y,byte color);
void Pixel_preview_magnifier_quad (word x,word y,byte color); void Pixel_preview_magnifier_quad (word x,word y,byte color);
void Horizontal_XOR_line_quad (word x_pos,word y_pos,word width); void Horizontal_XOR_line_quad (word x_pos,word y_pos,word width);
void Vertical_XOR_line_quad (word x_pos,word y_pos,word height); void Vertical_XOR_line_quad (word x_pos,word y_pos,word height);
void Display_brush_color_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_quad (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_quad (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_quad (word width,word height,word image_width); void Display_part_of_screen_quad (word width,word height,word image_width);
void Display_line_on_screen_quad (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_quad (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_quad (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_quad (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_quad(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_quad(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_quad (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_quad (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_line_on_screen_fast_quad (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_quad (word x_pos,word y_pos,word width,byte * line);

View File

@ -1,470 +1,470 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2008 Franck Charlet Copyright 2008 Franck Charlet
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h> #include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
#include "pxsimple.h" #include "pxsimple.h"
void Pixel_simple (word x,word y,byte color) void Pixel_simple (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
*(Screen_pixels + x + y * VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x + y * VIDEO_LINE_WIDTH)=color;
} }
byte Read_pixel_simple (word x,word y) byte Read_pixel_simple (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Screen_pixels + y * VIDEO_LINE_WIDTH + x ); return *( Screen_pixels + y * VIDEO_LINE_WIDTH + x );
} }
void Block_simple (word start_x,word start_y,word width,word height,byte color) void Block_simple (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=start_x; rectangle.x=start_x;
rectangle.y=start_y; rectangle.y=start_y;
rectangle.w=width; rectangle.w=width;
rectangle.h=height; rectangle.h=height;
SDL_FillRect(Screen_SDL,&rectangle,color); SDL_FillRect(Screen_SDL,&rectangle,color);
} }
void Display_part_of_screen_simple (word width,word height,word image_width) void Display_part_of_screen_simple (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
{ {
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(dest,src,width); memcpy(dest,src,width);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width; src+=image_width;
dest+=VIDEO_LINE_WIDTH; dest+=VIDEO_LINE_WIDTH;
} }
//Update_rect(0,0,width,height); //Update_rect(0,0,width,height);
} }
void Pixel_preview_normal_simple (word x,word y,byte color) void Pixel_preview_normal_simple (word x,word y,byte color)
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image /* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
* dans l'écran, en mode normal (pas en mode loupe) * dans l'écran, en mode normal (pas en mode loupe)
* Note: si on modifie cette procédure, il faudra penser à faire également * Note: si on modifie cette procédure, il faudra penser à faire également
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */ * la modif dans la procédure Pixel_Preview_Loupe_SDL. */
{ {
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) // if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color); Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color);
} }
void Pixel_preview_magnifier_simple (word x,word y,byte color) void Pixel_preview_magnifier_simple (word x,word y,byte color)
{ {
// Affiche le pixel dans la partie non zoomée // Affiche le pixel dans la partie non zoomée
Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color); Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color);
// Regarde si on doit aussi l'afficher dans la partie zoomée // Regarde si on doit aussi l'afficher dans la partie zoomée
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom) && x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
{ {
// On est dedans // On est dedans
int height; int height;
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
if (Menu_Y - y_zoom < Main_magnifier_factor) if (Menu_Y - y_zoom < Main_magnifier_factor)
// On ne doit dessiner qu'un morceau du pixel // On ne doit dessiner qu'un morceau du pixel
// sinon on dépasse sur le menu // sinon on dépasse sur le menu
height = Menu_Y - y_zoom; height = Menu_Y - y_zoom;
else else
height = Main_magnifier_factor; height = Main_magnifier_factor;
Block_simple( Block_simple(
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
y_zoom, Main_magnifier_factor, height, color y_zoom, Main_magnifier_factor, height, color
); );
} }
} }
void Horizontal_XOR_line_simple(word x_pos,word y_pos,word width) void Horizontal_XOR_line_simple(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de dest: //On calcule la valeur initiale de dest:
byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
int x; int x;
for (x=0;x<width;x++) for (x=0;x<width;x++)
*(dest+x)=~*(dest+x); *(dest+x)=~*(dest+x);
} }
void Vertical_XOR_line_simple(word x_pos,word y_pos,word height) void Vertical_XOR_line_simple(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte color; byte color;
for (i=y_pos;i<y_pos+height;i++) for (i=y_pos;i<y_pos+height;i++)
{ {
color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH); color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH);
*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=~color; *(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=~color;
} }
} }
void Display_brush_color_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_color_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos; byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = height;y > 0; y--)
{ {
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*dest = *src; *dest = *src;
} }
// Pixel suivant // Pixel suivant
src++; dest++; src++; dest++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH - width; dest = dest + VIDEO_LINE_WIDTH - width;
src = src + brush_width - width; src = src + brush_width - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Display_brush_mono_simple(word x_pos, word y_pos, void Display_brush_mono_simple(word x_pos, word y_pos,
word x_offset, word y_offset, word width, word height, word x_offset, word y_offset, word width, word height,
byte transp_color, byte color, word brush_width) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; // dest = adr Destination à byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; // dest = adr Destination à
// l'écran // l'écran
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
//Pour chaque ligne //Pour chaque ligne
{ {
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*src!=transp_color) if (*src!=transp_color)
*dest=color; *dest=color;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest++; dest++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=brush_width-width; src+=brush_width-width;
dest+=VIDEO_LINE_WIDTH-width; dest+=VIDEO_LINE_WIDTH-width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_simple(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width) void Clear_brush_simple(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
{ {
byte* dest=Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) byte* dest=Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
{ {
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(dest,src,width); memcpy(dest,src,width);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width; src+=image_width;
dest+=VIDEO_LINE_WIDTH; dest+=VIDEO_LINE_WIDTH;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
// Affiche une brosse (arbitraire) à l'écran // Affiche une brosse (arbitraire) à l'écran
void Display_brush_simple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_simple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos; byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = height;y > 0; y--)
{ {
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*dest = *src; *dest = *src;
} }
// Pixel suivant // Pixel suivant
src++; dest++; src++; dest++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH - width; dest = dest + VIDEO_LINE_WIDTH - width;
src = src + brush_width - width; src = src + brush_width - width;
} }
} }
void Remap_screen_simple(word x_pos,word y_pos,word width,word height,byte * conversion_table) void Remap_screen_simple(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// dest = coords a l'écran // dest = coords a l'écran
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos; byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
for(y=height;y>0;y--) for(y=height;y>0;y--)
{ {
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*dest = conversion_table[*dest]; *dest = conversion_table[*dest];
dest ++; dest ++;
} }
dest = dest + VIDEO_LINE_WIDTH - width; dest = dest + VIDEO_LINE_WIDTH - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Display_line_on_screen_simple(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_simple(word x_pos,word y_pos,word width,byte * line)
/* On affiche toute une ligne de pixels. Utilisé pour les textes. */ /* On affiche toute une ligne de pixels. Utilisé pour les textes. */
{ {
memcpy(Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH,line,width); memcpy(Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH,line,width);
} }
void Display_transparent_mono_line_on_screen_simple( void Display_transparent_mono_line_on_screen_simple(
word x_pos, word y_pos, word width, byte* line, word x_pos, word y_pos, word width, byte* line,
byte transp_color, byte color) byte transp_color, byte color)
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* dest = Screen_pixels+ y_pos * VIDEO_LINE_WIDTH + x_pos; byte* dest = Screen_pixels+ y_pos * VIDEO_LINE_WIDTH + x_pos;
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
{ {
if (transp_color!=*line) if (transp_color!=*line)
*dest = color; *dest = color;
line ++; // Pixel suivant line ++; // Pixel suivant
dest++; dest++;
} }
} }
void Read_line_screen_simple(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_simple(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,VIDEO_LINE_WIDTH * y_pos + x_pos + Screen_pixels,width); memcpy(line,VIDEO_LINE_WIDTH * y_pos + x_pos + Screen_pixels,width);
} }
void Display_part_of_screen_scaled_simple( void Display_part_of_screen_scaled_simple(
word width, // width non zoomée word width, // width non zoomée
word height, // height zoomée word height, // height zoomée
word image_width,byte * buffer) word image_width,byte * buffer)
{ {
byte* src = Main_screen + Main_magnifier_offset_Y * image_width byte* src = Main_screen + Main_magnifier_offset_Y * image_width
+ Main_magnifier_offset_X; + Main_magnifier_offset_X;
int y = 0; // Ligne en cours de traitement int y = 0; // Ligne en cours de traitement
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
while(1) while(1)
{ {
int x; int x;
// On éclate la ligne // On éclate la ligne
Zoom_a_line(src,buffer,Main_magnifier_factor,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On l'affiche Facteur fois, sur des lignes consécutives // On l'affiche Facteur fois, sur des lignes consécutives
x = Main_magnifier_factor; x = Main_magnifier_factor;
// Pour chaque ligne // Pour chaque ligne
do{ do{
// On affiche la ligne zoomée // On affiche la ligne zoomée
Display_line_on_screen_simple( Display_line_on_screen_simple(
Main_X_zoom, y, width*Main_magnifier_factor, Main_X_zoom, y, width*Main_magnifier_factor,
buffer buffer
); );
// On passe à la suivante // On passe à la suivante
y++; y++;
if(y==height) if(y==height)
{ {
Update_rect(Main_X_zoom,0, Update_rect(Main_X_zoom,0,
width*Main_magnifier_factor,height); width*Main_magnifier_factor,height);
return; return;
} }
x--; x--;
}while (x > 0); }while (x > 0);
src += image_width; src += image_width;
} }
// ATTENTION on n'arrive jamais ici ! // ATTENTION on n'arrive jamais ici !
} }
void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color) void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color)
{ {
byte* src = line; byte* src = line;
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos; byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
word x; word x;
// Pour chaque pixel de la ligne // Pour chaque pixel de la ligne
for(x = width;x > 0;x--) for(x = width;x > 0;x--)
{ {
if(*src!=transp_color) if(*src!=transp_color)
*dest = *src; *dest = *src;
src++; src++;
dest++; dest++;
} }
} }
// Affiche une partie de la brosse couleur zoomée // Affiche une partie de la brosse couleur zoomée
void Display_brush_color_zoom_simple(word x_pos,word y_pos, void Display_brush_color_zoom_simple(word x_pos,word y_pos,
word x_offset,word y_offset, word x_offset,word y_offset,
word width, // width non zoomée word width, // width non zoomée
word end_y_pos,byte transp_color, word end_y_pos,byte transp_color,
word brush_width, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * buffer) byte * buffer)
{ {
byte* src = Brush+y_offset*brush_width + x_offset; byte* src = Brush+y_offset*brush_width + x_offset;
word y = y_pos; word y = y_pos;
byte bx; byte bx;
// Pour chaque ligne // Pour chaque ligne
while(1) while(1)
{ {
Zoom_a_line(src,buffer,Main_magnifier_factor,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche facteur fois la ligne zoomée // On affiche facteur fois la ligne zoomée
for(bx=Main_magnifier_factor;bx>0;bx--) for(bx=Main_magnifier_factor;bx>0;bx--)
{ {
Display_transparent_line_on_screen_simple(x_pos,y,width*Main_magnifier_factor,buffer,transp_color); Display_transparent_line_on_screen_simple(x_pos,y,width*Main_magnifier_factor,buffer,transp_color);
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {
return; return;
} }
} }
src += brush_width; src += brush_width;
} }
// ATTENTION zone jamais atteinte // ATTENTION zone jamais atteinte
} }
void Display_brush_mono_zoom_simple(word x_pos, word y_pos, void Display_brush_mono_zoom_simple(word x_pos, word y_pos,
word x_offset, word y_offset, word x_offset, word y_offset,
word width, // width non zoomée word width, // width non zoomée
word end_y_pos, word end_y_pos,
byte transp_color, byte color, byte transp_color, byte color,
word brush_width, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * buffer byte * buffer
) )
{ {
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
int y=y_pos; int y=y_pos;
//Pour chaque ligne à zoomer : //Pour chaque ligne à zoomer :
while(1) while(1)
{ {
int bx; int bx;
// src = Ligne originale // src = Ligne originale
// On éclate la ligne // On éclate la ligne
Zoom_a_line(src,buffer,Main_magnifier_factor,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche la ligne Facteur fois à l'écran (sur des // On affiche la ligne Facteur fois à l'écran (sur des
// lignes consécutives) // lignes consécutives)
bx = Main_magnifier_factor; bx = Main_magnifier_factor;
// Pour chaque ligne écran // Pour chaque ligne écran
do do
{ {
// On affiche la ligne zoomée // On affiche la ligne zoomée
Display_transparent_mono_line_on_screen_simple( Display_transparent_mono_line_on_screen_simple(
x_pos, y, width * Main_magnifier_factor, x_pos, y, width * Main_magnifier_factor,
buffer, transp_color, color buffer, transp_color, color
); );
// On passe à la ligne suivante // On passe à la ligne suivante
y++; y++;
// On vérifie qu'on est pas à la ligne finale // On vérifie qu'on est pas à la ligne finale
if(y == end_y_pos) if(y == end_y_pos)
{ {
Update_rect( x_pos, y_pos, Update_rect( x_pos, y_pos,
width * Main_magnifier_factor, end_y_pos - y_pos ); width * Main_magnifier_factor, end_y_pos - y_pos );
return; return;
} }
bx --; bx --;
} }
while (bx > 0); while (bx > 0);
// Passage à la ligne suivante dans la brosse aussi // Passage à la ligne suivante dans la brosse aussi
src+=brush_width; src+=brush_width;
} }
} }
void Clear_brush_scaled_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer) void Clear_brush_scaled_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
{ {
// En fait on va recopier l'image non zoomée dans la partie zoomée ! // En fait on va recopier l'image non zoomée dans la partie zoomée !
byte* src = Main_screen + y_offset * image_width + x_offset; byte* src = Main_screen + y_offset * image_width + x_offset;
int y = y_pos; int y = y_pos;
int bx; int bx;
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
while(1){ while(1){
Zoom_a_line(src,buffer,Main_magnifier_factor,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
bx=Main_magnifier_factor; bx=Main_magnifier_factor;
// Pour chaque ligne // Pour chaque ligne
do{ do{
Display_line_on_screen_simple(x_pos,y, Display_line_on_screen_simple(x_pos,y,
width * Main_magnifier_factor,buffer); width * Main_magnifier_factor,buffer);
// Ligne suivante // Ligne suivante
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {
Update_rect(x_pos,y_pos, Update_rect(x_pos,y_pos,
width*Main_magnifier_factor,end_y_pos-y_pos); width*Main_magnifier_factor,end_y_pos-y_pos);
return; return;
} }
bx--; bx--;
}while(bx!=0); }while(bx!=0);
src+= image_width; src+= image_width;
} }
} }

View File

@ -1,51 +1,51 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxsimple.h ///@file pxsimple.h
/// Renderer for simple pixels (1x1). This is the normal one. /// Renderer for simple pixels (1x1). This is the normal one.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_simple (word x,word y,byte color); void Pixel_simple (word x,word y,byte color);
byte Read_pixel_simple (word x,word y); byte Read_pixel_simple (word x,word y);
void Block_simple (word start_x,word start_y,word width,word height,byte color); void Block_simple (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_simple (word x,word y,byte color); void Pixel_preview_normal_simple (word x,word y,byte color);
void Pixel_preview_magnifier_simple (word x,word y,byte color); void Pixel_preview_magnifier_simple (word x,word y,byte color);
void Horizontal_XOR_line_simple (word x_pos,word y_pos,word width); void Horizontal_XOR_line_simple (word x_pos,word y_pos,word width);
void Vertical_XOR_line_simple (word x_pos,word y_pos,word height); void Vertical_XOR_line_simple (word x_pos,word y_pos,word height);
void Display_brush_color_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_simple (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_simple (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_simple (word width,word height,word image_width); void Display_part_of_screen_simple (word width,word height,word image_width);
void Display_line_on_screen_simple (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_simple (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_simple (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_simple (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_simple(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_simple(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_simple (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_simple (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_transparent_mono_line_on_screen_simple( void Display_transparent_mono_line_on_screen_simple(
word x_pos, word y_pos, word width, byte* line, word x_pos, word y_pos, word width, byte* line,
byte transp_color, byte color); byte transp_color, byte color);
void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color); void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color);

906
pxtall.c
View File

@ -1,453 +1,453 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2008 Franck Charlet Copyright 2008 Franck Charlet
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h> #include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
#include "pxtall.h" #include "pxtall.h"
#include "pxsimple.h" #include "pxsimple.h"
#define ZOOMX 1 #define ZOOMX 1
#define ZOOMY 2 #define ZOOMY 2
void Pixel_tall (word x,word y,byte color) void Pixel_tall (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
*(Screen_pixels + x + y*ZOOMY*VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x + y*ZOOMY*VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x + (y*ZOOMY+1)*VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x + (y*ZOOMY+1)*VIDEO_LINE_WIDTH)=color;
} }
byte Read_pixel_tall (word x,word y) byte Read_pixel_tall (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x ); return *( Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x );
} }
void Block_tall (word start_x,word start_y,word width,word height,byte color) void Block_tall (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=start_x; rectangle.x=start_x;
rectangle.y=start_y*ZOOMY; rectangle.y=start_y*ZOOMY;
rectangle.w=width; rectangle.w=width;
rectangle.h=height*ZOOMY; rectangle.h=height*ZOOMY;
SDL_FillRect(Screen_SDL,&rectangle,color); SDL_FillRect(Screen_SDL,&rectangle,color);
} }
void Display_part_of_screen_tall (word width,word height,word image_width) void Display_part_of_screen_tall (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
{ {
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(dest,src,width); memcpy(dest,src,width);
dest+=VIDEO_LINE_WIDTH; dest+=VIDEO_LINE_WIDTH;
memcpy(dest,src,width); memcpy(dest,src,width);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width; src+=image_width;
dest+=VIDEO_LINE_WIDTH; dest+=VIDEO_LINE_WIDTH;
} }
//Update_rect(0,0,width,height); //Update_rect(0,0,width,height);
} }
void Pixel_preview_normal_tall (word x,word y,byte color) void Pixel_preview_normal_tall (word x,word y,byte color)
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image /* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
* dans l'écran, en mode normal (pas en mode loupe) * dans l'écran, en mode normal (pas en mode loupe)
* Note: si on modifie cette procédure, il faudra penser à faire également * Note: si on modifie cette procédure, il faudra penser à faire également
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */ * la modif dans la procédure Pixel_Preview_Loupe_SDL. */
{ {
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) // if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color); Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color);
} }
void Pixel_preview_magnifier_tall (word x,word y,byte color) void Pixel_preview_magnifier_tall (word x,word y,byte color)
{ {
// Affiche le pixel dans la partie non zoomée // Affiche le pixel dans la partie non zoomée
Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color); Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color);
// Regarde si on doit aussi l'afficher dans la partie zoomée // Regarde si on doit aussi l'afficher dans la partie zoomée
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom) && x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
{ {
// On est dedans // On est dedans
int height; int height;
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
if (Menu_Y - y_zoom < Main_magnifier_factor) if (Menu_Y - y_zoom < Main_magnifier_factor)
// On ne doit dessiner qu'un morceau du pixel // On ne doit dessiner qu'un morceau du pixel
// sinon on dépasse sur le menu // sinon on dépasse sur le menu
height = Menu_Y - y_zoom; height = Menu_Y - y_zoom;
else else
height = Main_magnifier_factor; height = Main_magnifier_factor;
Block_tall( Block_tall(
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
y_zoom, Main_magnifier_factor, height, color y_zoom, Main_magnifier_factor, height, color
); );
} }
} }
void Horizontal_XOR_line_tall(word x_pos,word y_pos,word width) void Horizontal_XOR_line_tall(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de dest: //On calcule la valeur initiale de dest:
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
int x; int x;
for (x=0;x<width;x++) for (x=0;x<width;x++)
*(dest+x)=~*(dest+x); *(dest+x)=~*(dest+x);
dest=(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; dest=(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
for (x=0;x<width;x++) for (x=0;x<width;x++)
*(dest+x)=~*(dest+x); *(dest+x)=~*(dest+x);
} }
void Vertical_XOR_line_tall(word x_pos,word y_pos,word height) void Vertical_XOR_line_tall(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte color; byte color;
for (i=y_pos*ZOOMY;i<(y_pos+height)*ZOOMY;i++) for (i=y_pos*ZOOMY;i<(y_pos+height)*ZOOMY;i++)
{ {
color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH); color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH);
*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=~color; *(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=~color;
} }
} }
void Display_brush_color_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_color_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos; byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = height;y > 0; y--)
{ {
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*dest = *src; *dest = *src;
*(dest+VIDEO_LINE_WIDTH) = *src; *(dest+VIDEO_LINE_WIDTH) = *src;
} }
// Pixel suivant // Pixel suivant
src++; dest++; src++; dest++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + ZOOMY*VIDEO_LINE_WIDTH - width; dest = dest + ZOOMY*VIDEO_LINE_WIDTH - width;
src = src + brush_width - width; src = src + brush_width - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Display_brush_mono_tall(word x_pos, word y_pos, void Display_brush_mono_tall(word x_pos, word y_pos,
word x_offset, word y_offset, word width, word height, word x_offset, word y_offset, word width, word height,
byte transp_color, byte color, word brush_width) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; // dest = adr Destination à byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; // dest = adr Destination à
// l'écran // l'écran
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
//Pour chaque ligne //Pour chaque ligne
{ {
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*src!=transp_color) if (*src!=transp_color)
{ {
*dest=color; *dest=color;
*(dest+VIDEO_LINE_WIDTH)=color; *(dest+VIDEO_LINE_WIDTH)=color;
} }
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest++; dest++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=brush_width-width; src+=brush_width-width;
dest+=ZOOMY*VIDEO_LINE_WIDTH-width; dest+=ZOOMY*VIDEO_LINE_WIDTH-width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_tall(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width) void Clear_brush_tall(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
{ {
byte* dest=Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) byte* dest=Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
{ {
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(dest,src,width); memcpy(dest,src,width);
dest+=VIDEO_LINE_WIDTH; dest+=VIDEO_LINE_WIDTH;
memcpy(dest,src,width); memcpy(dest,src,width);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width; src+=image_width;
dest+=VIDEO_LINE_WIDTH; dest+=VIDEO_LINE_WIDTH;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
// Affiche une brosse (arbitraire) à l'écran // Affiche une brosse (arbitraire) à l'écran
void Display_brush_tall(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_tall(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos; byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = height;y > 0; y--)
{ {
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*dest = *src; *dest = *src;
*(dest+VIDEO_LINE_WIDTH) = *src; *(dest+VIDEO_LINE_WIDTH) = *src;
} }
// Pixel suivant // Pixel suivant
src++; dest++; src++; dest++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width; dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width;
src = src + brush_width - width; src = src + brush_width - width;
} }
} }
void Remap_screen_tall(word x_pos,word y_pos,word width,word height,byte * conversion_table) void Remap_screen_tall(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// dest = coords a l'écran // dest = coords a l'écran
byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos; byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
for(y=height*ZOOMY;y>0;y--) for(y=height*ZOOMY;y>0;y--)
{ {
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*dest = conversion_table[*dest]; *dest = conversion_table[*dest];
dest ++; dest ++;
} }
dest = dest + VIDEO_LINE_WIDTH - width; dest = dest + VIDEO_LINE_WIDTH - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Display_line_on_screen_tall(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_tall(word x_pos,word y_pos,word width,byte * line)
/* On affiche toute une ligne de pixels. Utilisé pour les textes. */ /* On affiche toute une ligne de pixels. Utilisé pour les textes. */
{ {
memcpy(Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width); memcpy(Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width);
memcpy(Screen_pixels+x_pos+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width); memcpy(Screen_pixels+x_pos+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width);
} }
void Read_line_screen_tall(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_tall(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY*y_pos + x_pos + Screen_pixels,width); memcpy(line,VIDEO_LINE_WIDTH*ZOOMY*y_pos + x_pos + Screen_pixels,width);
} }
void Display_part_of_screen_scaled_tall( void Display_part_of_screen_scaled_tall(
word width, // width non zoomée word width, // width non zoomée
word height, // height zoomée word height, // height zoomée
word image_width,byte * buffer) word image_width,byte * buffer)
{ {
byte* src = Main_screen + Main_magnifier_offset_Y * image_width byte* src = Main_screen + Main_magnifier_offset_Y * image_width
+ Main_magnifier_offset_X; + Main_magnifier_offset_X;
int y = 0; // Ligne en cours de traitement int y = 0; // Ligne en cours de traitement
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
while(1) while(1)
{ {
int x; int x;
// On éclate la ligne // On éclate la ligne
Zoom_a_line(src,buffer,Main_magnifier_factor,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On l'affiche Facteur fois, sur des lignes consécutives // On l'affiche Facteur fois, sur des lignes consécutives
x = Main_magnifier_factor*ZOOMY; x = Main_magnifier_factor*ZOOMY;
// Pour chaque ligne // Pour chaque ligne
do{ do{
// On affiche la ligne zoomée // On affiche la ligne zoomée
Display_line_on_screen_simple( Display_line_on_screen_simple(
Main_X_zoom, y, width*Main_magnifier_factor, Main_X_zoom, y, width*Main_magnifier_factor,
buffer buffer
); );
// On passe à la suivante // On passe à la suivante
y++; y++;
if(y==height*ZOOMY) if(y==height*ZOOMY)
{ {
Update_rect(Main_X_zoom,0, Update_rect(Main_X_zoom,0,
width*Main_magnifier_factor,height); width*Main_magnifier_factor,height);
return; return;
} }
x--; x--;
}while (x > 0); }while (x > 0);
src += image_width; src += image_width;
} }
// ATTENTION on n'arrive jamais ici ! // ATTENTION on n'arrive jamais ici !
} }
// Affiche une partie de la brosse couleur zoomée // Affiche une partie de la brosse couleur zoomée
void Display_brush_color_zoom_tall(word x_pos,word y_pos, void Display_brush_color_zoom_tall(word x_pos,word y_pos,
word x_offset,word y_offset, word x_offset,word y_offset,
word width, // width non zoomée word width, // width non zoomée
word end_y_pos,byte transp_color, word end_y_pos,byte transp_color,
word brush_width, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * buffer) byte * buffer)
{ {
byte* src = Brush+y_offset*brush_width + x_offset; byte* src = Brush+y_offset*brush_width + x_offset;
word y = y_pos; word y = y_pos;
byte bx; byte bx;
// Pour chaque ligne // Pour chaque ligne
while(1) while(1)
{ {
Zoom_a_line(src,buffer,Main_magnifier_factor,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche facteur fois la ligne zoomée // On affiche facteur fois la ligne zoomée
for(bx=Main_magnifier_factor;bx>0;bx--) for(bx=Main_magnifier_factor;bx>0;bx--)
{ {
Display_transparent_line_on_screen_simple(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color); Display_transparent_line_on_screen_simple(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color);
memcpy(Screen_pixels + (y*ZOOMY +1) * VIDEO_LINE_WIDTH + x_pos, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos, width*Main_magnifier_factor); memcpy(Screen_pixels + (y*ZOOMY +1) * VIDEO_LINE_WIDTH + x_pos, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos, width*Main_magnifier_factor);
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {
return; return;
} }
} }
src += brush_width; src += brush_width;
} }
// ATTENTION zone jamais atteinte // ATTENTION zone jamais atteinte
} }
void Display_brush_mono_zoom_tall(word x_pos, word y_pos, void Display_brush_mono_zoom_tall(word x_pos, word y_pos,
word x_offset, word y_offset, word x_offset, word y_offset,
word width, // width non zoomée word width, // width non zoomée
word end_y_pos, word end_y_pos,
byte transp_color, byte color, byte transp_color, byte color,
word brush_width, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * buffer byte * buffer
) )
{ {
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
int y=y_pos*ZOOMY; int y=y_pos*ZOOMY;
//Pour chaque ligne à zoomer : //Pour chaque ligne à zoomer :
while(1) while(1)
{ {
int bx; int bx;
// src = Ligne originale // src = Ligne originale
// On éclate la ligne // On éclate la ligne
Zoom_a_line(src,buffer,Main_magnifier_factor,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche la ligne Facteur fois à l'écran (sur des // On affiche la ligne Facteur fois à l'écran (sur des
// lignes consécutives) // lignes consécutives)
bx = Main_magnifier_factor*ZOOMY; bx = Main_magnifier_factor*ZOOMY;
// Pour chaque ligne écran // Pour chaque ligne écran
do do
{ {
// On affiche la ligne zoomée // On affiche la ligne zoomée
Display_transparent_mono_line_on_screen_simple( Display_transparent_mono_line_on_screen_simple(
x_pos, y, width * Main_magnifier_factor, x_pos, y, width * Main_magnifier_factor,
buffer, transp_color, color buffer, transp_color, color
); );
// On passe à la ligne suivante // On passe à la ligne suivante
y++; y++;
// On vérifie qu'on est pas à la ligne finale // On vérifie qu'on est pas à la ligne finale
if(y == end_y_pos*ZOOMY) if(y == end_y_pos*ZOOMY)
{ {
Update_rect( x_pos, y_pos, Update_rect( x_pos, y_pos,
width * Main_magnifier_factor, end_y_pos - y_pos ); width * Main_magnifier_factor, end_y_pos - y_pos );
return; return;
} }
bx --; bx --;
} }
while (bx > 0); while (bx > 0);
// Passage à la ligne suivante dans la brosse aussi // Passage à la ligne suivante dans la brosse aussi
src+=brush_width; src+=brush_width;
} }
} }
void Clear_brush_scaled_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer) void Clear_brush_scaled_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
{ {
// En fait on va recopier l'image non zoomée dans la partie zoomée ! // En fait on va recopier l'image non zoomée dans la partie zoomée !
byte* src = Main_screen + y_offset * image_width + x_offset; byte* src = Main_screen + y_offset * image_width + x_offset;
int y = y_pos; int y = y_pos;
int bx; int bx;
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
while(1){ while(1){
Zoom_a_line(src,buffer,Main_magnifier_factor,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
bx=Main_magnifier_factor; bx=Main_magnifier_factor;
// Pour chaque ligne // Pour chaque ligne
do{ do{
Display_line_on_screen_tall(x_pos,y, Display_line_on_screen_tall(x_pos,y,
width * Main_magnifier_factor,buffer); width * Main_magnifier_factor,buffer);
// Ligne suivante // Ligne suivante
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {
Update_rect(x_pos,y_pos, Update_rect(x_pos,y_pos,
width*Main_magnifier_factor,end_y_pos-y_pos); width*Main_magnifier_factor,end_y_pos-y_pos);
return; return;
} }
bx--; bx--;
}while(bx!=0); }while(bx!=0);
src+= image_width; src+= image_width;
} }
} }

View File

@ -1,46 +1,46 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxtall.h ///@file pxtall.h
/// Renderer for tall pixels (1x2). /// Renderer for tall pixels (1x2).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_tall (word x,word y,byte color); void Pixel_tall (word x,word y,byte color);
byte Read_pixel_tall (word x,word y); byte Read_pixel_tall (word x,word y);
void Block_tall (word start_x,word start_y,word width,word height,byte color); void Block_tall (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_tall (word x,word y,byte color); void Pixel_preview_normal_tall (word x,word y,byte color);
void Pixel_preview_magnifier_tall (word x,word y,byte color); void Pixel_preview_magnifier_tall (word x,word y,byte color);
void Horizontal_XOR_line_tall (word x_pos,word y_pos,word width); void Horizontal_XOR_line_tall (word x_pos,word y_pos,word width);
void Vertical_XOR_line_tall (word x_pos,word y_pos,word height); void Vertical_XOR_line_tall (word x_pos,word y_pos,word height);
void Display_brush_color_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_tall (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_tall (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_tall (word width,word height,word image_width); void Display_part_of_screen_tall (word width,word height,word image_width);
void Display_line_on_screen_tall (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_tall (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_tall (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_tall (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_tall(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_tall(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_tall (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_tall (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);

1048
pxtall2.c

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxtall2.h ///@file pxtall2.h
/// Renderer for double-tall pixels (2x4). /// Renderer for double-tall pixels (2x4).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_tall2 (word x,word y,byte color); void Pixel_tall2 (word x,word y,byte color);
byte Read_pixel_tall2 (word x,word y); byte Read_pixel_tall2 (word x,word y);
void Block_tall2 (word start_x,word start_y,word width,word height,byte color); void Block_tall2 (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_tall2 (word x,word y,byte color); void Pixel_preview_normal_tall2 (word x,word y,byte color);
void Pixel_preview_magnifier_tall2 (word x,word y,byte color); void Pixel_preview_magnifier_tall2 (word x,word y,byte color);
void Horizontal_XOR_line_tall2 (word x_pos,word y_pos,word width); void Horizontal_XOR_line_tall2 (word x_pos,word y_pos,word width);
void Vertical_XOR_line_tall2 (word x_pos,word y_pos,word height); void Vertical_XOR_line_tall2 (word x_pos,word y_pos,word height);
void Display_brush_color_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_tall2 (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_tall2 (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_tall2 (word width,word height,word image_width); void Display_part_of_screen_tall2 (word width,word height,word image_width);
void Display_line_on_screen_tall2 (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_tall2 (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_tall2 (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_tall2 (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_tall2(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_tall2(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_tall2 (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_tall2 (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_line_on_screen_fast_tall2 (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_tall2 (word x_pos,word y_pos,word width,byte * line);

1040
pxtriple.c

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxtriple.h ///@file pxtriple.h
/// Renderer for triple pixels (3x3). /// Renderer for triple pixels (3x3).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_triple (word x,word y,byte color); void Pixel_triple (word x,word y,byte color);
byte Read_pixel_triple (word x,word y); byte Read_pixel_triple (word x,word y);
void Block_triple (word start_x,word start_y,word width,word height,byte color); void Block_triple (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_triple (word x,word y,byte color); void Pixel_preview_normal_triple (word x,word y,byte color);
void Pixel_preview_magnifier_triple (word x,word y,byte color); void Pixel_preview_magnifier_triple (word x,word y,byte color);
void Horizontal_XOR_line_triple (word x_pos,word y_pos,word width); void Horizontal_XOR_line_triple (word x_pos,word y_pos,word width);
void Vertical_XOR_line_triple (word x_pos,word y_pos,word height); void Vertical_XOR_line_triple (word x_pos,word y_pos,word height);
void Display_brush_color_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_triple (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_triple (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_triple (word width,word height,word image_width); void Display_part_of_screen_triple (word width,word height,word image_width);
void Display_line_on_screen_triple (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_triple (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_triple (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_triple (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_triple(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_triple(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_triple (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_triple (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_line_on_screen_fast_triple (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_triple (word x_pos,word y_pos,word width,byte * line);

1012
pxwide.c

File diff suppressed because it is too large Load Diff

View File

@ -1,49 +1,49 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxwide.h ///@file pxwide.h
/// Renderer for wide pixels (2x1). /// Renderer for wide pixels (2x1).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_wide (word x,word y,byte color); void Pixel_wide (word x,word y,byte color);
byte Read_pixel_wide (word x,word y); byte Read_pixel_wide (word x,word y);
void Block_wide (word start_x,word start_y,word width,word height,byte color); void Block_wide (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_wide (word x,word y,byte color); void Pixel_preview_normal_wide (word x,word y,byte color);
void Pixel_preview_magnifier_wide (word x,word y,byte color); void Pixel_preview_magnifier_wide (word x,word y,byte color);
void Horizontal_XOR_line_wide (word x_pos,word y_pos,word width); void Horizontal_XOR_line_wide (word x_pos,word y_pos,word width);
void Vertical_XOR_line_wide (word x_pos,word y_pos,word height); void Vertical_XOR_line_wide (word x_pos,word y_pos,word height);
void Display_brush_color_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_wide (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_wide (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_wide (word width,word height,word image_width); void Display_part_of_screen_wide (word width,word height,word image_width);
void Display_line_on_screen_wide (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_wide (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_wide (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_wide (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_wide(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_wide(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_wide (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_wide (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_line_on_screen_fast_wide (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_wide (word x_pos,word y_pos,word width,byte * line);
void Display_transparent_line_on_screen_wide(word x_pos,word y_pos,word width,byte* line,byte transp_color); void Display_transparent_line_on_screen_wide(word x_pos,word y_pos,word width,byte* line,byte transp_color);

1028
pxwide2.c

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxwide2.h ///@file pxwide2.h
/// Renderer for double-wide pixels (4x2). /// Renderer for double-wide pixels (4x2).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_wide2 (word x,word y,byte color); void Pixel_wide2 (word x,word y,byte color);
byte Read_pixel_wide2 (word x,word y); byte Read_pixel_wide2 (word x,word y);
void Block_wide2 (word start_x,word start_y,word width,word height,byte color); void Block_wide2 (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_wide2 (word x,word y,byte color); void Pixel_preview_normal_wide2 (word x,word y,byte color);
void Pixel_preview_magnifier_wide2 (word x,word y,byte color); void Pixel_preview_magnifier_wide2 (word x,word y,byte color);
void Horizontal_XOR_line_wide2 (word x_pos,word y_pos,word width); void Horizontal_XOR_line_wide2 (word x_pos,word y_pos,word width);
void Vertical_XOR_line_wide2 (word x_pos,word y_pos,word height); void Vertical_XOR_line_wide2 (word x_pos,word y_pos,word height);
void Display_brush_color_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_wide2 (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_wide2 (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_wide2 (word width,word height,word image_width); void Display_part_of_screen_wide2 (word width,word height,word image_width);
void Display_line_on_screen_wide2 (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_wide2 (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_wide2 (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_wide2 (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_wide2(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_wide2(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_wide2 (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_wide2 (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_line_on_screen_fast_wide2 (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_wide2 (word x_pos,word y_pos,word width,byte * line);

View File

@ -1,27 +1,27 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file readini.h ///@file readini.h
/// Reading settings in gfx2.ini /// Reading settings in gfx2.ini
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
int Load_INI(T_Config * conf); int Load_INI(T_Config * conf);
int Load_INI_seek_pattern(char * buffer,char * pattern); int Load_INI_seek_pattern(char * buffer,char * pattern);
void Load_INI_clear_string(char * str, byte keep_comments); void Load_INI_clear_string(char * str, byte keep_comments);

View File

@ -1,350 +1,350 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
/************************************************************************ /************************************************************************
* * * *
* READLINE (procédure permettant de saisir une chaîne de caractères) * * READLINE (procédure permettant de saisir une chaîne de caractères) *
* * * *
************************************************************************/ ************************************************************************/
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "const.h" #include "const.h"
#include "struct.h" #include "struct.h"
#include "global.h" #include "global.h"
#include "misc.h" #include "misc.h"
#include "errors.h" #include "errors.h"
#include "const.h" #include "const.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "readline.h" #include "readline.h"
#include "windows.h" #include "windows.h"
#include "input.h" #include "input.h"
#define TEXT_COLOR MC_Black #define TEXT_COLOR MC_Black
#define BACKGROUND_COLOR MC_Light #define BACKGROUND_COLOR MC_Light
#define CURSOR_COLOR MC_Black #define CURSOR_COLOR MC_Black
#define CURSOR_BACKGROUND_COLOR MC_Dark #define CURSOR_BACKGROUND_COLOR MC_Dark
// Suppresion d'un caractère à une certaine POSITION dans une CHAINE. // Suppresion d'un caractère à une certaine POSITION dans une CHAINE.
void Remove_character(char * str, byte position) void Remove_character(char * str, byte position)
{ {
for (;str[position]!='\0';position++) for (;str[position]!='\0';position++)
str[position]=str[position+1]; str[position]=str[position+1];
} }
void Insert_character(char * str, char letter, byte position) void Insert_character(char * str, char letter, byte position)
// Insertion d'une LETTRE à une certaine POSITION // Insertion d'une LETTRE à une certaine POSITION
// dans une CHAINE d'une certaine TAILLE. // dans une CHAINE d'une certaine TAILLE.
{ {
char temp_char; char temp_char;
for (;letter!='\0';position++) for (;letter!='\0';position++)
{ {
// On mémorise le caractère qui se trouve en "position" // On mémorise le caractère qui se trouve en "position"
temp_char=str[position]; temp_char=str[position];
// On splotch la lettre à insérer // On splotch la lettre à insérer
str[position]=letter; str[position]=letter;
// On place le caractère mémorisé dans "letter" comme nouvelle lettre à insérer // On place le caractère mémorisé dans "letter" comme nouvelle lettre à insérer
letter=temp_char; letter=temp_char;
} }
// On termine la chaine // On termine la chaine
str[position]='\0'; str[position]='\0';
} }
int Valid_character(int c) int Valid_character(int c)
{ {
// Sous Linux: Seul le / est strictement interdit, mais beaucoup // Sous Linux: Seul le / est strictement interdit, mais beaucoup
// d'autres poseront des problèmes au shell, alors on évite. // d'autres poseront des problèmes au shell, alors on évite.
// Sous Windows : c'est moins grave car le fopen() échouerait de toutes façons. // Sous Windows : c'est moins grave car le fopen() échouerait de toutes façons.
// AmigaOS4: Pas de ':' car utilisé pour les volumes. // AmigaOS4: Pas de ':' car utilisé pour les volumes.
#if defined(__WIN32__) #if defined(__WIN32__)
char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':', '\\'}; char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':', '\\'};
#elif defined (__amigaos4__) #elif defined (__amigaos4__)
char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':'}; char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':'};
#else #else
char forbidden_char[] = {'/', '|', '?', '*', '<', '>'}; char forbidden_char[] = {'/', '|', '?', '*', '<', '>'};
#endif #endif
int position; int position;
if (c < ' ' || c > 255) if (c < ' ' || c > 255)
return 0; return 0;
for (position=0; position<(long)sizeof(forbidden_char); position++) for (position=0; position<(long)sizeof(forbidden_char); position++)
if (c == forbidden_char[position]) if (c == forbidden_char[position])
return 0; return 0;
return 1; return 1;
} }
void Display_whole_string(word x_pos,word y_pos,char * str,byte position) void Display_whole_string(word x_pos,word y_pos,char * str,byte position)
{ {
Print_in_window(x_pos,y_pos,str,TEXT_COLOR,BACKGROUND_COLOR); Print_in_window(x_pos,y_pos,str,TEXT_COLOR,BACKGROUND_COLOR);
Print_char_in_window(x_pos+(position<<3),y_pos,str[position],CURSOR_COLOR,CURSOR_BACKGROUND_COLOR); Print_char_in_window(x_pos+(position<<3),y_pos,str[position],CURSOR_COLOR,CURSOR_BACKGROUND_COLOR);
} }
/**************************************************************************** /****************************************************************************
* Enhanced super scanf deluxe pro plus giga mieux :-) * * Enhanced super scanf deluxe pro plus giga mieux :-) *
****************************************************************************/ ****************************************************************************/
byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type) byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type)
// Paramètres: // Paramètres:
// x_pos, y_pos : Coordonnées de la saisie dans la fenêtre // x_pos, y_pos : Coordonnées de la saisie dans la fenêtre
// str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale) // str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale)
// max_size : Nombre de caractères logeant dans la zone de saisie // max_size : Nombre de caractères logeant dans la zone de saisie
// input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier // input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier
// Sortie: // Sortie:
// 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return) // 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return)
{ {
byte max_size; byte max_size;
// Grosse astuce pour les noms de fichiers: La taille affichée est différente // Grosse astuce pour les noms de fichiers: La taille affichée est différente
// de la taille maximum gérée. // de la taille maximum gérée.
if (input_type == 2) if (input_type == 2)
max_size = 255; max_size = 255;
else else
max_size = visible_size; max_size = visible_size;
return Readline_ex(x_pos,y_pos,str,visible_size,max_size,input_type); return Readline_ex(x_pos,y_pos,str,visible_size,max_size,input_type);
} }
/**************************************************************************** /****************************************************************************
* Enhanced super scanf deluxe pro plus giga mieux :-) * * Enhanced super scanf deluxe pro plus giga mieux :-) *
****************************************************************************/ ****************************************************************************/
byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_size, byte input_type) byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_size, byte input_type)
// Paramètres: // Paramètres:
// x_pos, y_pos : Coordonnées de la saisie dans la fenêtre // x_pos, y_pos : Coordonnées de la saisie dans la fenêtre
// str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale) // str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale)
// max_size : Nombre de caractères logeant dans la zone de saisie // max_size : Nombre de caractères logeant dans la zone de saisie
// input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier // input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier
// Sortie: // Sortie:
// 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return) // 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return)
{ {
char initial_string[256]; char initial_string[256];
char display_string[256]; char display_string[256];
byte position; byte position;
byte size; byte size;
word input_key=0; word input_key=0;
byte is_authorized; byte is_authorized;
byte offset=0; // index du premier caractère affiché byte offset=0; // index du premier caractère affiché
Hide_cursor(); Hide_cursor();
// Effacement de la chaîne // Effacement de la chaîne
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3)); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
// Mise à jour des variables se rapportant à la chaîne en fonction de la chaîne initiale // Mise à jour des variables se rapportant à la chaîne en fonction de la chaîne initiale
strcpy(initial_string,str); strcpy(initial_string,str);
// Si on a commencé à editer par un clic-droit, on vide la chaine. // Si on a commencé à editer par un clic-droit, on vide la chaine.
if (Mouse_K==RIGHT_SIDE) if (Mouse_K==RIGHT_SIDE)
str[0]='\0'; str[0]='\0';
else if (input_type==1) else if (input_type==1)
snprintf(str,10,"%d",atoi(str)); // On tasse la chaine à gauche snprintf(str,10,"%d",atoi(str)); // On tasse la chaine à gauche
size=strlen(str); size=strlen(str);
position=(size<max_size)? size:size-1; position=(size<max_size)? size:size-1;
if (position-offset>visible_size) if (position-offset>visible_size)
offset=position-visible_size+1; offset=position-visible_size+1;
// Formatage d'une partie de la chaine (si trop longue pour tenir) // Formatage d'une partie de la chaine (si trop longue pour tenir)
strncpy(display_string, str + offset, visible_size); strncpy(display_string, str + offset, visible_size);
display_string[visible_size]='\0'; display_string[visible_size]='\0';
if (offset>0) if (offset>0)
display_string[0]=LEFT_TRIANGLE_CHARACTER; display_string[0]=LEFT_TRIANGLE_CHARACTER;
if (visible_size + offset + 1 < size ) if (visible_size + offset + 1 < size )
display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER; display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER;
Display_whole_string(x_pos,y_pos,display_string,position - offset); Display_whole_string(x_pos,y_pos,display_string,position - offset);
Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3)); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
Flush_update(); Flush_update();
while ((input_key!=SDLK_RETURN) && (input_key!=KEY_ESC)) while ((input_key!=SDLK_RETURN) && (input_key!=KEY_ESC))
{ {
Display_cursor(); Display_cursor();
do do
{ {
if(!Get_input()) SDL_Delay(20); if(!Get_input()) SDL_Delay(20);
input_key=Key_ANSI; input_key=Key_ANSI;
} while(input_key==0); } while(input_key==0);
Hide_cursor(); Hide_cursor();
switch (input_key) switch (input_key)
{ {
case SDLK_DELETE : // Suppr. case SDLK_DELETE : // Suppr.
if (position<size) if (position<size)
{ {
Remove_character(str,position); Remove_character(str,position);
size--; size--;
// Effacement de la chaîne // Effacement de la chaîne
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
goto affichage; goto affichage;
} }
break; break;
case SDLK_LEFT : // Gauche case SDLK_LEFT : // Gauche
if (position>0) if (position>0)
{ {
// Effacement de la chaîne // Effacement de la chaîne
if (position==size) if (position==size)
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
position--; position--;
if (offset > 0 && (position == 0 || position < (offset + 1))) if (offset > 0 && (position == 0 || position < (offset + 1)))
offset--; offset--;
goto affichage; goto affichage;
} }
break; break;
case SDLK_RIGHT : // Droite case SDLK_RIGHT : // Droite
if ((position<size) && (position<max_size-1)) if ((position<size) && (position<max_size-1))
{ {
position++; position++;
//if (position > visible_size + offset - 2) //if (position > visible_size + offset - 2)
//if (offset + visible_size < max_size && (position == size || (position > visible_size + offset - 2))) //if (offset + visible_size < max_size && (position == size || (position > visible_size + offset - 2)))
if (display_string[position-offset]==RIGHT_TRIANGLE_CHARACTER || position-offset>=visible_size) if (display_string[position-offset]==RIGHT_TRIANGLE_CHARACTER || position-offset>=visible_size)
offset++; offset++;
goto affichage; goto affichage;
} }
break; break;
case SDLK_HOME : // Home case SDLK_HOME : // Home
if (position) if (position)
{ {
// Effacement de la chaîne // Effacement de la chaîne
if (position==size) if (position==size)
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
position = 0; position = 0;
offset = 0; offset = 0;
goto affichage; goto affichage;
} }
break; break;
case SDLK_END : // End case SDLK_END : // End
if ((position<size) && (position<max_size-1)) if ((position<size) && (position<max_size-1))
{ {
position=(size<max_size)?size:size-1; position=(size<max_size)?size:size-1;
if (position-offset>visible_size) if (position-offset>visible_size)
offset=position-visible_size+1; offset=position-visible_size+1;
goto affichage; goto affichage;
} }
break; break;
case SDLK_BACKSPACE : // Backspace : combinaison de gauche + suppr case SDLK_BACKSPACE : // Backspace : combinaison de gauche + suppr
if (position) if (position)
{ {
position--; position--;
if (offset > 0 && (position == 0 || position < (offset + 1))) if (offset > 0 && (position == 0 || position < (offset + 1)))
offset--; offset--;
Remove_character(str,position); Remove_character(str,position);
size--; size--;
// Effacement de la chaîne // Effacement de la chaîne
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
goto affichage; goto affichage;
} }
break; break;
case SDLK_RETURN : case SDLK_RETURN :
break; break;
case KEY_ESC : case KEY_ESC :
// On restaure la chaine initiale // On restaure la chaine initiale
strcpy(str,initial_string); strcpy(str,initial_string);
size=strlen(str); size=strlen(str);
break; break;
default : default :
if (size<max_size) if (size<max_size)
{ {
// On va regarder si l'utilisateur le droit de se servir de cette touche // On va regarder si l'utilisateur le droit de se servir de cette touche
is_authorized=0; // On commence par supposer qu'elle est interdite is_authorized=0; // On commence par supposer qu'elle est interdite
switch(input_type) switch(input_type)
{ {
case 0 : // N'importe quelle chaîne: case 0 : // N'importe quelle chaîne:
if (input_key>=' ' && input_key<= 255) if (input_key>=' ' && input_key<= 255)
is_authorized=1; is_authorized=1;
break; break;
case 1 : // Nombre case 1 : // Nombre
if ( (input_key>='0') && (input_key<='9') ) if ( (input_key>='0') && (input_key<='9') )
is_authorized=1; is_authorized=1;
break; break;
default : // Nom de fichier default : // Nom de fichier
// On regarde si la touche est autorisée // On regarde si la touche est autorisée
if ( Valid_character(input_key)) if ( Valid_character(input_key))
is_authorized=1; is_authorized=1;
} // End du "switch(input_type)" } // End du "switch(input_type)"
// Si la touche était autorisée... // Si la touche était autorisée...
if (is_authorized) if (is_authorized)
{ {
// ... alors on l'insère ... // ... alors on l'insère ...
Insert_character(str,input_key,position/*,size*/); Insert_character(str,input_key,position/*,size*/);
// ce qui augmente la taille de la chaine // ce qui augmente la taille de la chaine
size++; size++;
// et qui risque de déplacer le curseur vers la droite // et qui risque de déplacer le curseur vers la droite
if (size<max_size) if (size<max_size)
{ {
position++; position++;
if (display_string[position-offset]==RIGHT_TRIANGLE_CHARACTER || position-offset>=visible_size) if (display_string[position-offset]==RIGHT_TRIANGLE_CHARACTER || position-offset>=visible_size)
offset++; offset++;
} }
// Enfin, on raffiche la chaine // Enfin, on raffiche la chaine
goto affichage; goto affichage;
} // End du test d'autorisation de touche } // End du test d'autorisation de touche
} // End du test de place libre } // End du test de place libre
break; break;
affichage: affichage:
size=strlen(str); size=strlen(str);
// Formatage d'une partie de la chaine (si trop longue pour tenir) // Formatage d'une partie de la chaine (si trop longue pour tenir)
strncpy(display_string, str + offset, visible_size); strncpy(display_string, str + offset, visible_size);
display_string[visible_size]='\0'; display_string[visible_size]='\0';
if (offset>0) if (offset>0)
display_string[0]=LEFT_TRIANGLE_CHARACTER; display_string[0]=LEFT_TRIANGLE_CHARACTER;
if (visible_size + offset + 0 < size ) if (visible_size + offset + 0 < size )
display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER; display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER;
Display_whole_string(x_pos,y_pos,display_string,position - offset); Display_whole_string(x_pos,y_pos,display_string,position - offset);
Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3)); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
} // End du "switch(input_key)" } // End du "switch(input_key)"
Flush_update(); Flush_update();
} // End du "while" } // End du "while"
// Effacement de la chaîne // Effacement de la chaîne
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
// On raffiche la chaine correctement // On raffiche la chaine correctement
if (input_type==1) if (input_type==1)
{ {
if (str[0]=='\0') if (str[0]=='\0')
{ {
strcpy(str,"0"); strcpy(str,"0");
size=1; size=1;
} }
Print_in_window(x_pos+((max_size-size)<<3),y_pos,str,TEXT_COLOR,BACKGROUND_COLOR); Print_in_window(x_pos+((max_size-size)<<3),y_pos,str,TEXT_COLOR,BACKGROUND_COLOR);
} }
else else
{ {
Print_in_window_limited(x_pos,y_pos,str,visible_size,TEXT_COLOR,BACKGROUND_COLOR); Print_in_window_limited(x_pos,y_pos,str,visible_size,TEXT_COLOR,BACKGROUND_COLOR);
} }
Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3)); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
return (input_key==SDLK_RETURN); return (input_key==SDLK_RETURN);
} }

View File

@ -1,44 +1,44 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file readline.h ///@file readline.h
/// Text input functions. /// Text input functions.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// ///
/// Lets the user input a line of text, exit by Esc or Return. /// Lets the user input a line of text, exit by Esc or Return.
/// @param x_pos Coordinates of input, in window coordinates before scaling. /// @param x_pos Coordinates of input, in window coordinates before scaling.
/// @param y_pos Coordinates of input, in window coordinates before scaling. /// @param y_pos Coordinates of input, in window coordinates before scaling.
/// @param str The original string value (will be modified, unless user cancels. /// @param str The original string value (will be modified, unless user cancels.
/// @param visible_size Number of characters visible and editable. /// @param visible_size Number of characters visible and editable.
/// @param input_type 0=string, 1=number, 2=filename (255 editable characters) /// @param input_type 0=string, 1=number, 2=filename (255 editable characters)
/// @return 0 if user cancelled (esc), 1 if accepted (return) /// @return 0 if user cancelled (esc), 1 if accepted (return)
byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type); byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type);
/// ///
/// Lets the user input a line of text, exit by Esc or Return. /// Lets the user input a line of text, exit by Esc or Return.
/// @param x_pos Coordinates of input, in window coordinates before scaling. /// @param x_pos Coordinates of input, in window coordinates before scaling.
/// @param y_pos Coordinates of input, in window coordinates before scaling. /// @param y_pos Coordinates of input, in window coordinates before scaling.
/// @param str The original string value (will be modified, unless user cancels. /// @param str The original string value (will be modified, unless user cancels.
/// @param visible_size Number of characters visible. /// @param visible_size Number of characters visible.
/// @param max_size Number of characters editable. /// @param max_size Number of characters editable.
/// @param input_type 0=string, 1=number, 2=filename (255 editable characters) /// @param input_type 0=string, 1=number, 2=filename (255 editable characters)
/// @return 0 if user cancelled (esc), 1 if accepted (return) /// @return 0 if user cancelled (esc), 1 if accepted (return)
byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_size, byte input_type); byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_size, byte input_type);

View File

@ -1,25 +1,25 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file saveini.h ///@file saveini.h
/// Saving settings in gfx2.ini /// Saving settings in gfx2.ini
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
int Save_INI(T_Config * conf); int Save_INI(T_Config * conf);

364
setup.c
View File

@ -1,182 +1,182 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Peter Gordon Copyright 2008 Peter Gordon
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2008 Franck Charlet Copyright 2008 Franck Charlet
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#if defined(__WIN32__) #if defined(__WIN32__)
#include <windows.h> #include <windows.h>
#include <io.h> // Mingw's _mkdir() #include <io.h> // Mingw's _mkdir()
#elif defined(__macosx__) #elif defined(__macosx__)
#import <corefoundation/corefoundation.h> #import <corefoundation/corefoundation.h>
#import <sys/param.h> #import <sys/param.h>
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
#import <sys/param.h> #import <sys/param.h>
#endif #endif
#include "struct.h" #include "struct.h"
#include "io.h" #include "io.h"
#include "setup.h" #include "setup.h"
int Create_ConfigDirectory(char * config_dir) int Create_ConfigDirectory(char * config_dir)
{ {
#ifdef __WIN32__ #ifdef __WIN32__
// Mingw's mkdir has a weird name and only one argument // Mingw's mkdir has a weird name and only one argument
return _mkdir(config_dir); return _mkdir(config_dir);
#else #else
return mkdir(config_dir,S_IRUSR|S_IWUSR|S_IXUSR); return mkdir(config_dir,S_IRUSR|S_IWUSR|S_IXUSR);
#endif #endif
} }
#if defined(__macosx__) || defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) #if defined(__macosx__) || defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
#define ARG_UNUSED __attribute__((unused)) #define ARG_UNUSED __attribute__((unused))
#else #else
#define ARG_UNUSED #define ARG_UNUSED
#endif #endif
// Determine which directory contains the executable. // Determine which directory contains the executable.
// IN: Main's argv[0], some platforms need it, some don't. // IN: Main's argv[0], some platforms need it, some don't.
// OUT: Write into program_dir. Trailing / or \ is kept. // OUT: Write into program_dir. Trailing / or \ is kept.
// Note : in fact this is only used to check for the datafiles and fonts in // Note : in fact this is only used to check for the datafiles and fonts in
// this same directory. // this same directory.
void Set_program_directory(ARG_UNUSED const char * argv0,char * program_dir) void Set_program_directory(ARG_UNUSED const char * argv0,char * program_dir)
{ {
#undef ARG_UNUSED #undef ARG_UNUSED
// MacOSX // MacOSX
#if defined(__macosx__) #if defined(__macosx__)
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFURLGetFileSystemRepresentation(url,true,(UInt8*)program_dir,MAXPATHLEN); CFURLGetFileSystemRepresentation(url,true,(UInt8*)program_dir,MAXPATHLEN);
CFRelease(url); CFRelease(url);
// Append trailing slash // Append trailing slash
strcat(program_dir ,"/"); strcat(program_dir ,"/");
// AmigaOS and alike: hard-coded volume name. // AmigaOS and alike: hard-coded volume name.
#elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) #elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
strcpy(program_dir,"PROGDIR:"); strcpy(program_dir,"PROGDIR:");
// Others: The part of argv[0] before the executable name. // Others: The part of argv[0] before the executable name.
// Keep the last \ or /. // Keep the last \ or /.
// Note that on Unix, once installed, the executable is called from a shell // Note that on Unix, once installed, the executable is called from a shell
// script sitting in /usr/local/bin/, this allows argv[0] to contain the full // script sitting in /usr/local/bin/, this allows argv[0] to contain the full
// path. On Windows, Mingw32 already provides the full path in all cases. // path. On Windows, Mingw32 already provides the full path in all cases.
#else #else
Extract_path(program_dir, argv0); Extract_path(program_dir, argv0);
#endif #endif
} }
// Determine which directory contains the read-only data. // Determine which directory contains the read-only data.
// IN: The directory containing the executable // IN: The directory containing the executable
// OUT: Write into data_dir. Trailing / or \ is kept. // OUT: Write into data_dir. Trailing / or \ is kept.
void Set_data_directory(const char * program_dir, char * data_dir) void Set_data_directory(const char * program_dir, char * data_dir)
{ {
// On all platforms, data is in the executable's directory // On all platforms, data is in the executable's directory
strcpy(data_dir,program_dir); strcpy(data_dir,program_dir);
// Except MacOSX, here it is stored in a special folder: // Except MacOSX, here it is stored in a special folder:
#if defined(__macosx__) #if defined(__macosx__)
strcat(data_dir,"Contents/Resources/"); strcat(data_dir,"Contents/Resources/");
#endif #endif
} }
// Determine which directory should store the user's configuration. // Determine which directory should store the user's configuration.
// //
// For most Unix and Windows platforms: // For most Unix and Windows platforms:
// If a config file already exists in program_dir, it will return it in priority // If a config file already exists in program_dir, it will return it in priority
// (Useful for development, and possibly for upgrading from DOS version) // (Useful for development, and possibly for upgrading from DOS version)
// If the standard directory doesn't exist yet, this function will attempt // If the standard directory doesn't exist yet, this function will attempt
// to create it ($(HOME)/.grafx2, or %APPDATA%\GrafX2) // to create it ($(HOME)/.grafx2, or %APPDATA%\GrafX2)
// If it cannot be created, this function will return the executable's // If it cannot be created, this function will return the executable's
// own directory. // own directory.
// IN: The directory containing the executable // IN: The directory containing the executable
// OUT: Write into config_dir. Trailing / or \ is kept. // OUT: Write into config_dir. Trailing / or \ is kept.
void Set_config_directory(const char * program_dir, char * config_dir) void Set_config_directory(const char * program_dir, char * config_dir)
{ {
// AmigaOS4 // AmigaOS4
#if defined(__amigaos4__) || defined(__AROS__) #if defined(__amigaos4__) || defined(__AROS__)
strcpy(config_dir,"PROGDIR:"); strcpy(config_dir,"PROGDIR:");
// GP2X // GP2X
#elif defined(__GP2X__) #elif defined(__GP2X__)
// On the GP2X, the program is installed to the sdcard, and we don't want to mess with the system tree which is // On the GP2X, the program is installed to the sdcard, and we don't want to mess with the system tree which is
// on an internal flash chip. So, keep these settings locals. // on an internal flash chip. So, keep these settings locals.
strcpy(config_dir,program_dir); strcpy(config_dir,program_dir);
#else #else
char filename[MAX_PATH_CHARACTERS]; char filename[MAX_PATH_CHARACTERS];
// In priority: check own directory // In priority: check own directory
strcpy(config_dir, program_dir); strcpy(config_dir, program_dir);
strcpy(filename, config_dir); strcpy(filename, config_dir);
strcat(filename, "gfx2.cfg"); strcat(filename, "gfx2.cfg");
if (!File_exists(filename)) if (!File_exists(filename))
{ {
char *config_parent_dir; char *config_parent_dir;
#if defined(__WIN32__) #if defined(__WIN32__)
// "%APPDATA%\GrafX2" // "%APPDATA%\GrafX2"
const char* Config_SubDir = "GrafX2"; const char* Config_SubDir = "GrafX2";
config_parent_dir = getenv("APPDATA"); config_parent_dir = getenv("APPDATA");
#elif defined(__BEOS__) || defined(__HAIKU__) #elif defined(__BEOS__) || defined(__HAIKU__)
// "~/.grafx2", the BeOS way // "~/.grafx2", the BeOS way
const char* Config_SubDir = ".grafx2"; const char* Config_SubDir = ".grafx2";
config_parent_dir = getenv("$HOME"); config_parent_dir = getenv("$HOME");
#elif defined(__macosx__) #elif defined(__macosx__)
// "~/Library/Preferences/com.googlecode.grafx2" // "~/Library/Preferences/com.googlecode.grafx2"
const char* Config_SubDir = "Library/Preferences/com.googlecode.grafx2"; const char* Config_SubDir = "Library/Preferences/com.googlecode.grafx2";
config_parent_dir = getenv("HOME"); config_parent_dir = getenv("HOME");
#else #else
// "~/.grafx2" // "~/.grafx2"
const char* Config_SubDir = ".grafx2"; const char* Config_SubDir = ".grafx2";
config_parent_dir = getenv("HOME"); config_parent_dir = getenv("HOME");
#endif #endif
if (config_parent_dir && config_parent_dir[0]!='\0') if (config_parent_dir && config_parent_dir[0]!='\0')
{ {
int size = strlen(config_parent_dir); int size = strlen(config_parent_dir);
strcpy(config_dir, config_parent_dir); strcpy(config_dir, config_parent_dir);
if (config_parent_dir[size-1] != '\\' && config_parent_dir[size-1] != '/') if (config_parent_dir[size-1] != '\\' && config_parent_dir[size-1] != '/')
{ {
strcat(config_dir,PATH_SEPARATOR); strcat(config_dir,PATH_SEPARATOR);
} }
strcat(config_dir,Config_SubDir); strcat(config_dir,Config_SubDir);
if (Directory_exists(config_dir)) if (Directory_exists(config_dir))
{ {
// Répertoire trouvé, ok // Répertoire trouvé, ok
strcat(config_dir,PATH_SEPARATOR); strcat(config_dir,PATH_SEPARATOR);
} }
else else
{ {
// Tentative de création // Tentative de création
if (!Create_ConfigDirectory(config_dir)) if (!Create_ConfigDirectory(config_dir))
{ {
// Réussi // Réussi
strcat(config_dir,PATH_SEPARATOR); strcat(config_dir,PATH_SEPARATOR);
} }
else else
{ {
// Echec: on se rabat sur le repertoire de l'executable. // Echec: on se rabat sur le repertoire de l'executable.
strcpy(config_dir,program_dir); strcpy(config_dir,program_dir);
} }
} }
} }
} }
#endif #endif
} }

108
setup.h
View File

@ -1,54 +1,54 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Peter Gordon Copyright 2008 Peter Gordon
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2008 Franck Charlet Copyright 2008 Franck Charlet
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file setup.h ///@file setup.h
/// Functions that determine where grafx2 is running, finds its data, and /// Functions that determine where grafx2 is running, finds its data, and
/// reads and writes configuration files. /// reads and writes configuration files.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// ///
/// Determine which directory contains the executable. /// Determine which directory contains the executable.
/// - IN: Main's argv[0], some platforms need it, some don't. /// - IN: Main's argv[0], some platforms need it, some don't.
/// - OUT: Write into program_dir. Trailing / or \ is kept. /// - OUT: Write into program_dir. Trailing / or \ is kept.
/// Note : in fact this is only used to check for the datafiles and fonts in this same directory. /// Note : in fact this is only used to check for the datafiles and fonts in this same directory.
void Set_program_directory(const char * argv0,char * program_dir); void Set_program_directory(const char * argv0,char * program_dir);
/// ///
/// Determine which directory contains the read-only data. /// Determine which directory contains the read-only data.
/// IN: The directory containing the executable /// IN: The directory containing the executable
/// OUT: Write into data_dir. Trailing / or \ is kept. /// OUT: Write into data_dir. Trailing / or \ is kept.
void Set_data_directory(const char * program_dir, char * data_dir); void Set_data_directory(const char * program_dir, char * data_dir);
/// ///
/// Determine which directory should store the user's configuration. /// Determine which directory should store the user's configuration.
/// For most Unix and Windows platforms: /// For most Unix and Windows platforms:
/// If a config file already exists in program_dir, it will return it in priority /// If a config file already exists in program_dir, it will return it in priority
/// (Useful for development, and possibly for upgrading from DOS version) /// (Useful for development, and possibly for upgrading from DOS version)
/// If the standard directory doesn't exist yet, this function will attempt /// If the standard directory doesn't exist yet, this function will attempt
/// to create it ($(HOME)/.grafx2, or %APPDATA%\\GrafX2) /// to create it ($(HOME)/.grafx2, or %APPDATA%\\GrafX2)
/// If it cannot be created, this function will return the executable's /// If it cannot be created, this function will return the executable's
/// own directory. /// own directory.
/// IN: The directory containing the executable /// IN: The directory containing the executable
/// OUT: Write into config_dir. Trailing / or \ is kept. /// OUT: Write into config_dir. Trailing / or \ is kept.
void Set_config_directory(const char * program_dir, char * config_dir); void Set_config_directory(const char * program_dir, char * config_dir);

64
shade.h
View File

@ -1,32 +1,32 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file shade.h ///@file shade.h
/// Screens for Shade and Quick-shade settings. /// Screens for Shade and Quick-shade settings.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef SHADE_H_INCLUDED #ifndef SHADE_H_INCLUDED
#define SHADE_H_INCLUDED #define SHADE_H_INCLUDED
void Button_Quick_shade_menu(void); void Button_Quick_shade_menu(void);
int Shade_settings_menu(void); int Shade_settings_menu(void);
#endif // SHADE_H_INCLUDED #endif // SHADE_H_INCLUDED

728
special.c
View File

@ -1,364 +1,364 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "const.h" #include "const.h"
#include "struct.h" #include "struct.h"
#include "global.h" #include "global.h"
#include "graph.h" #include "graph.h"
#include "engine.h" #include "engine.h"
#include "windows.h" #include "windows.h"
#include "special.h" #include "special.h"
//---------------------- Modifier le pinceau spécial ------------------------- //---------------------- Modifier le pinceau spécial -------------------------
void Set_paintbrush_size(int width, int height) void Set_paintbrush_size(int width, int height)
{ {
int x_pos,y_pos; int x_pos,y_pos;
int x,y; int x,y;
float radius2; float radius2;
if (width<1) width=1; if (width<1) width=1;
if (height<1) height=1; if (height<1) height=1;
if (width>MAX_PAINTBRUSH_SIZE) width=MAX_PAINTBRUSH_SIZE; if (width>MAX_PAINTBRUSH_SIZE) width=MAX_PAINTBRUSH_SIZE;
if (height>MAX_PAINTBRUSH_SIZE) height=MAX_PAINTBRUSH_SIZE; if (height>MAX_PAINTBRUSH_SIZE) height=MAX_PAINTBRUSH_SIZE;
Paintbrush_width=width; Paintbrush_width=width;
Paintbrush_height=height; Paintbrush_height=height;
Paintbrush_offset_X=Paintbrush_width>>1; Paintbrush_offset_X=Paintbrush_width>>1;
Paintbrush_offset_Y=Paintbrush_height>>1; Paintbrush_offset_Y=Paintbrush_height>>1;
switch (Paintbrush_shape) switch (Paintbrush_shape)
{ {
case PAINTBRUSH_SHAPE_ROUND : case PAINTBRUSH_SHAPE_ROUND :
radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[ radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[
radius2*=radius2; radius2*=radius2;
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
{ {
x=x_pos-Paintbrush_offset_X; x=x_pos-Paintbrush_offset_X;
y=y_pos-Paintbrush_offset_Y; y=y_pos-Paintbrush_offset_Y;
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( ((x*x)+(y*y)) < radius2 ); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( ((x*x)+(y*y)) < radius2 );
} }
break; break;
case PAINTBRUSH_SHAPE_SQUARE : case PAINTBRUSH_SHAPE_SQUARE :
for (x_pos=0,y_pos=0; x_pos<Paintbrush_height; x_pos++,y_pos+=MAX_PAINTBRUSH_SIZE) for (x_pos=0,y_pos=0; x_pos<Paintbrush_height; x_pos++,y_pos+=MAX_PAINTBRUSH_SIZE)
memset(Paintbrush_sprite+y_pos,1,Paintbrush_width); memset(Paintbrush_sprite+y_pos,1,Paintbrush_width);
break; break;
case PAINTBRUSH_SHAPE_SIEVE_ROUND : case PAINTBRUSH_SHAPE_SIEVE_ROUND :
radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[ radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[
radius2*=radius2; radius2*=radius2;
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
{ {
x=x_pos-Paintbrush_offset_X; x=x_pos-Paintbrush_offset_X;
y=y_pos-Paintbrush_offset_Y; y=y_pos-Paintbrush_offset_Y;
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (!((x_pos+y_pos)&1)) && (((x*x)+(y*y)) < radius2)); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (!((x_pos+y_pos)&1)) && (((x*x)+(y*y)) < radius2));
} }
break; break;
case PAINTBRUSH_SHAPE_SIEVE_SQUARE: case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=!((x_pos+y_pos)&1); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=!((x_pos+y_pos)&1);
break; break;
case PAINTBRUSH_SHAPE_PLUS: case PAINTBRUSH_SHAPE_PLUS:
x=Paintbrush_width>>1; x=Paintbrush_width>>1;
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=((x_pos==x) || (y_pos==x)); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=((x_pos==x) || (y_pos==x));
break; break;
case PAINTBRUSH_SHAPE_SLASH: case PAINTBRUSH_SHAPE_SLASH:
x=Paintbrush_width>>1; x=Paintbrush_width>>1;
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(x_pos==(Paintbrush_width-(y_pos+1))); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(x_pos==(Paintbrush_width-(y_pos+1)));
break; break;
case PAINTBRUSH_SHAPE_ANTISLASH: case PAINTBRUSH_SHAPE_ANTISLASH:
x=Paintbrush_width>>1; x=Paintbrush_width>>1;
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(x_pos==y_pos); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(x_pos==y_pos);
break; break;
case PAINTBRUSH_SHAPE_HORIZONTAL_BAR: case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
memset(Paintbrush_sprite,1,Paintbrush_width); memset(Paintbrush_sprite,1,Paintbrush_width);
break; break;
case PAINTBRUSH_SHAPE_VERTICAL_BAR: case PAINTBRUSH_SHAPE_VERTICAL_BAR:
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)]=1; Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)]=1;
break; break;
case PAINTBRUSH_SHAPE_CROSS: case PAINTBRUSH_SHAPE_CROSS:
x=Paintbrush_width>>1; x=Paintbrush_width>>1;
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (x_pos==y_pos) || (x_pos==(Paintbrush_height-(y_pos+1))) ); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (x_pos==y_pos) || (x_pos==(Paintbrush_height-(y_pos+1))) );
break; break;
case PAINTBRUSH_SHAPE_DIAMOND: case PAINTBRUSH_SHAPE_DIAMOND:
x=Paintbrush_width>>1; x=Paintbrush_width>>1;
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
{ {
if (x_pos<=x) if (x_pos<=x)
y=x-x_pos; y=x-x_pos;
else else
y=x_pos-x; y=x_pos-x;
if (y_pos<=x) if (y_pos<=x)
y+=x-y_pos; y+=x-y_pos;
else else
y+=y_pos-x; y+=y_pos-x;
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(y<=x); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(y<=x);
} }
break; break;
case PAINTBRUSH_SHAPE_RANDOM: case PAINTBRUSH_SHAPE_RANDOM:
radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[ radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[
radius2*=radius2; radius2*=radius2;
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
{ {
x=x_pos-Paintbrush_offset_X; x=x_pos-Paintbrush_offset_X;
y=y_pos-Paintbrush_offset_Y; y=y_pos-Paintbrush_offset_Y;
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (((x*x)+(y*y)) < radius2) && (!(rand()&7)) ); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (((x*x)+(y*y)) < radius2) && (!(rand()&7)) );
} }
} }
} }
void Smaller_paintbrush(void) void Smaller_paintbrush(void)
{ {
if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC) if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC)
&& ( (Paintbrush_width>1) && ( (Paintbrush_width>1)
|| (Paintbrush_height>1) ) ) || (Paintbrush_height>1) ) )
{ {
Hide_cursor(); Hide_cursor();
switch (Paintbrush_shape) switch (Paintbrush_shape)
{ {
case PAINTBRUSH_SHAPE_ROUND: case PAINTBRUSH_SHAPE_ROUND:
case PAINTBRUSH_SHAPE_SIEVE_ROUND: case PAINTBRUSH_SHAPE_SIEVE_ROUND:
case PAINTBRUSH_SHAPE_CROSS: case PAINTBRUSH_SHAPE_CROSS:
case PAINTBRUSH_SHAPE_PLUS: case PAINTBRUSH_SHAPE_PLUS:
case PAINTBRUSH_SHAPE_DIAMOND: case PAINTBRUSH_SHAPE_DIAMOND:
case PAINTBRUSH_SHAPE_RANDOM: case PAINTBRUSH_SHAPE_RANDOM:
if (Paintbrush_width&1) if (Paintbrush_width&1)
Set_paintbrush_size(Paintbrush_width-2,Paintbrush_height-2); Set_paintbrush_size(Paintbrush_width-2,Paintbrush_height-2);
else else
Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1); Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1);
break; break;
case PAINTBRUSH_SHAPE_SQUARE: case PAINTBRUSH_SHAPE_SQUARE:
case PAINTBRUSH_SHAPE_SLASH: case PAINTBRUSH_SHAPE_SLASH:
case PAINTBRUSH_SHAPE_ANTISLASH: case PAINTBRUSH_SHAPE_ANTISLASH:
case PAINTBRUSH_SHAPE_SIEVE_SQUARE: case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1); Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1);
break; break;
case PAINTBRUSH_SHAPE_HORIZONTAL_BAR: case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
Set_paintbrush_size(Paintbrush_width-1,1); Set_paintbrush_size(Paintbrush_width-1,1);
break; break;
case PAINTBRUSH_SHAPE_VERTICAL_BAR: case PAINTBRUSH_SHAPE_VERTICAL_BAR:
Set_paintbrush_size(1,Paintbrush_height-1); Set_paintbrush_size(1,Paintbrush_height-1);
} }
Display_paintbrush_in_menu(); Display_paintbrush_in_menu();
Display_cursor(); Display_cursor();
} }
} }
void Bigger_paintbrush(void) void Bigger_paintbrush(void)
{ {
if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC) if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC)
&& ( (Paintbrush_width<MAX_PAINTBRUSH_SIZE) && ( (Paintbrush_width<MAX_PAINTBRUSH_SIZE)
|| (Paintbrush_height<MAX_PAINTBRUSH_SIZE) ) ) || (Paintbrush_height<MAX_PAINTBRUSH_SIZE) ) )
{ {
Hide_cursor(); Hide_cursor();
switch (Paintbrush_shape) switch (Paintbrush_shape)
{ {
case PAINTBRUSH_SHAPE_ROUND: case PAINTBRUSH_SHAPE_ROUND:
case PAINTBRUSH_SHAPE_SIEVE_ROUND: case PAINTBRUSH_SHAPE_SIEVE_ROUND:
case PAINTBRUSH_SHAPE_RANDOM: case PAINTBRUSH_SHAPE_RANDOM:
case PAINTBRUSH_SHAPE_CROSS: case PAINTBRUSH_SHAPE_CROSS:
case PAINTBRUSH_SHAPE_PLUS: case PAINTBRUSH_SHAPE_PLUS:
case PAINTBRUSH_SHAPE_DIAMOND: case PAINTBRUSH_SHAPE_DIAMOND:
if (Paintbrush_width&1) if (Paintbrush_width&1)
Set_paintbrush_size(Paintbrush_width+2,Paintbrush_height+2); Set_paintbrush_size(Paintbrush_width+2,Paintbrush_height+2);
else else
Set_paintbrush_size(Paintbrush_width+1,Paintbrush_height+1); Set_paintbrush_size(Paintbrush_width+1,Paintbrush_height+1);
break; break;
case PAINTBRUSH_SHAPE_SQUARE: case PAINTBRUSH_SHAPE_SQUARE:
case PAINTBRUSH_SHAPE_SLASH: case PAINTBRUSH_SHAPE_SLASH:
case PAINTBRUSH_SHAPE_ANTISLASH: case PAINTBRUSH_SHAPE_ANTISLASH:
case PAINTBRUSH_SHAPE_SIEVE_SQUARE: case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
Set_paintbrush_size(Paintbrush_width+1,Paintbrush_height+1); Set_paintbrush_size(Paintbrush_width+1,Paintbrush_height+1);
break; break;
case PAINTBRUSH_SHAPE_HORIZONTAL_BAR: case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
Set_paintbrush_size(Paintbrush_width+1,1); Set_paintbrush_size(Paintbrush_width+1,1);
break; break;
case PAINTBRUSH_SHAPE_VERTICAL_BAR: case PAINTBRUSH_SHAPE_VERTICAL_BAR:
Set_paintbrush_size(1,Paintbrush_height+1); Set_paintbrush_size(1,Paintbrush_height+1);
} }
Display_paintbrush_in_menu(); Display_paintbrush_in_menu();
Display_cursor(); Display_cursor();
} }
} }
//--------------------- Increase the ForeColor ----------------------- //--------------------- Increase the ForeColor -----------------------
void Special_next_forecolor(void) void Special_next_forecolor(void)
{ {
Hide_cursor(); Hide_cursor();
Set_fore_color(Fore_color+1); Set_fore_color(Fore_color+1);
Display_cursor(); Display_cursor();
} }
//--------------------- Decrease the ForeColor ----------------------- //--------------------- Decrease the ForeColor -----------------------
void Special_previous_forecolor(void) void Special_previous_forecolor(void)
{ {
Hide_cursor(); Hide_cursor();
Set_fore_color(Fore_color-1); Set_fore_color(Fore_color-1);
Display_cursor(); Display_cursor();
} }
//--------------------- Increase the BackColor ----------------------- //--------------------- Increase the BackColor -----------------------
void Special_next_backcolor(void) void Special_next_backcolor(void)
{ {
Hide_cursor(); Hide_cursor();
Set_back_color(Back_color+1); Set_back_color(Back_color+1);
Display_cursor(); Display_cursor();
} }
//--------------------- Decrease the BackColor ----------------------- //--------------------- Decrease the BackColor -----------------------
void Special_previous_backcolor(void) void Special_previous_backcolor(void)
{ {
Hide_cursor(); Hide_cursor();
Set_back_color(Back_color-1); Set_back_color(Back_color-1);
Display_cursor(); Display_cursor();
} }
/// Picks the next foreground color, according to current shade table /// Picks the next foreground color, according to current shade table
void Special_next_user_forecolor(void) void Special_next_user_forecolor(void)
{ {
Hide_cursor(); Hide_cursor();
Set_fore_color(Shade_table_left[Fore_color]); Set_fore_color(Shade_table_left[Fore_color]);
Display_cursor(); Display_cursor();
} }
/// Picks the previous foreground color, according to current shade table /// Picks the previous foreground color, according to current shade table
void Special_previous_user_forecolor(void) void Special_previous_user_forecolor(void)
{ {
Hide_cursor(); Hide_cursor();
Set_fore_color(Shade_table_right[Fore_color]); Set_fore_color(Shade_table_right[Fore_color]);
Display_cursor(); Display_cursor();
} }
/// Picks the next background color, according to current shade table /// Picks the next background color, according to current shade table
void Special_next_user_backcolor(void) void Special_next_user_backcolor(void)
{ {
Hide_cursor(); Hide_cursor();
Set_back_color(Shade_table_left[Back_color]); Set_back_color(Shade_table_left[Back_color]);
Display_cursor(); Display_cursor();
} }
/// Picks the previous background color, according to current shade table /// Picks the previous background color, according to current shade table
void Special_previous_user_backcolor(void) void Special_previous_user_backcolor(void)
{ {
Hide_cursor(); Hide_cursor();
Set_back_color(Shade_table_right[Back_color]); Set_back_color(Shade_table_right[Back_color]);
Display_cursor(); Display_cursor();
} }
// ------------------- Scroller l'écran (pas en mode loupe) ------------------ // ------------------- Scroller l'écran (pas en mode loupe) ------------------
void Scroll_screen(short delta_x,short delta_y) void Scroll_screen(short delta_x,short delta_y)
{ {
short temp_x_offset; short temp_x_offset;
short temp_y_offset; short temp_y_offset;
temp_x_offset=Main_offset_X+delta_x; temp_x_offset=Main_offset_X+delta_x;
temp_y_offset=Main_offset_Y+delta_y; temp_y_offset=Main_offset_Y+delta_y;
if (temp_x_offset+Screen_width>Main_image_width) if (temp_x_offset+Screen_width>Main_image_width)
temp_x_offset=Main_image_width-Screen_width; temp_x_offset=Main_image_width-Screen_width;
if (temp_y_offset+Menu_Y>Main_image_height) if (temp_y_offset+Menu_Y>Main_image_height)
temp_y_offset=Main_image_height-Menu_Y; temp_y_offset=Main_image_height-Menu_Y;
if (temp_x_offset<0) if (temp_x_offset<0)
temp_x_offset=0; temp_x_offset=0;
if (temp_y_offset<0) if (temp_y_offset<0)
temp_y_offset=0; temp_y_offset=0;
if ( (Main_offset_X!=temp_x_offset) || if ( (Main_offset_X!=temp_x_offset) ||
(Main_offset_Y!=temp_y_offset) ) (Main_offset_Y!=temp_y_offset) )
{ {
Hide_cursor(); Hide_cursor();
Main_offset_X=temp_x_offset; Main_offset_X=temp_x_offset;
Main_offset_Y=temp_y_offset; Main_offset_Y=temp_y_offset;
Compute_limits(); Compute_limits();
Compute_paintbrush_coordinates(); Compute_paintbrush_coordinates();
Display_all_screen(); // <=> Display_screen + Display_image_limits Display_all_screen(); // <=> Display_screen + Display_image_limits
Display_cursor(); Display_cursor();
} }
} }
// ---------------------- Scroller la fenêtre de la loupe -------------------- // ---------------------- Scroller la fenêtre de la loupe --------------------
void Scroll_magnifier(short delta_x,short delta_y) void Scroll_magnifier(short delta_x,short delta_y)
{ {
short temp_x_offset; short temp_x_offset;
short temp_y_offset; short temp_y_offset;
temp_x_offset=Main_magnifier_offset_X+delta_x; temp_x_offset=Main_magnifier_offset_X+delta_x;
temp_y_offset=Main_magnifier_offset_Y+delta_y; temp_y_offset=Main_magnifier_offset_Y+delta_y;
if (temp_x_offset+Main_magnifier_width>Main_image_width) if (temp_x_offset+Main_magnifier_width>Main_image_width)
temp_x_offset=Main_image_width-Main_magnifier_width; temp_x_offset=Main_image_width-Main_magnifier_width;
if (temp_y_offset+Main_magnifier_height>Main_image_height) if (temp_y_offset+Main_magnifier_height>Main_image_height)
temp_y_offset=Main_image_height-Main_magnifier_height; temp_y_offset=Main_image_height-Main_magnifier_height;
if (temp_x_offset<0) if (temp_x_offset<0)
temp_x_offset=0; temp_x_offset=0;
if (temp_y_offset<0) if (temp_y_offset<0)
temp_y_offset=0; temp_y_offset=0;
if ( (Main_magnifier_offset_X!=temp_x_offset) || if ( (Main_magnifier_offset_X!=temp_x_offset) ||
(Main_magnifier_offset_Y!=temp_y_offset) ) (Main_magnifier_offset_Y!=temp_y_offset) )
{ {
Hide_cursor(); Hide_cursor();
Main_magnifier_offset_X=temp_x_offset; Main_magnifier_offset_X=temp_x_offset;
Main_magnifier_offset_Y=temp_y_offset; Main_magnifier_offset_Y=temp_y_offset;
Position_screen_according_to_zoom(); Position_screen_according_to_zoom();
Compute_limits(); Compute_limits();
Compute_paintbrush_coordinates(); Compute_paintbrush_coordinates();
Display_all_screen(); Display_all_screen();
Display_cursor(); Display_cursor();
} }
} }
// -------------- Changer le Zoom (grâce aux touches [+] et [-]) ------------- // -------------- Changer le Zoom (grâce aux touches [+] et [-]) -------------
void Zoom(short delta) void Zoom(short delta)
{ {
short index; short index;
for (index=0; ZOOM_FACTOR[index]!=Main_magnifier_factor; index++); for (index=0; ZOOM_FACTOR[index]!=Main_magnifier_factor; index++);
index+=delta; index+=delta;
if ( (index>=0) && (index<NB_ZOOM_FACTORS) ) if ( (index>=0) && (index<NB_ZOOM_FACTORS) )
{ {
Hide_cursor(); Hide_cursor();
Change_magnifier_factor(index); Change_magnifier_factor(index);
if (Main_magnifier_mode) if (Main_magnifier_mode)
Display_all_screen(); Display_all_screen();
Display_cursor(); Display_cursor();
} }
} }

View File

@ -1,43 +1,43 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file special.h ///@file special.h
/// Editor functions that can be hooked to a keyboard shortcut, but don't have /// Editor functions that can be hooked to a keyboard shortcut, but don't have
/// a menu button associated to them. /// a menu button associated to them.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void Set_paintbrush_size(int width, int height); void Set_paintbrush_size(int width, int height);
void Smaller_paintbrush(void); void Smaller_paintbrush(void);
void Bigger_paintbrush(void); void Bigger_paintbrush(void);
void Special_next_forecolor(void); void Special_next_forecolor(void);
void Special_previous_forecolor(void); void Special_previous_forecolor(void);
void Special_next_backcolor(void); void Special_next_backcolor(void);
void Special_previous_backcolor(void); void Special_previous_backcolor(void);
void Special_next_user_forecolor(void); void Special_next_user_forecolor(void);
void Special_previous_user_forecolor(void); void Special_previous_user_forecolor(void);
void Special_next_user_backcolor(void); void Special_next_user_backcolor(void);
void Special_previous_user_backcolor(void); void Special_previous_user_backcolor(void);
void Scroll_screen(short delta_x,short delta_y); void Scroll_screen(short delta_x,short delta_y);
void Scroll_magnifier(short delta_x,short delta_y); void Scroll_magnifier(short delta_x,short delta_y);
void Zoom(short delta); void Zoom(short delta);

820
struct.h
View File

@ -1,410 +1,410 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file struct.h ///@file struct.h
/// Structures that can be used in the whole program. /// Structures that can be used in the whole program.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef _STRUCT_H_ #ifndef _STRUCT_H_
#define _STRUCT_H_ #define _STRUCT_H_
#if defined(__BEOS__) #if defined(__BEOS__)
#include <inttypes.h> #include <inttypes.h>
#else #else
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "const.h" #include "const.h"
// POSIX calls it strcasecmp, Windows uses stricmp... no ANSI standard. // POSIX calls it strcasecmp, Windows uses stricmp... no ANSI standard.
#ifdef WIN32 #ifdef WIN32
#define strcasecmp stricmp #define strcasecmp stricmp
#endif #endif
// Definition of the base data types // Definition of the base data types
/// 8bit unsigned integer /// 8bit unsigned integer
#define byte uint8_t #define byte uint8_t
/// 16bit unsigned integer /// 16bit unsigned integer
#define word uint16_t #define word uint16_t
/// 32bit unsigned integer /// 32bit unsigned integer
#define dword uint32_t #define dword uint32_t
/// 64bit unsigned integer /// 64bit unsigned integer
#define qword uint64_t #define qword uint64_t
// Named function prototypes // Named function prototypes
typedef void (* Func_action) (void); typedef void (* Func_action) (void);
typedef void (* Func_pixel) (word,word,byte); typedef void (* Func_pixel) (word,word,byte);
typedef byte (* Func_read) (word,word); typedef byte (* Func_read) (word,word);
typedef void (* Func_clear) (byte); typedef void (* Func_clear) (byte);
typedef void (* Func_display) (word,word,word); typedef void (* Func_display) (word,word,word);
typedef byte (* Func_effect) (word,word,byte); typedef byte (* Func_effect) (word,word,byte);
typedef void (* Func_block) (word,word,word,word,byte); typedef void (* Func_block) (word,word,word,word,byte);
typedef void (* Func_line_XOR) (word,word,word); typedef void (* Func_line_XOR) (word,word,word);
typedef void (* Func_display_brush_color) (word,word,word,word,word,word,byte,word); typedef void (* Func_display_brush_color) (word,word,word,word,word,word,byte,word);
typedef void (* Func_display_brush_mono) (word,word,word,word,word,word,byte,byte,word); typedef void (* Func_display_brush_mono) (word,word,word,word,word,word,byte,byte,word);
typedef void (* Func_gradient) (long,short,short); typedef void (* Func_gradient) (long,short,short);
typedef void (* Func_remap) (word,word,word,word,byte *); typedef void (* Func_remap) (word,word,word,word,byte *);
typedef void (* Func_procsline) (word,word,word,byte *); typedef void (* Func_procsline) (word,word,word,byte *);
typedef void (* Func_display_zoom) (word,word,word,byte *); typedef void (* Func_display_zoom) (word,word,word,byte *);
typedef void (* Func_display_brush_color_zoom) (word,word,word,word,word,word,byte,word,byte *); typedef void (* Func_display_brush_color_zoom) (word,word,word,word,word,word,byte,word,byte *);
typedef void (* Func_display_brush_mono_zoom) (word,word,word,word,word,word,byte,byte,word,byte *); typedef void (* Func_display_brush_mono_zoom) (word,word,word,word,word,word,byte,byte,word,byte *);
typedef void (* Func_draw_brush) (byte *,word,word,word,word,word,word,byte,word); typedef void (* Func_draw_brush) (byte *,word,word,word,word,word,word,byte,word);
typedef void (* Func_draw_list_item) (word,word,word,byte); typedef void (* Func_draw_list_item) (word,word,word,byte);
/// A set of RGB values. /// A set of RGB values.
typedef struct typedef struct
{ {
byte R; ///< Red byte R; ///< Red
byte G; ///< Green byte G; ///< Green
byte B; ///< Blue byte B; ///< Blue
}__attribute__ ((__packed__)) T_Components, T_Palette[256]; ///< A complete 256-entry RGB palette (768 bytes). }__attribute__ ((__packed__)) T_Components, T_Palette[256]; ///< A complete 256-entry RGB palette (768 bytes).
/// A normal rectangular button in windows and menus. /// A normal rectangular button in windows and menus.
typedef struct T_Normal_button typedef struct T_Normal_button
{ {
short Number; ///< Unique identifier for all controls short Number; ///< Unique identifier for all controls
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling. word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling. word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
word Width; ///< Width before scaling word Width; ///< Width before scaling
word Height; ///< Height before scaling word Height; ///< Height before scaling
byte Clickable; ///< Boolean, unused. byte Clickable; ///< Boolean, unused.
byte Repeatable; ///< Boolean, true if the button activates repeatedly until you release the mouse button. Used for "+" buttons, for example. byte Repeatable; ///< Boolean, true if the button activates repeatedly until you release the mouse button. Used for "+" buttons, for example.
word Shortcut; ///< Keyboard shortcut that will emulate a click on this button. word Shortcut; ///< Keyboard shortcut that will emulate a click on this button.
struct T_Normal_button * Next;///< Pointer to the next normal button of current window. struct T_Normal_button * Next;///< Pointer to the next normal button of current window.
} T_Normal_button; } T_Normal_button;
/// A window control that shows a complete 256-color palette /// A window control that shows a complete 256-color palette
typedef struct T_Palette_button typedef struct T_Palette_button
{ {
short Number; ///< Unique identifier for all controls short Number; ///< Unique identifier for all controls
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling. word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling. word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
struct T_Palette_button * Next;///< Pointer to the next palette of current window. struct T_Palette_button * Next;///< Pointer to the next palette of current window.
} T_Palette_button; } T_Palette_button;
/// A window control that represents a vertical scrollbar, with a slider, and two arrow buttons. /// A window control that represents a vertical scrollbar, with a slider, and two arrow buttons.
typedef struct T_Scroller_button typedef struct T_Scroller_button
{ {
short Number; ///< Unique identifier for all controls short Number; ///< Unique identifier for all controls
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling. word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling. word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
word Height; ///< Height before scaling. word Height; ///< Height before scaling.
word Nb_elements; ///< Number of distinct values it can take. word Nb_elements; ///< Number of distinct values it can take.
word Nb_visibles; ///< If this slider is meant to show several elements of a collection, this is their number (otherwise, it's 1). word Nb_visibles; ///< If this slider is meant to show several elements of a collection, this is their number (otherwise, it's 1).
word Position; ///< Current position of the slider: which item it's pointing. word Position; ///< Current position of the slider: which item it's pointing.
word Cursor_height; ///< Vertical dimension of the slider, in pixels before scaling. word Cursor_height; ///< Vertical dimension of the slider, in pixels before scaling.
struct T_Scroller_button * Next;///< Pointer to the next scroller of current window. struct T_Scroller_button * Next;///< Pointer to the next scroller of current window.
} T_Scroller_button; } T_Scroller_button;
/// ///
/// A window control that only has a rectangular "active" area which catches mouse clicks, /// A window control that only has a rectangular "active" area which catches mouse clicks,
// but no visible shape. It's used for custom controls where the drawing is done on // but no visible shape. It's used for custom controls where the drawing is done on
// a case by case basis. // a case by case basis.
typedef struct T_Special_button typedef struct T_Special_button
{ {
short Number; ///< Unique identifier for all controls short Number; ///< Unique identifier for all controls
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling. word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling. word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
word Width; ///< Width before scaling word Width; ///< Width before scaling
word Height; ///< Height before scaling word Height; ///< Height before scaling
struct T_Special_button * Next;///< Pointer to the next special button of current window. struct T_Special_button * Next;///< Pointer to the next special button of current window.
} T_Special_button; } T_Special_button;
/// Data for a dropdown item, ie. one proposed choice. /// Data for a dropdown item, ie. one proposed choice.
typedef struct T_Dropdown_choice typedef struct T_Dropdown_choice
{ {
short Number; ///< Value that identifies the choice (for this dropdown only) short Number; ///< Value that identifies the choice (for this dropdown only)
const char * Label; ///< String to display in the dropdown panel const char * Label; ///< String to display in the dropdown panel
struct T_Dropdown_choice * Next;///< Pointer to the next choice for this dropdown. struct T_Dropdown_choice * Next;///< Pointer to the next choice for this dropdown.
} T_Dropdown_choice; } T_Dropdown_choice;
/// A window control that behaves like a dropdown button. /// A window control that behaves like a dropdown button.
typedef struct T_Dropdown_button typedef struct T_Dropdown_button
{ {
short Number; ///< Unique identifier for all controls short Number; ///< Unique identifier for all controls
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling. word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling. word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
word Width; ///< Width before scaling word Width; ///< Width before scaling
word Height; ///< Height before scaling word Height; ///< Height before scaling
byte Display_choice; ///< Boolean, true if the engine should print the selected item's label in the dropdown area when the user chooses it. byte Display_choice; ///< Boolean, true if the engine should print the selected item's label in the dropdown area when the user chooses it.
byte Display_centered; ///< Boolean, true to center the labels (otherwise, align left) byte Display_centered; ///< Boolean, true to center the labels (otherwise, align left)
byte Display_arrow; ///< Boolean, true to display a "down" arrow box in top right byte Display_arrow; ///< Boolean, true to display a "down" arrow box in top right
byte Active_button; ///< Determines which mouse button(s) cause the dropdown panel to open: LEFT_SIDE || RIGHT_SIDE || (LEFT_SIDE|RIGHT_SIDE) byte Active_button; ///< Determines which mouse button(s) cause the dropdown panel to open: LEFT_SIDE || RIGHT_SIDE || (LEFT_SIDE|RIGHT_SIDE)
word Dropdown_width; ///< Width of the dropdown panel when it's open. Use 0 for "same as the dropdown button" word Dropdown_width; ///< Width of the dropdown panel when it's open. Use 0 for "same as the dropdown button"
T_Dropdown_choice * First_item; ///< Linked list with the choices available for this dropdown. T_Dropdown_choice * First_item; ///< Linked list with the choices available for this dropdown.
struct T_Dropdown_button * Next;///< Pointer to the next dropdown button of current window. struct T_Dropdown_button * Next;///< Pointer to the next dropdown button of current window.
} T_Dropdown_button; } T_Dropdown_button;
/// Data for one item (file, directory) in a fileselector. /// Data for one item (file, directory) in a fileselector.
typedef struct T_Fileselector_item typedef struct T_Fileselector_item
{ {
char Short_name[19]; ///< Name to display. char Short_name[19]; ///< Name to display.
char Full_name[256]; ///< Filesystem value. char Full_name[256]; ///< Filesystem value.
byte Type; ///< Type of item: 0 = File, 1 = Directory, 2 = Drive byte Type; ///< Type of item: 0 = File, 1 = Directory, 2 = Drive
struct T_Fileselector_item * Next; ///< Pointer to next item of the current fileselector. struct T_Fileselector_item * Next; ///< Pointer to next item of the current fileselector.
struct T_Fileselector_item * Previous;///< Pointer to previous item of the current fileselector. struct T_Fileselector_item * Previous;///< Pointer to previous item of the current fileselector.
} T_Fileselector_item; } T_Fileselector_item;
/// Data for a fileselector /// Data for a fileselector
typedef struct T_Fileselector typedef struct T_Fileselector
{ {
/// Number of elements in the current fileselector's ::Filelist /// Number of elements in the current fileselector's ::Filelist
short Nb_elements; short Nb_elements;
/// Number of files in the current fileselector's ::Filelist /// Number of files in the current fileselector's ::Filelist
short Nb_files; short Nb_files;
/// Number of directories in the current fileselector's ::Filelist /// Number of directories in the current fileselector's ::Filelist
short Nb_directories; short Nb_directories;
/// Head of the linked list for the fileselector. /// Head of the linked list for the fileselector.
T_Fileselector_item * First; T_Fileselector_item * First;
/// Index for direct access to element number N /// Index for direct access to element number N
T_Fileselector_item ** Index; T_Fileselector_item ** Index;
} T_Fileselector; } T_Fileselector;
typedef struct T_List_button typedef struct T_List_button
{ {
short Number; ///< Unique identifier for all controls short Number; ///< Unique identifier for all controls
short List_start; ///< Index of the font to appear as first line short List_start; ///< Index of the font to appear as first line
short Cursor_position; ///< Index of the selected line (0=top) short Cursor_position; ///< Index of the selected line (0=top)
T_Special_button * Entry_button; ///< Pointer to the associated selection control. T_Special_button * Entry_button; ///< Pointer to the associated selection control.
T_Scroller_button * Scroller; ///< Pointer to the associated scroller T_Scroller_button * Scroller; ///< Pointer to the associated scroller
Func_draw_list_item Draw_list_item; ///< Func_draw_list_item Draw_list_item; ///<
struct T_List_button * Next; ///< Pointer to the next list button of current window. struct T_List_button * Next; ///< Pointer to the next list button of current window.
} T_List_button; } T_List_button;
/// Data for one line of the "Help" screens. /// Data for one line of the "Help" screens.
typedef struct { typedef struct {
char Line_type; ///< Kind of line: 'N' for normal line, 'S' for a bold line, 'K' for a line with keyboard shortcut, 'T' and '-' for upper and lower titles. char Line_type; ///< Kind of line: 'N' for normal line, 'S' for a bold line, 'K' for a line with keyboard shortcut, 'T' and '-' for upper and lower titles.
char * Text; ///< Displayed string. char * Text; ///< Displayed string.
int Line_parameter; ///< Generic parameter depending on line type. For 'K' lines: a shortcut identifier. For others: unused. int Line_parameter; ///< Generic parameter depending on line type. For 'K' lines: a shortcut identifier. For others: unused.
} T_Help_table; } T_Help_table;
/// Data for one section of the "Help" screens, ie a page. /// Data for one section of the "Help" screens, ie a page.
typedef struct typedef struct
{ {
const T_Help_table* Help_table; ///< Pointer to the array of ::T_Help_table that contains the lines const T_Help_table* Help_table; ///< Pointer to the array of ::T_Help_table that contains the lines
word Length; ///< Size of the array of lines word Length; ///< Size of the array of lines
} T_Help_section; } T_Help_section;
/// Data for one setting of gradients. Warning, this one is saved/loaded as binary. /// Data for one setting of gradients. Warning, this one is saved/loaded as binary.
typedef struct typedef struct
{ {
byte Start; ///< First color byte Start; ///< First color
byte End; ///< Last color byte End; ///< Last color
dword Inverse; ///< Boolean, true if the gradient goes in descending order dword Inverse; ///< Boolean, true if the gradient goes in descending order
dword Mix; ///< Amount of randomness to add to the mix (0-255) dword Mix; ///< Amount of randomness to add to the mix (0-255)
dword Technique;///< Gradient technique: 0 (no pattern) 1 (dithering), or 2 (big dithering) dword Technique;///< Gradient technique: 0 (no pattern) 1 (dithering), or 2 (big dithering)
} T_Gradient_array; } T_Gradient_array;
/// Data for one setting of shade. Warning, this one is saved/loaded as binary. /// Data for one setting of shade. Warning, this one is saved/loaded as binary.
typedef struct typedef struct
{ {
word List[512]; ///< List of entries, each one is either a color (0-255) or -1 for empty. word List[512]; ///< List of entries, each one is either a color (0-255) or -1 for empty.
byte Step; ///< Step to increment/decrement on left-clicks. byte Step; ///< Step to increment/decrement on left-clicks.
byte Mode; ///< Shade mode: Normal, Loop, or No-saturation see ::SHADE_MODES byte Mode; ///< Shade mode: Normal, Loop, or No-saturation see ::SHADE_MODES
} T_Shade; } T_Shade;
/// Data for one fullscreen video mode in configuration file. Warning, this one is saved/loaded as binary. /// Data for one fullscreen video mode in configuration file. Warning, this one is saved/loaded as binary.
typedef struct typedef struct
{ {
byte State; ///< How good is the mode supported. 0:Good (white) 1:OK (light) 2:So-so (dark) 4:User-disabled (black); +128 => System doesn't support it at all. byte State; ///< How good is the mode supported. 0:Good (white) 1:OK (light) 2:So-so (dark) 4:User-disabled (black); +128 => System doesn't support it at all.
word Width; ///< Videomode width in pixels. word Width; ///< Videomode width in pixels.
word Height;///< Videomode height in pixels. word Height;///< Videomode height in pixels.
} __attribute__((__packed__)) T_Config_video_mode; } __attribute__((__packed__)) T_Config_video_mode;
/// Header for gfx2.cfg. Warning, this one is saved/loaded as binary. /// Header for gfx2.cfg. Warning, this one is saved/loaded as binary.
typedef struct typedef struct
{ {
char Signature[3]; ///< Signature for the file format. "CFG". char Signature[3]; ///< Signature for the file format. "CFG".
byte Version1; ///< Major version number (ex: 2) byte Version1; ///< Major version number (ex: 2)
byte Version2; ///< Minor version number (ex: 0) byte Version2; ///< Minor version number (ex: 0)
byte Beta1; ///< Major beta version number (ex: 96) byte Beta1; ///< Major beta version number (ex: 96)
byte Beta2; ///< Major beta version number (ex: 5) byte Beta2; ///< Major beta version number (ex: 5)
} __attribute__((__packed__)) T_Config_header; } __attribute__((__packed__)) T_Config_header;
/// Header for a config chunk in for gfx2.cfg. Warning, this one is saved/loaded as binary. /// Header for a config chunk in for gfx2.cfg. Warning, this one is saved/loaded as binary.
typedef struct typedef struct
{ {
byte Number; ///< Section identfier. Possible values are in enum ::CHUNKS_CFG byte Number; ///< Section identfier. Possible values are in enum ::CHUNKS_CFG
word Size; ///< Size of the configuration block that follows, in bytes. word Size; ///< Size of the configuration block that follows, in bytes.
} T_Config_chunk; } T_Config_chunk;
/// Configuration for one keyboard shortcut in gfx2.cfg. Warning, this one is saved/loaded as binary. /// Configuration for one keyboard shortcut in gfx2.cfg. Warning, this one is saved/loaded as binary.
typedef struct typedef struct
{ {
word Number; ///< Indicates the shortcut action. This is a number starting from 0, which matches ::T_Key_config.Number word Number; ///< Indicates the shortcut action. This is a number starting from 0, which matches ::T_Key_config.Number
word Key; ///< Keyboard shortcut: SDLK_something, or -1 for none word Key; ///< Keyboard shortcut: SDLK_something, or -1 for none
word Key2; ///< Alternate keyboard shortcut: SDLK_something, or -1 for none word Key2; ///< Alternate keyboard shortcut: SDLK_something, or -1 for none
} __attribute__((__packed__)) T_Config_shortcut_info; } __attribute__((__packed__)) T_Config_shortcut_info;
/// This structure holds all the settings which are saved and loaded as gfx2.ini. /// This structure holds all the settings which are saved and loaded as gfx2.ini.
typedef struct typedef struct
{ {
char *Font_file; ///< Name of the font used in the menus. Matches file skins/font_*.png (Case-sensitive on some filesystems) char *Font_file; ///< Name of the font used in the menus. Matches file skins/font_*.png (Case-sensitive on some filesystems)
char *Skin_file; ///< String, name of the file where all the graphic data is stored char *Skin_file; ///< String, name of the file where all the graphic data is stored
int Show_hidden_files; ///< Boolean, true to show hidden files in fileselectors. int Show_hidden_files; ///< Boolean, true to show hidden files in fileselectors.
int Show_hidden_directories; ///< Boolean, true to show hidden directories in fileselectors. int Show_hidden_directories; ///< Boolean, true to show hidden directories in fileselectors.
// int Show_system_directories; ///< (removed when converted from DOS) // int Show_system_directories; ///< (removed when converted from DOS)
byte Display_image_limits; ///< Boolean, true to display a dotted line at the borders of the image if it's smaller than screen. byte Display_image_limits; ///< Boolean, true to display a dotted line at the borders of the image if it's smaller than screen.
byte Cursor; ///< Mouse cursor aspect: 1 Solid, 2 Transparent, 3 Thin byte Cursor; ///< Mouse cursor aspect: 1 Solid, 2 Transparent, 3 Thin
byte Maximize_preview; ///< Boolean, true to make previews in fileselector fit the whole rectangle. byte Maximize_preview; ///< Boolean, true to make previews in fileselector fit the whole rectangle.
byte Auto_set_res; ///< Boolean, true to make grafx2 switch to a new resolution whenever you load an image. byte Auto_set_res; ///< Boolean, true to make grafx2 switch to a new resolution whenever you load an image.
byte Coords_rel; ///< Boolean, true to display coordinates as relative (instead of absolute) byte Coords_rel; ///< Boolean, true to display coordinates as relative (instead of absolute)
byte Backup; ///< Boolean, true to backup the original file whenever you save an image. byte Backup; ///< Boolean, true to backup the original file whenever you save an image.
byte Adjust_brush_pick; ///< Boolean, true to omit the right and bottom edges when grabbing a brush in Grid mode. byte Adjust_brush_pick; ///< Boolean, true to omit the right and bottom edges when grabbing a brush in Grid mode.
byte Auto_save; ///< Boolean, true to save configuration when exiting program. byte Auto_save; ///< Boolean, true to save configuration when exiting program.
byte Max_undo_pages; ///< Number of steps to memorize for Undo/Redo. byte Max_undo_pages; ///< Number of steps to memorize for Undo/Redo.
byte Mouse_sensitivity_index_x; ///< Mouse sensitivity in X axis byte Mouse_sensitivity_index_x; ///< Mouse sensitivity in X axis
byte Mouse_sensitivity_index_y; ///< Mouse sensitivity in Y axis byte Mouse_sensitivity_index_y; ///< Mouse sensitivity in Y axis
byte Mouse_fix_factor_X; ///< Mouse correction factor in X axis. byte Mouse_fix_factor_X; ///< Mouse correction factor in X axis.
byte Mouse_fix_factor_Y; ///< Mouse correction factor in Y axis. byte Mouse_fix_factor_Y; ///< Mouse correction factor in Y axis.
byte Mouse_merge_movement; ///< Number of SDL mouse events that are merged into a single change of mouse coordinates. byte Mouse_merge_movement; ///< Number of SDL mouse events that are merged into a single change of mouse coordinates.
byte Delay_left_click_on_slider; ///< Delay (in 1/100s) between two activations of a repeatable button when you hold left-click. byte Delay_left_click_on_slider; ///< Delay (in 1/100s) between two activations of a repeatable button when you hold left-click.
byte Delay_right_click_on_slider; ///< Delay (in 1/100s) between two activations of a repeatable button when you hold left-click. byte Delay_right_click_on_slider; ///< Delay (in 1/100s) between two activations of a repeatable button when you hold left-click.
long Timer_delay; ///< Delay (in 1/55s) before showing a preview in a fileselector. long Timer_delay; ///< Delay (in 1/55s) before showing a preview in a fileselector.
T_Components Fav_menu_colors[4]; ///< Favorite colors to use for the menu. T_Components Fav_menu_colors[4]; ///< Favorite colors to use for the menu.
int Nb_max_vertices_per_polygon; ///< Limit for the number of vertices in polygon tools. int Nb_max_vertices_per_polygon; ///< Limit for the number of vertices in polygon tools.
byte Clear_palette; ///< Boolean, true to reset the palette (to black) before loading an image. byte Clear_palette; ///< Boolean, true to reset the palette (to black) before loading an image.
byte Set_resolution_according_to; ///< When Auto_set_res is on, this determines if the mode should be chosen according to the "original screen" information in the file (1) or the picture dimensons (2) byte Set_resolution_according_to; ///< When Auto_set_res is on, this determines if the mode should be chosen according to the "original screen" information in the file (1) or the picture dimensons (2)
byte Ratio; ///< Determines the scaling of menu and windows: 0 no scaling, 1 scaling, 2 slight scaling. byte Ratio; ///< Determines the scaling of menu and windows: 0 no scaling, 1 scaling, 2 slight scaling.
byte Fast_zoom; ///< Boolean, true if the magnifier shortcut should automatically view the mouse area. byte Fast_zoom; ///< Boolean, true if the magnifier shortcut should automatically view the mouse area.
byte Find_file_fast; ///< In fileselectors, this determines which entries should be sought when typing letters: 0 all, 1 files only, 2 directories only. byte Find_file_fast; ///< In fileselectors, this determines which entries should be sought when typing letters: 0 all, 1 files only, 2 directories only.
byte Separate_colors; ///< Boolean, true if the menu palette should separate color cells with a black outline. byte Separate_colors; ///< Boolean, true if the menu palette should separate color cells with a black outline.
word Palette_cells_X; ///< Number of colors to show in a row of the menu palette. word Palette_cells_X; ///< Number of colors to show in a row of the menu palette.
word Palette_cells_Y; ///< Number of colors to show in a column of the menu palette. word Palette_cells_Y; ///< Number of colors to show in a column of the menu palette.
byte Palette_vertical; ///< Boolean, true if the menu palette should go top to bottom instead of left to right byte Palette_vertical; ///< Boolean, true if the menu palette should go top to bottom instead of left to right
byte FX_Feedback; ///< Boolean, true if drawing effects should read the image being modified (instead of the image before clicking) byte FX_Feedback; ///< Boolean, true if drawing effects should read the image being modified (instead of the image before clicking)
byte Safety_colors; ///< Boolean, true to make the palette automatically re-create menu colors if needed after a "Zap" or color reduction. byte Safety_colors; ///< Boolean, true to make the palette automatically re-create menu colors if needed after a "Zap" or color reduction.
byte Opening_message; ///< Boolean, true to display the splash screen on strtup. byte Opening_message; ///< Boolean, true to display the splash screen on strtup.
byte Clear_with_stencil; ///< Boolean, true to take the stencil into effect (if active) when using the Clear function. byte Clear_with_stencil; ///< Boolean, true to take the stencil into effect (if active) when using the Clear function.
byte Auto_discontinuous; ///< Boolean, true to automatically switch to the discontinuous freehand draw after grabbing a brush. byte Auto_discontinuous; ///< Boolean, true to automatically switch to the discontinuous freehand draw after grabbing a brush.
byte Screen_size_in_GIF; ///< Boolean, true to store current resolution in GIF files. byte Screen_size_in_GIF; ///< Boolean, true to store current resolution in GIF files.
byte Auto_nb_used; ///< Boolean, true to count colors in Palette screen. byte Auto_nb_used; ///< Boolean, true to count colors in Palette screen.
byte Default_resolution; ///< Default video mode to use on startup. Index in ::Video_mode. byte Default_resolution; ///< Default video mode to use on startup. Index in ::Video_mode.
char *Bookmark_directory[NB_BOOKMARKS];///< Bookmarked directories in fileselectors: This is the full dierctory name. char *Bookmark_directory[NB_BOOKMARKS];///< Bookmarked directories in fileselectors: This is the full dierctory name.
char Bookmark_label[NB_BOOKMARKS][8+1];///< Bookmarked directories in fileselectors: This is the displayed name. char Bookmark_label[NB_BOOKMARKS][8+1];///< Bookmarked directories in fileselectors: This is the displayed name.
int Window_pos_x; ///< Last window x position (9999 if unsupportd/irrelevant for the platform) int Window_pos_x; ///< Last window x position (9999 if unsupportd/irrelevant for the platform)
int Window_pos_y; ///< Last window y position (9999 if unsupportd/irrelevant for the platform) int Window_pos_y; ///< Last window y position (9999 if unsupportd/irrelevant for the platform)
word Double_click_speed; ///< Maximum delay for double-click, in ms. word Double_click_speed; ///< Maximum delay for double-click, in ms.
word Double_key_speed; ///< Maximum delay for double-keypress, in ms. word Double_key_speed; ///< Maximum delay for double-keypress, in ms.
} T_Config; } T_Config;
// Structures utilisées pour les descriptions de pages et de liste de pages. // Structures utilisées pour les descriptions de pages et de liste de pages.
// Lorsqu'on gèrera les animations, il faudra aussi des listes de listes de // Lorsqu'on gèrera les animations, il faudra aussi des listes de listes de
// pages. // pages.
// Ces structures sont manipulées à travers des fonctions de gestion du // Ces structures sont manipulées à travers des fonctions de gestion du
// backup dans "graph.c". // backup dans "graph.c".
/// This is the data for one step of Undo/Redo, for one image. /// This is the data for one step of Undo/Redo, for one image.
typedef struct typedef struct
{ {
byte * Image; ///< Pixel data for the image. byte * Image; ///< Pixel data for the image.
int Width; ///< Image width in pixels. int Width; ///< Image width in pixels.
int Height; ///< Image height in pixels. int Height; ///< Image height in pixels.
T_Palette Palette; ///< Image palette. T_Palette Palette; ///< Image palette.
char Comment[COMMENT_SIZE+1]; ///< Comment to store in the image file. char Comment[COMMENT_SIZE+1]; ///< Comment to store in the image file.
char File_directory[MAX_PATH_CHARACTERS];///< Directory that contains the file. char File_directory[MAX_PATH_CHARACTERS];///< Directory that contains the file.
char Filename[MAX_PATH_CHARACTERS]; ///< Filename without directory. char Filename[MAX_PATH_CHARACTERS]; ///< Filename without directory.
byte File_format; ///< File format, in enum ::FILE_FORMATS byte File_format; ///< File format, in enum ::FILE_FORMATS
} T_Page; } T_Page;
/// Collection of undo/redo steps. /// Collection of undo/redo steps.
typedef struct typedef struct
{ {
int List_size; /// Number of ::T_Page in the vector "Pages". int List_size; /// Number of ::T_Page in the vector "Pages".
int Nb_pages_allocated;/// Number of ::T_Page used so far in the vector "Pages". int Nb_pages_allocated;/// Number of ::T_Page used so far in the vector "Pages".
T_Page * Pages; /// Vector of Pages, each one being a undo/redo step. T_Page * Pages; /// Vector of Pages, each one being a undo/redo step.
} T_List_of_pages; } T_List_of_pages;
/// GUI skin data /// GUI skin data
typedef struct typedef struct
{ {
// Mouse // Mouse
/// X coordinate of the mouse cursor's "hot spot". It is < ::CURSOR_SPRITE_WIDTH /// X coordinate of the mouse cursor's "hot spot". It is < ::CURSOR_SPRITE_WIDTH
word Cursor_offset_X[NB_CURSOR_SPRITES]; word Cursor_offset_X[NB_CURSOR_SPRITES];
/// Y coordinate of the mouse cursor's "hot spot". It is < ::CURSOR_SPRITE_HEIGHT /// Y coordinate of the mouse cursor's "hot spot". It is < ::CURSOR_SPRITE_HEIGHT
word Cursor_offset_Y[NB_CURSOR_SPRITES]; word Cursor_offset_Y[NB_CURSOR_SPRITES];
/// Graphic resources for the mouse cursor. /// Graphic resources for the mouse cursor.
byte Cursor_sprite[NB_CURSOR_SPRITES][CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH]; byte Cursor_sprite[NB_CURSOR_SPRITES][CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH];
// Preset paintbrushes // Preset paintbrushes
/// Graphic resources for the preset paintbrushes. /// Graphic resources for the preset paintbrushes.
byte Paintbrush_sprite [NB_PAINTBRUSH_SPRITES][PAINTBRUSH_HEIGHT][PAINTBRUSH_WIDTH]; byte Paintbrush_sprite [NB_PAINTBRUSH_SPRITES][PAINTBRUSH_HEIGHT][PAINTBRUSH_WIDTH];
/// Width of the preset paintbrushes. /// Width of the preset paintbrushes.
word Preset_paintbrush_width[NB_PAINTBRUSH_SPRITES]; word Preset_paintbrush_width[NB_PAINTBRUSH_SPRITES];
/// Height of the preset paintbrushes. /// Height of the preset paintbrushes.
word Preset_paintbrush_height[NB_PAINTBRUSH_SPRITES]; word Preset_paintbrush_height[NB_PAINTBRUSH_SPRITES];
/// Type of the preset paintbrush: index in enum PAINTBRUSH_SHAPES /// Type of the preset paintbrush: index in enum PAINTBRUSH_SHAPES
byte Paintbrush_type[NB_PAINTBRUSH_SPRITES]; byte Paintbrush_type[NB_PAINTBRUSH_SPRITES];
/// Brush handle for the preset brushes. Generally ::Preset_paintbrush_width[]/2 /// Brush handle for the preset brushes. Generally ::Preset_paintbrush_width[]/2
word Preset_paintbrush_offset_X[NB_PAINTBRUSH_SPRITES]; word Preset_paintbrush_offset_X[NB_PAINTBRUSH_SPRITES];
/// Brush handle for the preset brushes. Generally ::Preset_paintbrush_height[]/2 /// Brush handle for the preset brushes. Generally ::Preset_paintbrush_height[]/2
word Preset_paintbrush_offset_Y[NB_PAINTBRUSH_SPRITES]; word Preset_paintbrush_offset_Y[NB_PAINTBRUSH_SPRITES];
// Sieve patterns // Sieve patterns
/// Preset sieve patterns, stored as binary (one word per line) /// Preset sieve patterns, stored as binary (one word per line)
word Sieve_pattern[12][16]; word Sieve_pattern[12][16];
// Menu and other graphics // Menu and other graphics
/// Bitmap data for the menu, a single rectangle. /// Bitmap data for the menu, a single rectangle.
byte Menu_block[MENU_HEIGHT][MENU_WIDTH]; byte Menu_block[MENU_HEIGHT][MENU_WIDTH];
/// Bitmap data for the icons that are displayed over the menu. /// Bitmap data for the icons that are displayed over the menu.
byte Menu_sprite[NB_MENU_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH]; byte Menu_sprite[NB_MENU_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH];
/// Bitmap data for the different "effects" icons. /// Bitmap data for the different "effects" icons.
byte Effect_sprite[NB_EFFECTS_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH]; byte Effect_sprite[NB_EFFECTS_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH];
/// Bitmap data for the Grafx2 logo that appears on splash screen. All 256 colors allowed. /// Bitmap data for the Grafx2 logo that appears on splash screen. All 256 colors allowed.
byte Logo_grafx2[231*56]; byte Logo_grafx2[231*56];
/// Bitmap data for the 6x8 font used in help screens. /// Bitmap data for the 6x8 font used in help screens.
byte Help_font_norm [256][6][8]; byte Help_font_norm [256][6][8];
/// Bitmap data for the 6x8 font used in help screens ("bold" verstion). /// Bitmap data for the 6x8 font used in help screens ("bold" verstion).
byte Bold_font [256][6][8]; byte Bold_font [256][6][8];
// 12 // 12
// 34 // 34
/// Bitmap data for the title font used in help screens. Top-left quarter. /// Bitmap data for the title font used in help screens. Top-left quarter.
byte Help_font_t1 [64][6][8]; byte Help_font_t1 [64][6][8];
/// Bitmap data for the title font used in help screens. Top-right quarter. /// Bitmap data for the title font used in help screens. Top-right quarter.
byte Help_font_t2 [64][6][8]; byte Help_font_t2 [64][6][8];
/// Bitmap data for the title font used in help screens. Bottom-left quarter. /// Bitmap data for the title font used in help screens. Bottom-left quarter.
byte Help_font_t3 [64][6][8]; byte Help_font_t3 [64][6][8];
/// Bitmap data for the title font used in help screens. Bottom-right quarter. /// Bitmap data for the title font used in help screens. Bottom-right quarter.
byte Help_font_t4 [64][6][8]; byte Help_font_t4 [64][6][8];
/// Bitmap data for the small 8x8 icons. /// Bitmap data for the small 8x8 icons.
byte Icon_sprite[NB_ICON_SPRITES][ICON_SPRITE_HEIGHT][ICON_SPRITE_WIDTH]; byte Icon_sprite[NB_ICON_SPRITES][ICON_SPRITE_HEIGHT][ICON_SPRITE_WIDTH];
/// A default 256-color palette. /// A default 256-color palette.
T_Palette Default_palette; T_Palette Default_palette;
} T_Gui_skin; } T_Gui_skin;
#endif #endif

108
text.h
View File

@ -1,54 +1,54 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2008 Adrien Destugues Copyright 2008 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file text.h ///@file text.h
/// Functions related to rendering text as a brush, using TrueType or SFont. /// Functions related to rendering text as a brush, using TrueType or SFont.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// Initialization of text settings, needs to be called once on program startup. /// Initialization of text settings, needs to be called once on program startup.
void Init_text(void); void Init_text(void);
/// Returns true if text.c was compiled with TrueType support. /// Returns true if text.c was compiled with TrueType support.
int TrueType_is_supported(void); int TrueType_is_supported(void);
/// Add a new font to the list to propose to the user. /// Add a new font to the list to propose to the user.
void Add_font(const char *name); void Add_font(const char *name);
/// ///
/// Creates a brush, from the parameters given: /// Creates a brush, from the parameters given:
/// @param str The text to render /// @param str The text to render
/// @param font_number The index of the font to use. Pass 0 for the first font you declared with ::Add_font(), 1 for the second etc. /// @param font_number The index of the font to use. Pass 0 for the first font you declared with ::Add_font(), 1 for the second etc.
/// @param size The size in points (unused for bitmap fonts) /// @param size The size in points (unused for bitmap fonts)
/// @param antialias Boolean, true to use antialiasing in TrueType /// @param antialias Boolean, true to use antialiasing in TrueType
/// @param bold Boolean, true to use bold rendering in TrueType /// @param bold Boolean, true to use bold rendering in TrueType
/// @param italic Boolean, true to use italic rendering in TrueType /// @param italic Boolean, true to use italic rendering in TrueType
/// @param width Returns the width of the created brush, in pixels. /// @param width Returns the width of the created brush, in pixels.
/// @param height Returns the height of the created brush, in pixels. /// @param height Returns the height of the created brush, in pixels.
/// Returns true on success. /// Returns true on success.
byte *Render_text(const char *str, int font_number, int size, int antialias, int bold, int italic, int *width, int *height); byte *Render_text(const char *str, int font_number, int size, int antialias, int bold, int italic, int *width, int *height);
/// Finds a label to display for a font declared with ::Add_font(). /// Finds a label to display for a font declared with ::Add_font().
char * Font_label(int index); char * Font_label(int index);
/// Finds the filename of a font declared with ::Add_font(). /// Finds the filename of a font declared with ::Add_font().
char * Font_name(int index); char * Font_name(int index);
/// Returns true if the font of this number is TrueType, false if it's a SFont bitmap. /// Returns true if the font of this number is TrueType, false if it's a SFont bitmap.
char * TrueType_font(int index); char * TrueType_font(int index);
/// ///
/// Number of fonts declared with a series of ::Add_font(). This is public for /// Number of fonts declared with a series of ::Add_font(). This is public for
/// convenience, but functionaly it is read-only. /// convenience, but functionaly it is read-only.
extern int Nb_fonts; extern int Nb_fonts;

View File

@ -1,409 +1,409 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2009 Yves Rizoud Copyright 2009 Yves Rizoud
Copyright 2009 Adrien Destugues Copyright 2009 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "global.h" #include "global.h"
#include "struct.h" #include "struct.h"
#include "transform.h" #include "transform.h"
#include "engine.h" #include "engine.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "windows.h" #include "windows.h"
#include "input.h" #include "input.h"
#include "help.h" #include "help.h"
#include "misc.h" // Num2str #include "misc.h" // Num2str
#include "readline.h" #include "readline.h"
#include "buttons.h" // Message_out_of_memory() #include "buttons.h" // Message_out_of_memory()
#include "pages.h" // Backup_with_new_dimensions() #include "pages.h" // Backup_with_new_dimensions()
/// Reduces a fraction A/B to its smallest representation. ie (40,60) becomes (2/3) /// Reduces a fraction A/B to its smallest representation. ie (40,60) becomes (2/3)
void Factorize(short *a, short *b) void Factorize(short *a, short *b)
{ {
// Method: brute-force. // Method: brute-force.
short factor; short factor;
factor=2; factor=2;
while (factor<=*a && factor<=*b) while (factor<=*a && factor<=*b)
{ {
if (((*a % factor) == 0) && ((*b % factor) == 0)) if (((*a % factor) == 0) && ((*b % factor) == 0))
{ {
// common factor is found // common factor is found
*a/=factor; *a/=factor;
*b/=factor; *b/=factor;
// restart // restart
factor=2; factor=2;
} }
else else
factor++; factor++;
} }
} }
/// Multiplies original_size by new_ratio/old_ratio, but keeps result in 1-9999 range. /// Multiplies original_size by new_ratio/old_ratio, but keeps result in 1-9999 range.
short Compute_dimension(short original_size, short new_ratio, short old_ratio) short Compute_dimension(short original_size, short new_ratio, short old_ratio)
{ {
long amount; long amount;
amount = (long)original_size*new_ratio/old_ratio; amount = (long)original_size*new_ratio/old_ratio;
if (amount>9999) if (amount>9999)
return 9999; return 9999;
else if (amount<1) else if (amount<1)
return 1; return 1;
else else
return amount; return amount;
} }
void Button_Transform_menu(void) void Button_Transform_menu(void)
{ {
enum RESIZE_UNIT { enum RESIZE_UNIT {
UNIT_PIXELS = 1, UNIT_PIXELS = 1,
UNIT_PERCENT = 2, UNIT_PERCENT = 2,
UNIT_RATIO = 3 UNIT_RATIO = 3
}; };
char buffer[5]; char buffer[5];
short clicked_button; short clicked_button;
const char * unit_label[] = { const char * unit_label[] = {
"", "",
"Pixels ", "Pixels ",
"Percent", "Percent",
"Ratio "}; "Ratio "};
short last_unit_index = -1; short last_unit_index = -1;
short old_ratio_width; short old_ratio_width;
short old_ratio_height; short old_ratio_height;
short new_ratio_width; short new_ratio_width;
short new_ratio_height; short new_ratio_height;
short new_width=Main_image_width; short new_width=Main_image_width;
short new_height=Main_image_height; short new_height=Main_image_height;
byte need_display_size = 0; byte need_display_size = 0;
// Persistent data // Persistent data
static short unit_index = 1; // 1= Pixels, 2= Percent, 3=Ratio static short unit_index = 1; // 1= Pixels, 2= Percent, 3=Ratio
static short ratio_is_locked = 1; // True if X and Y resize should go together static short ratio_is_locked = 1; // True if X and Y resize should go together
T_Dropdown_button * unit_button; T_Dropdown_button * unit_button;
T_Special_button * input_button[4]; T_Special_button * input_button[4];
short *input_value[4]; short *input_value[4];
// Set initial ratio // Set initial ratio
if (unit_index == UNIT_PERCENT) if (unit_index == UNIT_PERCENT)
new_ratio_width=old_ratio_width=new_ratio_height=old_ratio_height=100; new_ratio_width=old_ratio_width=new_ratio_height=old_ratio_height=100;
else else
new_ratio_width=old_ratio_width=new_ratio_height=old_ratio_height=1; new_ratio_width=old_ratio_width=new_ratio_height=old_ratio_height=1;
Open_window(215,165,"Picture transform"); Open_window(215,165,"Picture transform");
Window_display_frame( 5, 15,205,91); Window_display_frame( 5, 15,205,91);
Window_display_frame( 5,110, 55,49); Window_display_frame( 5,110, 55,49);
Window_display_frame(64,110, 85,49); Window_display_frame(64,110, 85,49);
Window_set_normal_button(154,140, 54,14,"Cancel",0,1,KEY_ESC); // 1 Window_set_normal_button(154,140, 54,14,"Cancel",0,1,KEY_ESC); // 1
Print_in_window( 9,114,"Mirror",MC_Dark,MC_Light); Print_in_window( 9,114,"Mirror",MC_Dark,MC_Light);
Window_set_normal_button( 17,125, 27,14,"X\035" ,1,1,SDLK_x); // 2 Window_set_normal_button( 17,125, 27,14,"X\035" ,1,1,SDLK_x); // 2
Window_set_normal_button( 17,140, 27,14,"Y\022" ,1,1,SDLK_y); // 3 Window_set_normal_button( 17,140, 27,14,"Y\022" ,1,1,SDLK_y); // 3
Print_in_window( 84,114,"Rotate",MC_Dark,MC_Light); Print_in_window( 84,114,"Rotate",MC_Dark,MC_Light);
Window_set_normal_button( 69,125, 37,14,"-90°" ,0,1,SDLK_LAST); // 4 Window_set_normal_button( 69,125, 37,14,"-90°" ,0,1,SDLK_LAST); // 4
Window_set_normal_button(107,125, 37,14,"+90°" ,0,1,SDLK_LAST); // 5 Window_set_normal_button(107,125, 37,14,"+90°" ,0,1,SDLK_LAST); // 5
Window_set_normal_button( 69,140, 75,14,"180°" ,0,1,SDLK_LAST); // 6 Window_set_normal_button( 69,140, 75,14,"180°" ,0,1,SDLK_LAST); // 6
Print_in_window( 87, 19,"Resize",MC_Dark,MC_Light); Print_in_window( 87, 19,"Resize",MC_Dark,MC_Light);
Window_set_normal_button( 80, 86, 60,14,"RESIZE",1,1,SDLK_r); // 7 Window_set_normal_button( 80, 86, 60,14,"RESIZE",1,1,SDLK_r); // 7
Print_in_window( 51, 34,"New",MC_Dark,MC_Light); Print_in_window( 51, 34,"New",MC_Dark,MC_Light);
Print_in_window( 96, 34,"Old",MC_Dark,MC_Light); Print_in_window( 96, 34,"Old",MC_Dark,MC_Light);
Print_in_window( 30, 44,"X:",MC_Dark,MC_Light); Print_in_window( 30, 44,"X:",MC_Dark,MC_Light);
Print_in_window( 30, 59,"Y:",MC_Dark,MC_Light); Print_in_window( 30, 59,"Y:",MC_Dark,MC_Light);
Print_in_window( 80, 44,":",MC_Dark,MC_Light); Print_in_window( 80, 44,":",MC_Dark,MC_Light);
Print_in_window( 80, 59,":",MC_Dark,MC_Light); Print_in_window( 80, 59,":",MC_Dark,MC_Light);
Print_in_window( 44, 75,"Lock proportions",MC_Dark,MC_Light); Print_in_window( 44, 75,"Lock proportions",MC_Dark,MC_Light);
Window_set_normal_button( 28, 72, 13,13,ratio_is_locked?"X":" ",0,1,SDLK_l);// 8 Window_set_normal_button( 28, 72, 13,13,ratio_is_locked?"X":" ",0,1,SDLK_l);// 8
unit_button = Window_set_dropdown_button(128,50,69,11,69,unit_label[unit_index],1,0,1,LEFT_SIDE|RIGHT_SIDE);// 9 unit_button = Window_set_dropdown_button(128,50,69,11,69,unit_label[unit_index],1,0,1,LEFT_SIDE|RIGHT_SIDE);// 9
Window_dropdown_add_item(unit_button,UNIT_PIXELS,unit_label[UNIT_PIXELS]); Window_dropdown_add_item(unit_button,UNIT_PIXELS,unit_label[UNIT_PIXELS]);
Window_dropdown_add_item(unit_button,UNIT_PERCENT,unit_label[UNIT_PERCENT]); Window_dropdown_add_item(unit_button,UNIT_PERCENT,unit_label[UNIT_PERCENT]);
Window_dropdown_add_item(unit_button,UNIT_RATIO,unit_label[UNIT_RATIO]); Window_dropdown_add_item(unit_button,UNIT_RATIO,unit_label[UNIT_RATIO]);
input_button[0] = Window_set_input_button(45,43,4); // 10 input_button[0] = Window_set_input_button(45,43,4); // 10
input_button[1] = Window_set_input_button(89,43,4); // 11 input_button[1] = Window_set_input_button(89,43,4); // 11
input_button[2] = Window_set_input_button(45,58,4); // 12 input_button[2] = Window_set_input_button(45,58,4); // 12
input_button[3] = Window_set_input_button(89,58,4); // 13 input_button[3] = Window_set_input_button(89,58,4); // 13
Update_window_area(0,0,Window_width, Window_height); Update_window_area(0,0,Window_width, Window_height);
Display_cursor(); Display_cursor();
do do
{ {
// Display the coordinates with the right unit // Display the coordinates with the right unit
if (last_unit_index != unit_index) if (last_unit_index != unit_index)
{ {
switch(unit_index) switch(unit_index)
{ {
case UNIT_PIXELS: case UNIT_PIXELS:
default: default:
input_value[0]=&new_width; input_value[0]=&new_width;
input_value[1]=&Main_image_width; // Don't worry, it's read-only input_value[1]=&Main_image_width; // Don't worry, it's read-only
input_value[2]=&new_height; input_value[2]=&new_height;
input_value[3]=&Main_image_height; // Don't worry, it's read-only input_value[3]=&Main_image_height; // Don't worry, it's read-only
break; break;
case UNIT_PERCENT: case UNIT_PERCENT:
case UNIT_RATIO: case UNIT_RATIO:
input_value[0]=&new_ratio_width; input_value[0]=&new_ratio_width;
input_value[1]=&old_ratio_width; input_value[1]=&old_ratio_width;
input_value[2]=&new_ratio_height; input_value[2]=&new_ratio_height;
input_value[3]=&old_ratio_height; input_value[3]=&old_ratio_height;
break; break;
} }
need_display_size=1; need_display_size=1;
last_unit_index=unit_index; last_unit_index=unit_index;
} }
if (need_display_size) if (need_display_size)
{ {
short i; short i;
Hide_cursor(); Hide_cursor();
for (i=0;i<4;i++) for (i=0;i<4;i++)
{ {
// "Old" values are not editable, unless the unit is "ratio" // "Old" values are not editable, unless the unit is "ratio"
byte color = ((unit_index!=UNIT_RATIO) && (i==1 || i==3)) ? MC_Dark : MC_Black; byte color = ((unit_index!=UNIT_RATIO) && (i==1 || i==3)) ? MC_Dark : MC_Black;
Num2str(*(input_value[i]),buffer,4); Num2str(*(input_value[i]),buffer,4);
Print_in_window_limited(input_button[i]->Pos_X+2,input_button[i]->Pos_Y+2,buffer,input_button[i]->Width/8,color,MC_Light); Print_in_window_limited(input_button[i]->Pos_X+2,input_button[i]->Pos_Y+2,buffer,input_button[i]->Width/8,color,MC_Light);
} }
Display_cursor(); Display_cursor();
need_display_size=0; need_display_size=0;
} }
clicked_button=Window_clicked_button(); clicked_button=Window_clicked_button();
// Contextual help // Contextual help
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
{ {
Key=0; Key=0;
Window_help(BUTTON_ADJUST, "PICTURE TRANSFORM"); Window_help(BUTTON_ADJUST, "PICTURE TRANSFORM");
} }
else switch(clicked_button) else switch(clicked_button)
{ {
case 9: // Unit case 9: // Unit
switch(Window_attribute2) switch(Window_attribute2)
{ {
case UNIT_PIXELS: case UNIT_PIXELS:
// Do nothing, pixel size was already computed. // Do nothing, pixel size was already computed.
break; break;
case UNIT_PERCENT: case UNIT_PERCENT:
if (unit_index == UNIT_RATIO) if (unit_index == UNIT_RATIO)
{ {
// Approximate from current ratio // Approximate from current ratio
new_ratio_width = Compute_dimension(new_ratio_width,100,old_ratio_width); new_ratio_width = Compute_dimension(new_ratio_width,100,old_ratio_width);
new_ratio_height = Compute_dimension(new_ratio_height,100,old_ratio_height); new_ratio_height = Compute_dimension(new_ratio_height,100,old_ratio_height);
old_ratio_width = 100; old_ratio_width = 100;
old_ratio_height = 100; old_ratio_height = 100;
// Update pixel dimensions, to match percentage exactly // Update pixel dimensions, to match percentage exactly
new_width=Compute_dimension(Main_image_width, new_ratio_width, old_ratio_width); new_width=Compute_dimension(Main_image_width, new_ratio_width, old_ratio_width);
new_height=Compute_dimension(Main_image_height, new_ratio_height, old_ratio_height); new_height=Compute_dimension(Main_image_height, new_ratio_height, old_ratio_height);
} }
else // unit_index == UNIT_PIXELS else // unit_index == UNIT_PIXELS
{ {
// Approximate from current pixel size // Approximate from current pixel size
new_ratio_width = new_width*100/Main_image_width; new_ratio_width = new_width*100/Main_image_width;
new_ratio_height = new_height*100/Main_image_height; new_ratio_height = new_height*100/Main_image_height;
old_ratio_width = 100; old_ratio_width = 100;
old_ratio_height = 100; old_ratio_height = 100;
} }
break; break;
case UNIT_RATIO: case UNIT_RATIO:
if (unit_index == UNIT_PERCENT) if (unit_index == UNIT_PERCENT)
{ {
// Compute simplest ratio from current % // Compute simplest ratio from current %
Factorize(&new_ratio_width, &old_ratio_width); Factorize(&new_ratio_width, &old_ratio_width);
Factorize(&new_ratio_height, &old_ratio_height); Factorize(&new_ratio_height, &old_ratio_height);
} }
else // unit_index == UNIT_PIXELS else // unit_index == UNIT_PIXELS
{ {
// Compute simplest ratio from current pixel size // Compute simplest ratio from current pixel size
new_ratio_width = new_width; new_ratio_width = new_width;
new_ratio_height = new_height; new_ratio_height = new_height;
old_ratio_width = Main_image_width; old_ratio_width = Main_image_width;
old_ratio_height = Main_image_height; old_ratio_height = Main_image_height;
Factorize(&new_ratio_width, &old_ratio_width); Factorize(&new_ratio_width, &old_ratio_width);
Factorize(&new_ratio_height, &old_ratio_height); Factorize(&new_ratio_height, &old_ratio_height);
} }
break; break;
} }
unit_index = Window_attribute2; unit_index = Window_attribute2;
break; break;
case 8: // Lock proportions case 8: // Lock proportions
ratio_is_locked = ! ratio_is_locked; ratio_is_locked = ! ratio_is_locked;
Hide_cursor(); Hide_cursor();
Print_in_window(31,75,(ratio_is_locked)?"X":" ",MC_Black,MC_Light); Print_in_window(31,75,(ratio_is_locked)?"X":" ",MC_Black,MC_Light);
Display_cursor(); Display_cursor();
break; break;
case 11: // input old width case 11: // input old width
case 13: // input old height case 13: // input old height
// "Old" values are not editable, unless the unit is "ratio" // "Old" values are not editable, unless the unit is "ratio"
if (unit_index!=UNIT_RATIO) if (unit_index!=UNIT_RATIO)
break; break;
case 10: // input new width case 10: // input new width
case 12: // input new height case 12: // input new height
Num2str(*( input_value[clicked_button-10]),buffer,4); Num2str(*( input_value[clicked_button-10]),buffer,4);
Hide_cursor(); Hide_cursor();
if (Readline(input_button[clicked_button-10]->Pos_X+2, if (Readline(input_button[clicked_button-10]->Pos_X+2,
input_button[clicked_button-10]->Pos_Y+2, input_button[clicked_button-10]->Pos_Y+2,
buffer, buffer,
4, 4,
1)) 1))
{ {
// Accept entered value // Accept entered value
*(input_value[clicked_button-10])=atoi(buffer); *(input_value[clicked_button-10])=atoi(buffer);
// 0 is not acceptable size // 0 is not acceptable size
if (*(input_value[clicked_button-10])==0) if (*(input_value[clicked_button-10])==0)
{ {
*(input_value[clicked_button-10])=1; *(input_value[clicked_button-10])=1;
} }
// Adapt the other coordinate if X and Y are locked // Adapt the other coordinate if X and Y are locked
if (ratio_is_locked) if (ratio_is_locked)
{ {
if (clicked_button == 10 || clicked_button == 11 ) if (clicked_button == 10 || clicked_button == 11 )
{ {
// Get Y value because X changed // Get Y value because X changed
if (unit_index == UNIT_PIXELS) if (unit_index == UNIT_PIXELS)
{ {
new_height=Compute_dimension(Main_image_height, new_width, Main_image_width); new_height=Compute_dimension(Main_image_height, new_width, Main_image_width);
} }
else else
{ {
// Copy the whole ratio // Copy the whole ratio
new_ratio_height=new_ratio_width; new_ratio_height=new_ratio_width;
old_ratio_height=old_ratio_width; old_ratio_height=old_ratio_width;
} }
} }
else // (clicked_button == 12 || clicked_button == 13) else // (clicked_button == 12 || clicked_button == 13)
{ {
// Get X value because Y changed // Get X value because Y changed
if (unit_index == UNIT_PIXELS) if (unit_index == UNIT_PIXELS)
{ {
new_width=Compute_dimension(Main_image_width, new_height, Main_image_height); new_width=Compute_dimension(Main_image_width, new_height, Main_image_height);
} }
else else
{ {
// Copy the whole ratio // Copy the whole ratio
new_ratio_width=new_ratio_height; new_ratio_width=new_ratio_height;
old_ratio_width=old_ratio_height; old_ratio_width=old_ratio_height;
} }
} }
} }
// Re-compute ratio from size in pixels // Re-compute ratio from size in pixels
if (unit_index == UNIT_PIXELS) if (unit_index == UNIT_PIXELS)
{ {
//new_width=(long)Main_image_width*new_ratio_width/old_ratio_width; //new_width=(long)Main_image_width*new_ratio_width/old_ratio_width;
//new_height=(long)Main_image_height*new_ratio_height/old_ratio_height; //new_height=(long)Main_image_height*new_ratio_height/old_ratio_height;
} }
else // Re-compute size in pixels from ratio else // Re-compute size in pixels from ratio
{ {
new_width=Compute_dimension(Main_image_width,new_ratio_width,old_ratio_width); new_width=Compute_dimension(Main_image_width,new_ratio_width,old_ratio_width);
new_height=Compute_dimension(Main_image_height,new_ratio_height,old_ratio_height); new_height=Compute_dimension(Main_image_height,new_ratio_height,old_ratio_height);
} }
need_display_size=1; need_display_size=1;
} }
Display_cursor(); Display_cursor();
break; break;
} }
} }
while (clicked_button<=0 || clicked_button>=8); while (clicked_button<=0 || clicked_button>=8);
Close_window(); Close_window();
// The Scroll operation uses the same button as transformation menu. // The Scroll operation uses the same button as transformation menu.
if (Current_operation != OPERATION_SCROLL) if (Current_operation != OPERATION_SCROLL)
Unselect_button(BUTTON_ADJUST); Unselect_button(BUTTON_ADJUST);
if (clicked_button != 1) // 1 is Cancel if (clicked_button != 1) // 1 is Cancel
{ {
short old_width; short old_width;
short old_height; short old_height;
// Determine new image dimensions // Determine new image dimensions
switch (clicked_button) switch (clicked_button)
{ {
case 7 : // Resize case 7 : // Resize
// Keep new_width and new_height as entered. // Keep new_width and new_height as entered.
break; break;
case 2 : // Flip X case 2 : // Flip X
case 3 : // Flip Y case 3 : // Flip Y
case 6 : // 180° Rotation case 6 : // 180° Rotation
new_width=Main_image_width; new_width=Main_image_width;
new_height=Main_image_height; new_height=Main_image_height;
break; break;
case 4 : // -90° Rotation case 4 : // -90° Rotation
case 5 : // +90° Rotation case 5 : // +90° Rotation
new_width=Main_image_height; new_width=Main_image_height;
new_height=Main_image_width; new_height=Main_image_width;
break; break;
} }
// Memorize the current dimensions // Memorize the current dimensions
old_width=Main_image_width; old_width=Main_image_width;
old_height=Main_image_height; old_height=Main_image_height;
// Allocate a new page // Allocate a new page
if (Backup_with_new_dimensions(1,new_width,new_height)) if (Backup_with_new_dimensions(1,new_width,new_height))
{ {
// The new image is allocated, the new dimensions are already updated. // The new image is allocated, the new dimensions are already updated.
Main_image_is_modified=1; Main_image_is_modified=1;
// Process the transformation: // Process the transformation:
switch(clicked_button) switch(clicked_button)
{ {
case 2 : // Flip X case 2 : // Flip X
memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height); memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height);
Flip_X_lowlevel(Main_screen, Main_image_width, Main_image_height); Flip_X_lowlevel(Main_screen, Main_image_width, Main_image_height);
break; break;
case 3 : // Flip Y case 3 : // Flip Y
memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height); memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height);
Flip_Y_lowlevel(Main_screen, Main_image_width, Main_image_height); Flip_Y_lowlevel(Main_screen, Main_image_width, Main_image_height);
break; break;
case 4 : // -90° Rotation case 4 : // -90° Rotation
Rotate_270_deg_lowlevel(Screen_backup, Main_screen, old_width, old_height); Rotate_270_deg_lowlevel(Screen_backup, Main_screen, old_width, old_height);
break; break;
case 5 : // +90° Rotation case 5 : // +90° Rotation
Rotate_90_deg_lowlevel(Screen_backup, Main_screen, old_width, old_height); Rotate_90_deg_lowlevel(Screen_backup, Main_screen, old_width, old_height);
break; break;
case 6 : // 180° Rotation case 6 : // 180° Rotation
memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height); memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height);
Rotate_180_deg_lowlevel(Main_screen, Main_image_width, Main_image_height); Rotate_180_deg_lowlevel(Main_screen, Main_image_width, Main_image_height);
break; break;
case 7 : // Resize case 7 : // Resize
Rescale(Screen_backup, old_width, old_height, Main_screen, Main_image_width, Main_image_height, 0, 0); Rescale(Screen_backup, old_width, old_height, Main_screen, Main_image_width, Main_image_height, 0, 0);
break; break;
} }
Display_all_screen(); Display_all_screen();
} }
else else
{ {
Display_cursor(); Display_cursor();
Message_out_of_memory(); Message_out_of_memory();
Hide_cursor(); Hide_cursor();
} }
} }
Display_cursor(); Display_cursor();
} }

View File

@ -1,27 +1,27 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2009 Yves Rizoud Copyright 2009 Yves Rizoud
Copyright 2009 Adrien Destugues Copyright 2009 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file transform.h ///@file transform.h
/// Screen and functions for picture transform. /// Screen and functions for picture transform.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// Opens and handles the Picture transform screen. /// Opens and handles the Picture transform screen.
void Button_Transform_menu(void); void Button_Transform_menu(void);