Resizing BMP

Hi,

I receive image frames from my firewire camera. These data are made
compatible for SDL_LoadBMP and finally blitted to the screen. 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?

Chris

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.On Wed, 2006-06-07 at 10:22 +0200, Phase GmbH wrote:

Chris


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

Hi Kevin,

thanks. In the meantime I tried SDL_ResizeXY with fastest filter but the
algorithm is too slow for a framerate of about 10 fps (1,4 Mega Pixels,
Black and White). The number of free image buffers allocated by the camera
driver decline to zero which then invoke a fatal error.

Any idea?

Chris> ----- Original Message -----

From: kevinmb500@gawab.com (Kevin Baragona)
To: “Phase GmbH” <@Phase_GmbH>; “A list for developers using the
SDL library. (includes SDL-announce)”
Sent: Thursday, June 08, 2006 1:16 AM
Subject: Re: [SDL] Resizing BMP

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

Hi Kevin,

thanks. In the meantime I tried SDL_ResizeXY with fastest filter but the
algorithm is too slow for a framerate of about 10 fps (1,4 Mega Pixels,
Black and White). The number of free image buffers allocated by the camera
driver decline to zero which then invoke a fatal error.

Try SDL_SoftStretch(), that’s probably good enough for your purposes.

See ya!
-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

Yes, as is mentioned in the library description, the functions really are
only suitable for pre-rendering images, as the functions are not speed
effecient at all. The best ones (Lanczos3) give excellent results, though!
If you can see an easy way to speed up the library, please let me know, and
I’ll update it!
-Dave Olsen> ----- Original Message -----

From: imaging@phase-hl.com (Phase GmbH)
To: “Kevin Baragona” ; “A list for developers using
the SDL library. (includes SDL-announce)”
Sent: Friday, June 09, 2006 9:49 AM
Subject: Re: [SDL] Resizing BMP

Hi Kevin,

thanks. In the meantime I tried SDL_ResizeXY with fastest filter but the
algorithm is too slow for a framerate of about 10 fps (1,4 Mega Pixels,
Black and White). The number of free image buffers allocated by the camera
driver decline to zero which then invoke a fatal error.

Any idea?

Chris

----- Original Message -----

From: “Kevin Baragona”
To: “Phase GmbH” ; “A list for developers using the
SDL library. (includes SDL-announce)”
Sent: Thursday, June 08, 2006 1:16 AM
Subject: Re: [SDL] Resizing BMP

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


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