From 7b651c97b2c983042958d5c43a879338c47f429e Mon Sep 17 00:00:00 2001 From: William Kendrick Date: Wed, 5 Mar 2008 03:26:55 +0000 Subject: [PATCH] * Fixed bug when zooming stamps in video depth other than 32bpp. (Float to int casting; also removes compiler errors.) * getpixel/putpixel function passed to Magic tools now pays attention to the incoming surface, rather than always using the canvas surface, to determine bitdepth. (Fixes bug where some Magic tools, e.g., Grass, didn't work right on video depths other than 32bpp.) --- docs/CHANGES.txt | 6 ++++++ src/tuxpaint.c | 24 +++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index aaa8e7bdc..e2f1af563 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -52,6 +52,12 @@ $Id$ Pere Pujal i Carabantes * Fixed bug when zooming stamps in video depth other than 32bpp. + (Float to int casting; also removes compiler errors.) + + * getpixel/putpixel function passed to Magic tools now pays attention + to the incoming surface, rather than always using the canvas surface, + to determine bitdepth. (Fixes bug where some Magic tools, e.g., Grass, + didn't work right on video depths other than 32bpp.) 2008.February.25 (0.9.19) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index f2a89a68e..8a9b76cc1 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -32,9 +32,9 @@ /* Color depth for Tux Paint to run in, and store canvases in: */ -//#if defined(NOKIA_770) -# define VIDEO_BPP 15 -//#endif +#if defined(NOKIA_770) +# define VIDEO_BPP 16 +#endif #if defined(OLPC_XO) # define VIDEO_BPP 15 @@ -574,6 +574,9 @@ static grid_dims gd_colors; // was 17x1 static int WINDOW_WIDTH, WINDOW_HEIGHT; +void magic_putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel); +Uint32 magic_getpixel(SDL_Surface * surface, int x, int y); + static void setup_normal_screen_layout(void) { @@ -16719,8 +16722,8 @@ void load_magic_plugins(void) magic_api_struct[plc]->sRGB_to_linear = magic_sRGB_to_linear; magic_api_struct[plc]->linear_to_sRGB = magic_linear_to_sRGB; magic_api_struct[plc]->in_circle = in_circle_rad; - magic_api_struct[plc]->getpixel = getpixels[canvas->format->BytesPerPixel]; - magic_api_struct[plc]->putpixel = putpixels[canvas->format->BytesPerPixel]; + magic_api_struct[plc]->getpixel = magic_getpixel; + magic_api_struct[plc]->putpixel = magic_putpixel; magic_api_struct[plc]->line = magic_line_func; magic_api_struct[plc]->playsound = magic_playsound; magic_api_struct[plc]->stopsound = magic_stopsound; @@ -18676,3 +18679,14 @@ int do_color_picker(void) return(chose); } +void magic_putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel) +{ + putpixels[surface->format->BytesPerPixel](surface, x, y, pixel); +} + +Uint32 magic_getpixel(SDL_Surface * surface, int x, int y) +{ + return(getpixels[surface->format->BytesPerPixel](surface, x, y)); +} + +