Added colour option to blackandwhite and threshold magic tools. Since the blackandwhite tool is now the same as tint(with the exception that bandw handles tinting black in a better way) the blackandwhite tool was merged into tint.c and blackandwhite.c removed

This commit is contained in:
Andrew Corcoran 2008-07-20 19:46:08 +00:00
parent c54d6b31a7
commit b2e2289622
6 changed files with 157 additions and 364 deletions

View file

@ -46,8 +46,9 @@ $Id$
implied warranty. implied warranty.
Blur ('entire image' mode), Sharpen, Trace Contour, Silhouette, Blur ('entire image' mode), Sharpen, Trace Contour, Silhouette,
Snow Flake, Snow Ball, Black & White, Threshold Magic tools Snow Flake, Snow Ball, Black & White, Threshold,
and Jigsaw 3x3 and Jigsaw 5x5 starter images. Tint, Noise and Mosaic Magic Tools
Jigsaw 3x3 and Jigsaw 5x5 starter images
by Andrew 'akanewbie' Corcoran <akanewbie@gmail.com> by Andrew 'akanewbie' Corcoran <akanewbie@gmail.com>
Contributed as part of Google Summer of Code, 2008. Contributed as part of Google Summer of Code, 2008.

View file

@ -23,10 +23,11 @@ $Id$
+ Sharpen - Sharpens entire image + Sharpen - Sharpens entire image
+ Trace Contour - Traces the edges of the image, over a white background. + Trace Contour - Traces the edges of the image, over a white background.
+ Silhouette - Creates an outline of the image, over a black background. + Silhouette - Creates an outline of the image, over a black background.
+ Black & White - Removes all color from the image (turns it greyscale). + Threshold - Turns image pure colour & pure white (no grey or color).
+ Threshold - Turns image pure black & pure white (no grey or color).
+ Snow Ball - Places random snow balls over the image. + Snow Ball - Places random snow balls over the image.
+ Snow Flake - Places random snow flakes over the image. + Snow Flake - Places random snow flakes over the image.
+ Noise - Adds random noise to the image.
+ Mosaic - Gives the image a mosaic effect.
By Andrew 'akanewbie' Corcoran <akanewbie@gmail.com> By Andrew 'akanewbie' Corcoran <akanewbie@gmail.com>
(Part of Tux4Kids' participation in Google Summer of Code 2008) (Part of Tux4Kids' participation in Google Summer of Code 2008)

View file

@ -1,262 +0,0 @@
/*
blackAndWhite.c
blackAndWhite, Convert the image to greyscale or threshold it into pure black and pure white
Tux Paint - A simple drawing program for children.
Credits: Andrew Corcoran <akanewbie@gmail.com>
Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com
http://www.tuxpaint.org/
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last updated: July 8, 2008
$Id$
*/
#include <stdio.h>
#include <string.h>
#include <libintl.h>
#include "tp_magic_api.h"
#include "SDL_image.h"
#include "SDL_mixer.h"
#include <math.h>
#include <limits.h>
#ifndef gettext_noop
#define gettext_noop(String) String
#endif
enum {
TOOL_BANDW,
TOOL_THRESHOLD,
bandw_NUM_TOOLS
};
int bandw_min = INT_MAX;
int bandw_max = 0;
const int bandw_RADIUS =16;
static Mix_Chunk * bandw_snd_effect[bandw_NUM_TOOLS];
const char * bandw_snd_filenames[bandw_NUM_TOOLS] = {
"flip.wav",
"flip.wav"
};
const char * bandw_icon_filenames[bandw_NUM_TOOLS] = {
"flip.png",
"flip.png"
};
const char * bandw_names[bandw_NUM_TOOLS] = {
gettext_noop("Black & White"),
gettext_noop("Threshold")
};
const char * bandw_descs[bandw_NUM_TOOLS][2] = {
{gettext_noop("Click and move the mouse around convert the image to greyscale."),
gettext_noop("Click to convert the image to greyscale."),},
{gettext_noop("Click and move the mouse around to threshold the image into black and white regions."),
gettext_noop("Click to threshold the image into black and white regions.")}
};
Uint32 blackAndWhite_api_version(void) { return(TP_MAGIC_API_VERSION); }
//Load sounds
int blackAndWhite_init(magic_api * api){
int i;
char fname[1024];
for (i = 0; i < bandw_NUM_TOOLS; i++){
snprintf(fname, sizeof(fname), "%s/sounds/magic/%s", api->data_directory, bandw_snd_filenames[i]);
bandw_snd_effect[i] = Mix_LoadWAV(fname);
}
return(1);
}
int blackAndWhite_get_tool_count(magic_api * api){
return(bandw_NUM_TOOLS);
}
// Load our icons:
SDL_Surface * blackAndWhite_get_icon(magic_api * api, int which){
char fname[1024];
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, bandw_icon_filenames[which]);
return(IMG_Load(fname));
}
// Return our names, localized:
char * blackAndWhite_get_name(magic_api * api, int which){
return(strdup(gettext(bandw_names[which])));
}
// Return our descriptions, localized:
char * blackAndWhite_get_description(magic_api * api, int which, int mode){
return(strdup(gettext(bandw_descs[which][mode-1])));
}
//Calculates the grey scale value for a rgb pixel
static int blackAndWhite_grey(Uint8 r1,Uint8 g1,Uint8 b1){
return 0.3*r1+.59*g1+0.11*b1;
}
static void do_blackAndWhite_pixel(void * ptr, int which,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y){
magic_api * api = (magic_api *) ptr;
Uint8 r1,g1,b1;
SDL_GetRGB(api->getpixel(last, x, y), last->format, &r1, &g1, &b1);
{
int greyValue = blackAndWhite_grey(r1,g1,b1);
if (which == TOOL_BANDW){
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, greyValue, greyValue, greyValue));
}else{
int thresholdValue = (bandw_max-bandw_min)/2;
if (greyValue < thresholdValue){
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, 0, 0, 0));
}else{
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, 255, 255, 255));
}
}
}
}
// Do the effect:
static void do_blackAndWhite_full(void * ptr,SDL_Surface * canvas, SDL_Surface * last, int which){
magic_api * api = (magic_api *) ptr;
int x,y;
for (y = 0; y < last->h; y++){
for (x=0; x < last->w; x++){
do_blackAndWhite_pixel(ptr, which, canvas, last, x, y);
}
}
}
static void do_blackAndWhite_brush(void * ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y){
int xx, yy;
magic_api * api = (magic_api *) ptr;
for (yy = y - bandw_RADIUS; yy < y + bandw_RADIUS; yy++)
{
for (xx = x - bandw_RADIUS; xx < x + bandw_RADIUS; xx++)
{
if (api->in_circle(xx - x, yy - y, bandw_RADIUS) &&
!api->touched(xx, yy))
{
do_blackAndWhite_pixel(api, which, canvas, last, xx, yy);
}
}
}
}
// Affect the canvas on drag:
void blackAndWhite_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * last, int ox, int oy, int x, int y,
SDL_Rect * update_rect){
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_blackAndWhite_brush);
api->playsound(bandw_snd_effect[which], (x * 255) / canvas->w, 255);
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
update_rect->x = ox - bandw_RADIUS;
update_rect->y = oy - bandw_RADIUS;
update_rect->w = (x + bandw_RADIUS) - update_rect->x;
update_rect->h = (y + bandw_RADIUS) - update_rect->y;
}
// Affect the canvas on click:
void blackAndWhite_click(magic_api * api, int which, int mode,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect){
if (mode == MODE_PAINT)
blackAndWhite_drag(api, which, canvas, last, x, y, x, y, update_rect);
else{
update_rect->x = 0;
update_rect->y = 0;
update_rect->w = canvas->w;
update_rect->h = canvas->h;
do_blackAndWhite_full(api, canvas, last, which);
api->playsound(bandw_snd_effect[which], 128, 255);
}
}
// Affect the canvas on release:
void blackAndWhite_release(magic_api * api, int which,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect)
{
}
// No setup happened:
void blackAndWhite_shutdown(magic_api * api)
{
//Clean up sounds
int i;
for(i=0; i<bandw_NUM_TOOLS; i++){
if(bandw_snd_effect[i] != NULL){
Mix_FreeChunk(bandw_snd_effect[i]);
}
}
}
// Record the color from Tux Paint:
void blackAndWhite_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b)
{
}
// Use colors:
int blackAndWhite_requires_colors(magic_api * api, int which)
{
return 0;
}
void blackAndWhite_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas){
int x,y;
Uint8 r1,g1,b1;
for (y = 0; y < canvas->h; y++){
for (x=0; x < canvas->w; x++){
SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &r1, &g1, &b1);
{
int greyValue = blackAndWhite_grey(r1,g1,b1);
if (greyValue<bandw_min){
bandw_min=greyValue;
}
if (greyValue>bandw_max){
bandw_max=greyValue;
}
}
}
}
}
void blackAndWhite_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
int blackAndWhite_modes(magic_api * api, int which)
{
return(MODE_FULLSCREEN|MODE_PAINT);
}

View file

@ -5,6 +5,8 @@
Requires the mosaicAll sharpen and noise tools. Requires the mosaicAll sharpen and noise tools.
Tux Paint - A simple drawing program for children. Tux Paint - A simple drawing program for children.
Credits: Andrew Corcoran <akanewbie@gmail.com>
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.tuxpaint.org/ http://www.tuxpaint.org/
@ -37,9 +39,6 @@
#include <math.h> #include <math.h>
#include <limits.h> #include <limits.h>
#include <time.h> #include <time.h>
//#include "noise.c"
//#include "sharpen.c"
//#include "blur.c"
#ifndef gettext_noop #ifndef gettext_noop
@ -371,7 +370,7 @@ void mosaic_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
//Sharpen the temp surface //Sharpen the temp surface
for (y = 0; y < canvas->h; y++){ for (y = 0; y < canvas->h; y++){
for (x=0; x < canvas->w; x++){ for (x=0; x < canvas->w; x++){
//We dont want pixels to be affected by already blurred nearby pixels so we require two surfaces //We dont want pixels to be affected by already sharpened pixels so we require two surfaces
mosaic_sharpen_pixel(api, mosaic_final, mosaic_temp, x, y); mosaic_sharpen_pixel(api, mosaic_final, mosaic_temp, x, y);
} }
} }

View file

@ -4,6 +4,8 @@
noise,Add noise the whole image. noise,Add noise the whole image.
Tux Paint - A simple drawing program for children. Tux Paint - A simple drawing program for children.
Credits: Andrew Corcoran <akanewbie@gmail.com>
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.tuxpaint.org/ http://www.tuxpaint.org/

View file

@ -1,9 +1,11 @@
/* /*
tint.c tint.c
Tint Magic Tool Plugin tint, Tin the image into one colour or threshold it into pure colour and white
Tux Paint - A simple drawing program for children. Tux Paint - A simple drawing program for children.
Credits: Andrew Corcoran <akanewbie@gmail.com>
Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.tuxpaint.org/ http://www.tuxpaint.org/
@ -23,113 +25,148 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
Last updated: July 9, 2008 Last updated: July 8, 2008
$Id$ $Id$
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <libintl.h>
#include "tp_magic_api.h" #include "tp_magic_api.h"
#include "SDL_image.h" #include "SDL_image.h"
#include "SDL_mixer.h" #include "SDL_mixer.h"
#include <math.h>
#include <limits.h>
#ifndef gettext_noop
#define gettext_noop(String) String
#endif
/* Our globals: */ enum {
TOOL_TINT,
static Mix_Chunk * tint_snd; TOOL_THRESHOLD,
tint_NUM_TOOLS
};
static Uint8 tint_r, tint_g, tint_b; static Uint8 tint_r, tint_g, tint_b;
static int tint_min = INT_MAX;
static int tint_max = 0;
static const int tint_RADIUS =16;
// No setup required: static Mix_Chunk * tint_snd_effect[tint_NUM_TOOLS];
int tint_init(magic_api * api)
{
char fname[1024];
snprintf(fname, sizeof(fname), "%s/sounds/magic/tint.wav", const char * tint_snd_filenames[tint_NUM_TOOLS] = {
api->data_directory); "tint.wav",
tint_snd = Mix_LoadWAV(fname); "flip.wav"
};
return(1); const char * tint_icon_filenames[tint_NUM_TOOLS] = {
} "tint.png",
"flip.png"
};
const char * tint_names[tint_NUM_TOOLS] = {
gettext_noop("Tint"),
gettext_noop("Threshold")
};
const char * tint_descs[tint_NUM_TOOLS][2] = {
{gettext_noop("Click and move the mouse around to change the color of parts of the picture."),
gettext_noop("Click to change the entire pictures color."),},
{gettext_noop("Click and move the mouse around to threshold the image into pure colour and white regions."),
gettext_noop("Click to threshold the image into pure colour and white regions.")}
};
Uint32 tint_api_version(void) { return(TP_MAGIC_API_VERSION); } Uint32 tint_api_version(void) { return(TP_MAGIC_API_VERSION); }
// We have multiple tools: //Load sounds
int tint_get_tool_count(magic_api * api) int tint_init(magic_api * api){
{ int i;
char fname[1024];
for (i = 0; i < tint_NUM_TOOLS; i++){
snprintf(fname, sizeof(fname), "%s/sounds/magic/%s", api->data_directory, tint_snd_filenames[i]);
tint_snd_effect[i] = Mix_LoadWAV(fname);
}
return(1); return(1);
} }
int tint_get_tool_count(magic_api * api){
return(tint_NUM_TOOLS);
}
// Load our icons: // Load our icons:
SDL_Surface * tint_get_icon(magic_api * api, int which) SDL_Surface * tint_get_icon(magic_api * api, int which){
{
char fname[1024]; char fname[1024];
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, tint_icon_filenames[which]);
snprintf(fname, sizeof(fname), "%s/images/magic/tint.png",
api->data_directory);
return(IMG_Load(fname)); return(IMG_Load(fname));
} }
// Return our names, localized: // Return our names, localized:
char * tint_get_name(magic_api * api, int which) char * tint_get_name(magic_api * api, int which){
{ return(strdup(gettext(tint_names[which])));
return(strdup(gettext_noop("Tint")));
} }
// Return our descriptions, localized: // Return our descriptions, localized:
char * tint_get_description(magic_api * api, int which, int mode) char * tint_get_description(magic_api * api, int which, int mode){
{ return(strdup(gettext(tint_descs[which][mode-1])));
if (mode == MODE_PAINT) }
return(strdup(gettext_noop("Click and move the mouse around to change the color of parts of the picture.")));
else //Calculates the grey scale value for a rgb pixel
return(strdup(gettext_noop("Click to change the entire pictures color."))); static int tint_grey(Uint8 r1,Uint8 g1,Uint8 b1){
return 0.3*r1+.59*g1+0.11*b1;
}
static void do_tint_pixel(void * ptr, int which,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y){
magic_api * api = (magic_api *) ptr;
Uint8 r,g,b;
float h,s,v;
SDL_GetRGB(api->getpixel(last, x, y), last->format, &r, &g, &b);
{
int greyValue = tint_grey(r,g,b);
if (which == TOOL_TINT){
api->rgbtohsv(tint_r, tint_g, tint_b, &h, &s, &v);
api->hsvtorgb(h, s, greyValue/255.0, &r, &g, &b);
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, r, g, b));
}else if (which == TOOL_THRESHOLD){
int thresholdValue = (tint_max-tint_min)/2;
if (greyValue < thresholdValue){
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, tint_r, tint_g, tint_b));
}else{
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, 255, 255, 255));
}
}
}
} }
// Do the effect: // Do the effect:
static void do_tint_full(void * ptr,SDL_Surface * canvas, SDL_Surface * last, int which){
static void do_tint(void * ptr, SDL_Surface * canvas, SDL_Surface * last, magic_api * api = (magic_api *) ptr;
int x, int y)
{
magic_api * api = (magic_api *) ptr;
double rd = api->sRGB_to_linear(tint_r);
double gd = api->sRGB_to_linear(tint_g);
double bd = api->sRGB_to_linear(tint_b);
double old;
Uint8 r, g, b;
/* Get original pixel: */ int x,y;
for (y = 0; y < last->h; y++){
SDL_GetRGB(api->getpixel(last, x, y), last->format, &r, &g, &b); for (x=0; x < last->w; x++){
do_tint_pixel(ptr, which, canvas, last, x, y);
old = api->sRGB_to_linear(r) * 0.2126 + }
api->sRGB_to_linear(g) * 0.7152 + }
api->sRGB_to_linear(b) * 0.0722;
api->putpixel(canvas, x, y,
SDL_MapRGB(canvas->format,
api->linear_to_sRGB(rd * old),
api->linear_to_sRGB(gd * old),
api->linear_to_sRGB(bd * old)));
} }
static void do_tint_brush(void * ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y){
static void do_tint_paint(void * ptr, int which, SDL_Surface * canvas, SDL_Surface * last,
int x, int y)
{
magic_api * api = (magic_api *) ptr;
int xx, yy; int xx, yy;
magic_api * api = (magic_api *) ptr;
for (yy = y - 16; yy < y + 16; yy++) for (yy = y - tint_RADIUS; yy < y + tint_RADIUS; yy++)
{ {
for (xx = x - 16; xx < x + 16; xx++) for (xx = x - tint_RADIUS; xx < x + tint_RADIUS; xx++)
{ {
if (api->in_circle(xx - x, yy - y, 16)) if (api->in_circle(xx - x, yy - y, tint_RADIUS) &&
!api->touched(xx, yy))
{ {
if (!api->touched(xx, yy)) do_tint_pixel(api, which, canvas, last, xx, yy);
{
do_tint(ptr, canvas, last, xx, yy);
}
} }
} }
} }
@ -138,56 +175,54 @@ static void do_tint_paint(void * ptr, int which, SDL_Surface * canvas, SDL_Surfa
// Affect the canvas on drag: // Affect the canvas on drag:
void tint_drag(magic_api * api, int which, SDL_Surface * canvas, void tint_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Surface * last, int ox, int oy, int x, int y,
SDL_Rect * update_rect) SDL_Rect * update_rect){
{
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_tint_paint); api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_tint_brush);
api->playsound(tint_snd_effect[which], (x * 255) / canvas->w, 255);
if (ox > x) { int tmp = ox; ox = x; x = tmp; } if (ox > x) { int tmp = ox; ox = x; x = tmp; }
if (oy > y) { int tmp = oy; oy = y; y = tmp; } if (oy > y) { int tmp = oy; oy = y; y = tmp; }
update_rect->x = ox - 16; update_rect->x = ox - tint_RADIUS;
update_rect->y = oy - 16; update_rect->y = oy - tint_RADIUS;
update_rect->w = (x + 16) - update_rect->x; update_rect->w = (x + tint_RADIUS) - update_rect->x;
update_rect->h = (y + 16) - update_rect->y; update_rect->h = (y + tint_RADIUS) - update_rect->y;
api->playsound(tint_snd, (x * 255) / canvas->w, 255);
} }
// Affect the canvas on click: // Affect the canvas on click:
void tint_click(magic_api * api, int which, int mode, void tint_click(magic_api * api, int which, int mode,
SDL_Surface * canvas, SDL_Surface * last, SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect) int x, int y, SDL_Rect * update_rect){
{
if (mode == MODE_PAINT) if (mode == MODE_PAINT)
tint_drag(api, which, canvas, last, x, y, x, y, update_rect); tint_drag(api, which, canvas, last, x, y, x, y, update_rect);
else else{
{
int xx, yy;
for (yy = 0; yy < canvas->h; yy++)
for (xx = 0; xx < canvas->w; xx++)
do_tint(api, canvas, last, xx, yy);
update_rect->x = 0; update_rect->x = 0;
update_rect->y = 0; update_rect->y = 0;
update_rect->w = canvas->w; update_rect->w = canvas->w;
update_rect->h = canvas->h; update_rect->h = canvas->h;
do_tint_full(api, canvas, last, which);
/* FIXME: Play sfx */ api->playsound(tint_snd_effect[which], 128, 255);
} }
} }
// Affect the canvas on release:
void tint_release(magic_api * api, int which, void tint_release(magic_api * api, int which,
SDL_Surface * canvas, SDL_Surface * last, SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect) int x, int y, SDL_Rect * update_rect)
{ {
} }
// No setup happened:
void tint_shutdown(magic_api * api) void tint_shutdown(magic_api * api)
{ {
if (tint_snd != NULL) //Clean up sounds
Mix_FreeChunk(tint_snd); int i;
for(i=0; i<tint_NUM_TOOLS; i++){
if(tint_snd_effect[i] != NULL){
Mix_FreeChunk(tint_snd_effect[i]);
}
}
} }
// Record the color from Tux Paint: // Record the color from Tux Paint:
@ -204,8 +239,25 @@ int tint_requires_colors(magic_api * api, int which)
return 1; return 1;
} }
void tint_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas) void tint_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas){
{
int x,y;
Uint8 r1,g1,b1;
for (y = 0; y < canvas->h; y++){
for (x=0; x < canvas->w; x++){
SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &r1, &g1, &b1);
{
int greyValue = tint_grey(r1,g1,b1);
if (greyValue<tint_min){
tint_min=greyValue;
}
if (greyValue>tint_max){
tint_max=greyValue;
}
}
}
}
} }
void tint_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas) void tint_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
@ -214,5 +266,5 @@ void tint_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
int tint_modes(magic_api * api, int which) int tint_modes(magic_api * api, int which)
{ {
return(MODE_PAINT | MODE_FULLSCREEN); return(MODE_FULLSCREEN|MODE_PAINT);
} }