Revision: 6714
          http://playerstage.svn.sourceforge.net/playerstage/?rev=6714&view=rev
Author:   rtv
Date:     2008-06-30 01:22:54 -0700 (Mon, 30 Jun 2008)

Log Message:
-----------
fixed byte-alignment bug in screenshot code. I want 3 hours of my life back

Modified Paths:
--------------
    code/stage/trunk/libstage/canvas.cc
    code/stage/trunk/worlds/fasr.world

Modified: code/stage/trunk/libstage/canvas.cc
===================================================================
--- code/stage/trunk/libstage/canvas.cc 2008-06-30 07:59:07 UTC (rev 6713)
+++ code/stage/trunk/libstage/canvas.cc 2008-06-30 08:22:54 UTC (rev 6714)
@@ -624,7 +624,7 @@
 
   int width = viewport[2];//w();
   int height = viewport[3];//;;h();
-  int depth = 3; // RGB
+  int depth = 4; // RGBA
 
  //  printf( "VP: %d %d %d %d  WIN %d %d\n",
 //       viewport[0],
@@ -639,8 +639,13 @@
   glFlush(); // make sure the drawing is done
   // read the pixels from the screen
   //glReadPixels( viewport[0], viewport[1], width, height, GL_RGB, 
GL_UNSIGNED_BYTE, pixels );                  
-  glReadPixels( 0,0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels );        
                 
+  glReadPixels( 0,0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels );       
                 
   
+  // force the alpha channel to be maximum
+  for( int i=0; i<height; i++ )
+    for( int j=0; j<width; j++ )
+      pixels[ ((i * width + j) * depth)+3] = 0xFF; 
+
   static uint32_t count = 0;            
   char filename[64];
   snprintf( filename, 63, "stage-%d.png", count++ );
@@ -668,11 +673,13 @@
   //png_set_compression_level(pp, Z_DEFAULT_COMPRESSION);
   png_set_IHDR( pp, info, 
                width, height, 8, 
-               PNG_COLOR_TYPE_RGB, 
+               PNG_COLOR_TYPE_RGBA, 
                PNG_INTERLACE_NONE, 
                PNG_COMPRESSION_TYPE_DEFAULT, 
                PNG_FILTER_TYPE_DEFAULT);
 
+  png_set_strip_alpha(pp);
+
   png_write_png( pp, info, PNG_TRANSFORM_IDENTITY, NULL );
   png_destroy_write_struct(&pp, &info);
   

Modified: code/stage/trunk/worlds/fasr.world
===================================================================
--- code/stage/trunk/worlds/fasr.world  2008-06-30 07:59:07 UTC (rev 6713)
+++ code/stage/trunk/worlds/fasr.world  2008-06-30 08:22:54 UTC (rev 6714)
@@ -21,7 +21,7 @@
 # configure the GUI window
 window
 ( 
-  size [ 280.000 480.000 ] 
+  size [ 641.000 480.000 ] 
   center [-0.294 0.114] 
   rotate [ -52.500 -18.500 ]
   scale 27.525 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to