1. pygame
  2. Untitled project
  3. pygame

Commits

pygame  committed 6d91c54

fix save opengl green

  • Participants
  • Parent commits 34902e8
  • Branches default

Comments (0)

Files changed (3)

File WHATSNEW

View file
 # BREAK = change breaks existing code
 # BUG	= fixed a bug that was (or could have been) crashing
 
+September 18, 2003
+	Fix color problem when saving opengl screenshot
+
 September 10, 2003
 	SysFont now accepts None like regular Font
 

File lib/sysfont.py

View file
         initsysfonts()
 
     fontname = None
-    origbold = origitalic = 0
     if name:
         allnames = name
         for name in allnames.split(','):
             if fontname: break
 
     font = pygame.font.Font(fontname, size)
-    if origbold and not bold:
-        font.set_bold(1)
-    if origitalic and not italic:
-        font.set_italic(1)
+    if name:
+        if origbold and not bold:
+            font.set_bold(1)
+        if origitalic and not italic:
+            font.set_italic(1)
+    else:
+        if bold:
+            font.set_bold(1)
+        elif italic:
+            font.set_italic(1)
+
     return font
 
 

File src/image.c

View file
 static int is_extended = 0;
 static int SaveTGA(SDL_Surface *surface, char *file, int rle);
 static int SaveTGA_RW(SDL_Surface *surface, SDL_RWops *out, int rle);
+static SDL_Surface* opengltosdl();
 
 
 #define DATAROW(data, row, width, height, flipped) \
         PyObject *pyopengl, *readpixels = NULL;
         int typeflag=0, formatflag=0;
         SDL_Surface *surf;
-        Uint32 rmask, gmask, bmask, amask;
-        int i, depth, doalpha=0;
+        Uint32 rmask, gmask, bmask;
+        int i;
         unsigned char *pixels;
         PyObject *data;
 
         surf = SDL_GetVideoSurface();
-    
+
         pyopengl = PyImport_ImportModule("OpenGL.GL");
         if(pyopengl)
         {
             return NULL;
         }
 
-        data = PyObject_CallFunction(readpixels, "iiiiii", 
+        data = PyObject_CallFunction(readpixels, "iiiiii",
                                 0, 0, surf->w, surf->h, formatflag, typeflag);
         if(!data)
         {
                 return NULL;
         }
         pixels = (unsigned char*)PyString_AsString(data);
-        
+
         if(SDL_BYTEORDER == SDL_LIL_ENDIAN)
         {
-            if(doalpha)
-            {
-                rmask=0x000000FF; gmask=0x0000FF00; bmask=0x00FF00; amask=0xFF000000; depth=32;
-            }
-            else
-            {
-                rmask=0x000000FF; gmask=0x0000FF00; bmask=0x00FF00; amask=0x00000000; depth=24;
-            }
+            rmask=0x000000FF; gmask=0x0000FF00; bmask=0x00FF0000;
         }
         else
         {
-            if(doalpha)
-            {
-                rmask=0xFF000000; gmask=0x00FF0000; bmask=0x00FF00; amask=0x00000000; depth=32;
-            }
-            else
-            {
-                rmask=0x00FF0000; gmask=0x0000FF00; bmask=0x000000FF; amask=0x00000000; depth=24;
-            }
+            rmask=0x00FF0000; gmask=0x0000FF00; bmask=0x000000FF;
         }
-        surf = SDL_CreateRGBSurface(SDL_SWSURFACE, surf->w, surf->h, depth,
-                    rmask, gmask, bmask, amask);
+        surf = SDL_CreateRGBSurface(SDL_SWSURFACE, surf->w, surf->h, 24,
+                    rmask, gmask, bmask, 0);
         if(!surf)
         {
                 Py_DECREF(data);
 
         for(i=0; i<surf->h; ++i)
                 memcpy(((char *) surf->pixels) + surf->pitch * i, pixels + 3*surf->w * (surf->h-i-1), surf->w*3);
-        
+
         Py_DECREF(data);
         return surf;
 }
 	SDL_Surface *surf;
 	SDL_Surface *temp = NULL;
 	int result;
-	
+
 	if(!PyArg_ParseTuple(arg, "O!O", &PySurface_Type, &surfobj, &file))
 		return NULL;
 	surf = PySurface_AsSurface(surfobj);
                 if(!surf)
                     return NULL;
 	}
-        
+
 	Rmask = surf->format->Rmask; Gmask = surf->format->Gmask;
 	Bmask = surf->format->Bmask; Amask = surf->format->Amask;
 	Rshift = surf->format->Rshift; Gshift = surf->format->Gshift;
 					data[0] = (char)(((color & Rmask) >> Rshift) << Rloss);
 					data[1] = (char)(((color & Gmask) >> Gshift) << Gloss);
 					data[2] = (char)(((color & Bmask) >> Bshift) << Bloss);
-					data[3] = hascolorkey ? (char)(color!=colorkey)*255 : 
+					data[3] = hascolorkey ? (char)(color!=colorkey)*255 :
 								(char)(Amask ? (((color & Amask) >> Ashift) << Aloss) : 255);
 					data += 4;
 				}