From 78adc951137553179058ce136c09758b88ca10c2 Mon Sep 17 00:00:00 2001 From: avolkov Date: Fri, 6 May 2005 14:53:25 +0000 Subject: [PATCH] New GetPixel function git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1720 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/graphics/sdl/canvas.c | 16 ++++++++++++++++ sc2/src/sc2code/libs/graphics/tfb_draw.h | 1 + 2 files changed, 17 insertions(+) diff --git a/sc2/src/sc2code/libs/graphics/sdl/canvas.c b/sc2/src/sc2code/libs/graphics/sdl/canvas.c index 3d6746154..e739e63e9 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/canvas.c +++ b/sc2/src/sc2code/libs/graphics/sdl/canvas.c @@ -1040,6 +1040,22 @@ TFB_DrawCanvas_GetLine (TFB_Canvas canvas, int line) return (uint8*)surf->pixels + surf->pitch * line; } +void +TFB_DrawCanvas_GetPixel (TFB_Canvas canvas, int x, int y, int *r, int *g, int *b) +{ + SDL_Surface* surf = (SDL_Surface *)canvas; + Uint8 ur, ug, ub; + Uint32 pixel; + GetPixelFn getpixel; + + getpixel = getpixel_for(surf); + pixel = (*getpixel)(surf, x, y); + SDL_GetRGB (pixel, surf->format, &ur, &ug, &ub); + *r = ur; + *g = ug; + *b = ub; +} + void TFB_DrawCanvas_Rotate (TFB_Canvas src_canvas, TFB_Canvas dst_canvas, int angle, EXTENT size) { diff --git a/sc2/src/sc2code/libs/graphics/tfb_draw.h b/sc2/src/sc2code/libs/graphics/tfb_draw.h index 8a7519408..1d68f2792 100644 --- a/sc2/src/sc2code/libs/graphics/tfb_draw.h +++ b/sc2/src/sc2code/libs/graphics/tfb_draw.h @@ -126,5 +126,6 @@ void TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, int r, int g, int b, void TFB_DrawCanvas_Initialize (void); void TFB_DrawCanvas_GetScreenFormat (TFB_PixelFormat *fmt); void* TFB_DrawCanvas_GetLine (TFB_Canvas canvas, int line); +void TFB_DrawCanvas_GetPixel (TFB_Canvas canvas, int x, int y, int *r, int *g, int *b); #endif