[SDL] Dumping a surface to a custom file
bob at pendleton.com
Mon Mar 31 14:26:01 PST 2003
On Mon, 2003-03-31 at 13:52, Atrix Wolfe wrote:
> surface->pitch is the number of pixels per row and surface->h is the number
> of rows in the image, so all you need is:
Pitch is *NOT* always equal to width and can not be used as a substitute
for width. If the address if pixel image(x, y) is pa, then the address
of the pixel at image(x, y + 1) is pa + pitch. You really can't make
assumptions about the relationship between width and pitch except that
pitch is >= (width * bytesPerPixel).
> ----- Original Message -----
> From: "Bradley Bell" <btb at icculus.org>
> To: <sdl at libsdl.org>
> Sent: Monday, March 31, 2003 11:33 AM
> Subject: Re: [SDL] Dumping a surface to a custom file
> > Quoting "Eduardo B. Fonseca" <ebf-sender-5525f7 at aedsolucoes.com.br>:
> > > First of all, (sorry for the newbie question) how can I *really*
> > > the *actual* size of the pixel array on the SDL_Surface? I thought it
> > > be (surface->w + surface->h)*surface->format->BytesPerPixel. I must be
> > > missing something here.
> > surface->pitch * surface->h * surface->format->BytesPerPixel
> > should do it, I think.
> > > I need to keep alpha values and colorkeys on the file, so when I load
> > > image, all is restored. Will a "raw dump" of the surface (keeping the
> > > SDL_PixelFormat and etc) work? If so, how? What about endianess?
> > I believe that endianness will surely be a problem with this method. But
> > you have control over the pixelformat, you can compensate for this by
> > the masks.
> > -brad
> > _______________________________________________
> > SDL mailing list
> > SDL at libsdl.org
> > http://www.libsdl.org/mailman/listinfo/sdl
> SDL mailing list
> SDL at libsdl.org
+ Bob Pendleton: independent writer +
+ and programmer. +
+ email: Bob at Pendleton.com +
More information about the SDL