Image load/save

[…]

Yeah, simple.

remember, BGRA (or ARGB if you listen to Microsoft) was an
extension until OpenGL 1.2 - may or may not exist.
AH CRAP.
I forgot, SDL does listen to Microsoft. If you’ll excuse me, I
need to fix byte order madness. =pOn Tue, Apr 30, 2002 at 05:15:25AM -0700, Joseph Carter wrote:

I decided to keep this as simple as possible so that you can upload the

Joseph Carter glDisable (DX8_CRAP);

This is the solution to Debian’s problem … and since the only real way
to create more relatives of developers is to have children, we need more
sex! It’s a long term investment … it’s the work itself that is
satisfying!
– Craig Brozefsky

-------------- next part --------------
Index: src/video/SDL_video.c

RCS file: /home/slouken/libsdl.org/cvs/SDL12/src/video/SDL_video.c,v
retrieving revision 1.23
diff -u -r1.23 SDL_video.c
— src/video/SDL_video.c 2002/03/20 02:37:44 1.23
+++ src/video/SDL_video.c 2002/04/30 12:24:04
@@ -843,6 +843,25 @@
SDL_SetError(“No video mode has been set”);
return(NULL);
}
+

  • /* If PublicSurface is an OpenGL context, treat it specially */
  • if ((SDL_PublicSurface->flags&SDL_OPENGL) == SDL_OPENGL)
  • {
  •   SDL_PixelFormat *format;
    
  •   SDL_Surface *converted;
    
  •   /* Use a format perfect for GL_RGB texture uploads */
    

+#if SDL_BYTEORDER == SDL_LIL_ENDIAN

  •   format = SDL_AllocFormat(24, 0xFF000000, 0x00FF0000, 0x0000FF00);
    

+#else

  •   format = SDL_AllocFormat(24, 0x000000FF, 0x0000FF00, 0x00FF0000);
    

+#endif

  •   converted = SDL_ConvertSurface(surface, format, SDL_SWSURFACE);
    
  •   SDL_FreeFormat(format);
    
  •   return(converted);
    
  • }
  • /* Set the flags appropriate for copying to display surface */
    if (((SDL_PublicSurface->flags&SDL_HWSURFACE) == SDL_HWSURFACE) && current_video->info.blit_hw)
    flags = SDL_HWSURFACE;
    @@ -877,38 +896,60 @@
    SDL_SetError(“No video mode has been set”);
    return(NULL);
    }
  • vf = SDL_PublicSurface->format;

  • switch(vf->BytesPerPixel) {

  •   case 2:
    
  •   /* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}.
    
  •      For anything else (like ARGB4444) it doesn't matter
    
  •      since we have no special code for it anyway */
    
  •   if ( (vf->Rmask == 0x1f) &&
    
  •        (vf->Bmask == 0xf800 || vf->Bmask == 0x7c00)) {
    
  •   	rmask = 0xff;
    
  •   	bmask = 0xff0000;
    
  •   }
    
  •   break;
    
  • /* OpenGL needs special treatment */
  • if ((SDL_PublicSurface->flags&SDL_OPENGL) != SDL_OPENGL)
  • {
  •   /* Set the format for 32 bit GL_RGBA texture uploads */
    

+#if SDL_BYTEORDER == SDL_LIL_ENDIAN

  •   rmask = 0xff000000;
    
  •   gmask = 0x00ff0000;
    
  •   bmask = 0x0000ff00;
    
  •   amask = 0x000000ff;
    

+#else

  •   rmask = 0x000000ff;
    
  •   rmask = 0x0000ff00;
    
  •   rmask = 0x00ff0000;
    
  •   rmask = 0xff000000;
    

+#endif
+

  •   flags = SDL_SWSURFACE;
    
  • } else {
  •   vf = SDL_PublicSurface->format;
    
  •   case 3:
    
  •   case 4:
    
  •   /* Keep the video format, as long as the high 8 bits are
    
  •      unused or alpha */
    
  •   if ( (vf->Rmask == 0xff) && (vf->Bmask == 0xff0000) ) {
    
  •   	rmask = 0xff;
    
  •   	bmask = 0xff0000;
    
  •   switch(vf->BytesPerPixel) {
    
  •       case 2:
    
  •   	/* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}.
    
  •   	   For anything else (like ARGB4444) it doesn't matter
    
  •   	   since we have no special code for it anyway */
    
  •   	if ( (vf->Rmask == 0x1f) &&
    
  •   	     (vf->Bmask == 0xf800 || vf->Bmask == 0x7c00)) {
    
  •   		rmask = 0xff;
    
  •   		bmask = 0xff0000;
    
  •   	}
    
  •   	break;
    
  •       case 3:
    
  •       case 4:
    
  •   	/* Keep the video format, as long as the high 8 bits are
    
  •   	   unused or alpha */
    
  •   	if ( (vf->Rmask == 0xff) && (vf->Bmask == 0xff0000) ) {
    
  •   		rmask = 0xff;
    
  •   		bmask = 0xff0000;
    
  •   	}
    
  •   	break;
    
  •       default:
    
  •   	/* We have no other optimised formats right now. When/if a new
    
  •   	   optimised alpha format is written, add the converter here */
    
  •   	break;
      }
    
  •   break;
    
  •   default:
    
  •   /* We have no other optimised formats right now. When/if a new
    
  •      optimised alpha format is written, add the converter here */
    
  •   break;
    
  •   flags = SDL_PublicSurface->flags & SDL_HWSURFACE;
    
  •   flags |= surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
    
    }
  • format = SDL_AllocFormat(32, rmask, gmask, bmask, amask);
  • flags = SDL_PublicSurface->flags & SDL_HWSURFACE;
  • flags |= surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
    converted = SDL_ConvertSurface(surface, format, flags);
    SDL_FreeFormat(format);
    return(converted);
    -------------- next part --------------
    A non-text attachment was scrubbed…
    Name: not available
    Type: application/pgp-signature
    Size: 273 bytes
    Desc: not available
    URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020430/d67c1f4d/attachment.pgp