Creating SDL_PixelFormat

I need to SDL_ConvertSurface few surfaces, so I need SDL_PixelFormat.

How can I create SDL_PixelFormat for depth=24 without creating SDL_Surface?

And if it isn’t possible - how can I copy SDL_PixelFormat (with easy way), so I
could free surface ?–
http://decopter.sf.net - free unrealistic helicopter simulator

If the pixel format you want to use on the conversion is the same as your video surface format, you can user the pixel format field from the video surface itself (use SDL_GetVideoSurface()->format or the video surface pointer you are using), no need to create your own pixel format for the conversion.

Paulo> From: Jacek Pop?awski

I need to SDL_ConvertSurface few surfaces, so I need SDL_PixelFormat.

How can I create SDL_PixelFormat for depth=24 without creating SDL_Surface?

And if it isn’t possible - how can I copy SDL_PixelFormat (with easy way), so I
could free surface ?


http://decopter.sf.net - free unrealistic helicopter simulator


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

I’ve ask how to create PixelFormat without Surface.On Mon, Oct 14, 2002 at 04:14:17PM -0400, pvwr at sympatico.ca wrote:

If the pixel format you want to use on the conversion is the same as your
video surface format,


http://decopter.sf.net - free unrealistic helicopter simulator

Just declare a variable of the right type, or malloc enough storage and
fill in all the fields. Not a problem.

	Bob PendletonOn Mon, 2002-10-14 at 15:38, Jacek Pop?awski wrote:

On Mon, Oct 14, 2002 at 04:14:17PM -0400, pvwr at sympatico.ca wrote:

If the pixel format you want to use on the conversion is the same as your
video surface format,

I’ve ask how to create PixelFormat without Surface.


±-----------------------------------+

Why not just create a SDL_PixelFormat by hand? For 24bpp RGB (little-endian)
in C you could go:

SDL_Format pf = (SDL_PixelFormat)calloc(1, sizeof(SDL_PixelFormat));
pf->BitsPerPixel=24;
pf->BytesPerPixel=3;
pf->Rshift=16;
pf->Gshift=8;
pf->Bshift=0;
pf->Rmask=0xff<<16;
pf->Gmask=0xff<<8;
pf->Bmask=0xff;On Monday 14 October 2002 15:21, Jacek Pop?awski wrote:

I need to SDL_ConvertSurface few surfaces, so I need SDL_PixelFormat.

How can I create SDL_PixelFormat for depth=24 without creating SDL_Surface?


Max Watson <@Max_Watson>

Because it’s not easy way. When I create surface I don’t need to know all that
information. And when I set video mode I don’t even need to know Rmask…

I need it for loading textures into memory in OpenGL program. Sometime texture
is 32bit and I need 24bit format, so I must convert it. My current solution is:
create small surface with depth 24 and use its format. But I think it’s dirty
hack and wonder if there is already something “better”.On Mon, Oct 14, 2002 at 05:21:23PM -0400, Max Watson wrote:

Why not just create a SDL_PixelFormat by hand? For 24bpp RGB (little-endian)
in C you could go:


http://decopter.sf.net - free unrealistic helicopter simulator

If the pixel format you want to use on the conversion is the same as your
video surface format,

I’ve ask how to create PixelFormat without Surface.

I think the answer that everyone here is groping for is ‘no’. There
isn’t any simple function to call that’ll take a couple of simple
parameters and spit out a format for you.

Given that a surface that’s 1x1 of the format you want uses trivially
more memory than the format by itself, you’re probably safest just
biting the bullet and keeping the whole surface. I know it’s gross, and
it feels like a hack… but the alternatives I know of would be to fill
the whole thing out by hand (which you mentioned you didn’t want to do)
or creating a surface and just doing a malloc & memcopy on the surface
and then freeing the surface… which (to me anyway) feels even uglier
than keeping a small surface around.On Mon, 2002-10-14 at 16:38, Jacek Pop?awski wrote:

On Mon, Oct 14, 2002 at 04:14:17PM -0400, pvwr at sympatico.ca wrote:


http://decopter.sf.net - free unrealistic helicopter simulator


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

Jimmy <@Jimmy>
Jimmy’s World.org