From 24b63d16a46c33936edccf10f9392a0102883f38 Mon Sep 17 00:00:00 2001 From: avolkov Date: Fri, 6 May 2005 15:02:23 +0000 Subject: [PATCH] Fix potential crash with truecolor oscill image and make oscill more flexible; bug #729 git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1721 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/oscill.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sc2/src/sc2code/oscill.c b/sc2/src/sc2code/oscill.c index 5b5c51b0c..8bab90292 100644 --- a/sc2/src/sc2code/oscill.c +++ b/sc2/src/sc2code/oscill.c @@ -37,11 +37,21 @@ InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME f) if (!scope_init) { TFB_Canvas scope_bg_canvas, scope_surf_canvas; - scope_bg_canvas = TFB_DrawCanvas_New_Paletted (width, height, - scope_frame->image->Palette, -1); + if (TFB_DrawCanvas_IsPaletted (scope_frame->image->NormalImg)) + { + scope_bg_canvas = TFB_DrawCanvas_New_Paletted (width, height, + scope_frame->image->Palette, -1); + scope_surf_canvas = TFB_DrawCanvas_New_Paletted (width, height, + scope_frame->image->Palette, -1); + } + else + { + scope_bg_canvas = TFB_DrawCanvas_New_ForScreen (width, height, + FALSE); + scope_surf_canvas = TFB_DrawCanvas_New_ForScreen (width, height, + FALSE); + } scope_bg = TFB_DrawImage_New (scope_bg_canvas); - scope_surf_canvas = TFB_DrawCanvas_New_Paletted (width, height, - scope_frame->image->Palette, -1); scope_surf = TFB_DrawImage_New (scope_surf_canvas); TFB_DrawImage_Image (scope_frame->image, 0, 0, 0, NULL, scope_bg); scope_init = 1; @@ -81,9 +91,9 @@ Oscilloscope (DWORD grab_data) if (GetSoundData (scope_data)) { int i, r, g, b; - r = scope_surf->Palette[238].r; - g = scope_surf->Palette[238].g; - b = scope_surf->Palette[238].b; + TFB_DrawCanvas_GetPixel (scope_bg->NormalImg, + scope_bg->extent.width / 2, scope_bg->extent.height / 2, + &r, &g, &b); for (i = 0; i < RADAR_WIDTH - 3; ++i) TFB_DrawImage_Line (i + 1, scope_data[i], i + 2, scope_data[i + 1], r, g, b, scope_surf);