[SDL] Resizing BMP

Kevin Baragona kevinmb500 at gawab.com
Wed Jun 7 16:16:13 PDT 2006


On Wed, 2006-06-07 at 10:22 +0200, Phase GmbH wrote:
> Hi,
> 
> I receive image frames from my firewire camera. These data are made 
> compatible for SDL_LoadBMP and finally blitted to the screen.
You mean you save each frame into a BMP and load it into a surface?
>  As each frame 
> has about 1.4 MB Pixels it would be highly desireable to down-scale (resize) 
> the frames to let them be dispalyed in a smaller display window. The WINDOWS 
> API does this by function StretchDIBits.
> 
> Is there any comparable function ind SDL?
No. But I have recently been introduced to a collection of functions
David Olsen calls SDL_Resize which you can get here
http://www.libsdl.org/libraries.php?match_id=1714. You can scale using
nearest neighbor, lanczos3, and everything in between. You call the
function SDL_ResizeXY() and tell it the source surface, new dimensions,
and scaling mode (consult the trusty well documented header file). It
returns a pointer to the new surface and frees the old one so you can
call it like this:
SDL_Surface *new = SDL_ResizeXY(old, width, hieght, 1);
That will use nearest neighbor which sounds best for your case.
If you want to crop like StretchDIBits looks like it can, then make a
new smaller surface and blit a portion of the old one into it.

Hope this helps.

> 
> Chris
> 
> 
> 
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl





More information about the SDL mailing list