void TFB_DrawImage_SetMipmap (TFB_Image *img, TFB_Image *mmimg, int hotx, int hoty) { bool imgpal; bool mmpal; if (!img || !mmimg) return; LockMutex (img->mutex); LockMutex (mmimg->mutex); // Either both images must be using the same colormap, or mipmap image // must not be paletted. This restriction is due to the current // implementation of fill-stamp, which replaces the palette with // fill color. imgpal = TFB_DrawCanvas_IsPaletted (img->NormalImg); mmpal = TFB_DrawCanvas_IsPaletted (mmimg->NormalImg); if (!mmpal || (mmpal && imgpal && img->colormap_index == mmimg->colormap_index)) { img->MipmapImg = mmimg->NormalImg; img->MipmapHs.x = hotx; img->MipmapHs.y = hoty; } else { img->MipmapImg = NULL; } UnlockMutex (mmimg->mutex); UnlockMutex (img->mutex); }
void InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME f) { scope_frame = f; if (!scope_init) { TFB_Canvas scope_bg_canvas, scope_surf_canvas; 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 = TFB_DrawImage_New (scope_surf_canvas); TFB_DrawImage_Image (scope_frame->image, 0, 0, 0, NULL, scope_bg); scope_init = 1; } /* remove compiler warnings */ (void) x; (void) y; }
TFB_Image * TFB_DrawImage_New (TFB_Canvas canvas) { TFB_Image *img = HMalloc (sizeof (TFB_Image)); img->mutex = CreateMutex ("image lock", SYNC_CLASS_VIDEO); img->ScaledImg = NULL; img->MipmapImg = NULL; img->FilledImg = NULL; img->colormap_index = -1; img->colormap_version = 0; img->NormalHs = NullHs; img->MipmapHs = NullHs; img->last_scale_hs = NullHs; img->last_scale_type = -1; img->last_scale = 0; img->dirty = FALSE; TFB_DrawCanvas_GetExtent (canvas, &img->extent); if (TFB_DrawCanvas_IsPaletted (canvas)) { img->NormalImg = canvas; } else { img->NormalImg = TFB_DrawCanvas_ToScreenFormat (canvas); } return img; }
static void process_image (FRAME FramePtr, TFB_Canvas img[], AniData *ani, int cel_ct) { TFB_Image *tfbimg; int hx, hy; FramePtr->Type = ROM_DRAWABLE; FramePtr->Index = cel_ct; // handle transparency cases if (TFB_DrawCanvas_IsPaletted (img[cel_ct])) { // indexed color image if (ani[cel_ct].transparent_color >= 0) { TFB_DrawCanvas_SetTransparentIndex (img[cel_ct], ani[cel_ct].transparent_color, FALSE); } } else { // special transparency cases for truecolor images if (ani[cel_ct].transparent_color == 0) { // make RGB=0,0,0 transparent Color color = {0, 0, 0, 0}; TFB_DrawCanvas_SetTransparentColor (img[cel_ct], color, FALSE); } } if (ani[cel_ct].transparent_color == -1) { // enforce -1 to mean 'no transparency' TFB_DrawCanvas_SetTransparentIndex (img[cel_ct], -1, FALSE); // set transparent_color == -2 to use PNG tRNS transparency } hx = ani[cel_ct].hotspot_x; hy = ani[cel_ct].hotspot_y; FramePtr->image = TFB_DrawImage_New (img[cel_ct]); tfbimg = FramePtr->image; tfbimg->colormap_index = ani[cel_ct].colormap_index; img[cel_ct] = tfbimg->NormalImg; FramePtr->HotSpot = MAKE_HOT_SPOT (hx, hy); SetFrameBounds (FramePtr, tfbimg->extent.width, tfbimg->extent.height); #ifdef CLIPDEBUG { /* for debugging clipping: draws white (or most matching color from palette) pixels to every corner of the image */ Color color = {0xff, 0xff, 0xff, 0xff}; RECT r = {{0, 0}, {1, 1}}; if (tfbimg->extent.width > 2 && tfbimg->extent.height > 2) { TFB_DrawImage_Rect (&r, color, tfbimg); r.corner.x = tfbimg->extent.width - 1; TFB_DrawImage_Rect (&r, color, tfbimg); r.corner.y = tfbimg->extent.height - 1; TFB_DrawImage_Rect (&r, color, tfbimg); r.corner.x = 0; TFB_DrawImage_Rect (&r, color, tfbimg); } } #endif }