Example #1
0
DRAWABLE
_request_drawable (COUNT NumFrames, DRAWABLE_TYPE DrawableType,
		CREATE_FLAGS flags, SIZE width, SIZE height)
{
	DRAWABLE Drawable;

	Drawable = AllocDrawableImage (
			NumFrames, DrawableType, flags, width, height
			);
	if (Drawable)
	{
		int imgw, imgh;
		FRAME FramePtr;

		Drawable->Flags = flags;
		Drawable->MaxIndex = NumFrames - 1;

		imgw = width;
		imgh = height;
			
		FramePtr = &Drawable->Frame[NumFrames - 1];
		while (NumFrames--)
		{
			TFB_Image *Image;

			if (DrawableType == RAM_DRAWABLE && imgw > 0 && imgh > 0
					&& (Image = TFB_DrawImage_New (TFB_DrawCanvas_New_TrueColor (
						imgw, imgh, (flags & WANT_ALPHA) ? TRUE : FALSE))))
			{
				FramePtr->image = Image;
			}

			FramePtr->Type = DrawableType;
			FramePtr->Index = NumFrames;
			SetFrameBounds (FramePtr, width, height);
			--FramePtr;
		}
	}

	return (Drawable);
}
Example #2
0
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
}
Example #3
0
static void
process_image (FRAME FramePtr, SDL_Surface *img[], AniData *ani, int cel_ct)
{
	TFB_Image *tfbimg;
	int hx, hy;

	FramePtr->Type = ROM_DRAWABLE;
	FramePtr->Index = cel_ct;

	// handle transparency cases
	if (img[cel_ct]->format->palette)
	{	// indexed color image
		if (ani[cel_ct].transparent_color >= 0)
		    SDL_SetColorKey (img[cel_ct], SDL_SRCCOLORKEY,
					ani[cel_ct].transparent_color);
	}
	else if (img[cel_ct]->format->BitsPerPixel > 8)
	{	// special transparency cases for truecolor images
		if (ani[cel_ct].transparent_color == 0)
			// make RGB=0,0,0 transparent
		    SDL_SetColorKey (img[cel_ct], SDL_SRCCOLORKEY,
					SDL_MapRGBA (img[cel_ct]->format, 0, 0, 0, 0));
	}
	if (ani[cel_ct].transparent_color == -1)
	{	// enforce -1 to mean 'no transparency'
		SDL_SetColorKey (img[cel_ct], 0, 0);
		// 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] = (SDL_Surface *)tfbimg->NormalImg;
	
	FramePtr->HotSpot = MAKE_HOT_SPOT (hx, hy);
	SetFrameBounds (FramePtr, img[cel_ct]->w, img[cel_ct]->h);

#ifdef CLIPDEBUG
	{
		/* for debugging clipping:
		   draws white (or most matching color from palette) pixels to
	       every corner of the image
		 */
		Uint32 color = SDL_MapRGB (img[cel_ct]->format, 255, 255, 255);
		SDL_Rect r = {0, 0, 1, 1};
		if (img[cel_ct]->w > 2 && img[cel_ct]->h > 2)
		{
			SDL_FillRect (img[cel_ct], &r, color);
			r.x = img[cel_ct]->w - 1;
			SDL_FillRect (img[cel_ct], &r, color);
			r.y = img[cel_ct]->h - 1;
			SDL_FillRect (img[cel_ct], &r, color);
			r.x = 0;
			SDL_FillRect (img[cel_ct], &r, color);
		}
	}
#endif
}