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