pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] [pingus] push by address@hidden - Added remove blitter for


From: pingus
Subject: [Pingus-CVS] [pingus] push by address@hidden - Added remove blitter for RGBA on 2011-12-29 14:59 GMT
Date: Thu, 29 Dec 2011 15:00:01 +0000

Revision: 96e7deb28088
Author:   Ingo Ruhnke <address@hidden>
Date:     Thu Dec 29 06:59:36 2011
Log:      Added remove blitter for RGBA

http://code.google.com/p/pingus/source/detail?r=96e7deb28088

Modified:
 /src/pingus/ground_map.cpp

=======================================
--- /src/pingus/ground_map.cpp  Fri Dec 23 05:23:51 2011
+++ /src/pingus/ground_map.cpp  Thu Dec 29 06:59:36 2011
@@ -201,7 +201,9 @@
 GroundMap::put_alpha_surface(Surface provider, Surface sprovider,
int x_pos, int y_pos, int real_x_arg, int real_y_arg)
 {
-  if (sprovider.get_surface()->format->BitsPerPixel != 8)
+  if (sprovider.get_surface()->format->BitsPerPixel != 8  &&
+      sprovider.get_surface()->format->BitsPerPixel != 24 &&
+      sprovider.get_surface()->format->BitsPerPixel != 32)
   {
     log_error("Image has wrong color depth: "
<< static_cast<int>(sprovider.get_surface()->format->BitsPerPixel));
@@ -229,7 +231,27 @@
   Uint8* target_buf = static_cast<Uint8*>(provider.get_data());
   Uint8* source_buf = static_cast<Uint8*>(sprovider.get_data());

-  if (sprovider.get_surface()->flags & SDL_SRCCOLORKEY)
+  if (sprovider.get_surface()->format->BitsPerPixel == 32)
+  {
+    for (int y = start_y; y < end_y; ++y)
+    {
+      Uint8* tptr = target_buf + tpitch*(y+y_pos) + 4*(x_pos + start_x);
+      Uint8* sptr = source_buf + spitch*y + 4*start_x;
+
+      for (int x = start_x; x < end_x; ++x)
+      {
+        if (sptr[3] == 255 &&
+ colmap->getpixel(real_x_arg+x, real_y_arg+y) != Groundtype::GP_SOLID)
+        {
+          tptr[3] = 0;
+        }
+
+        tptr += 4;
+        sptr += 4;
+      }
+    }
+  }
+  else if (sprovider.get_surface()->flags & SDL_SRCCOLORKEY)
   {
     Uint32 colorkey = sprovider.get_surface()->format->colorkey;

@@ -251,11 +273,11 @@
     }
   }
   else
-  {
+  {
+ // opaque source surface, so we can use the same code for 24bpp and indexed
     for (int y = start_y; y < end_y; ++y)
     {
       Uint8* tptr = target_buf + tpitch*(y+y_pos) + 4*(x_pos + start_x);
-      Uint8* sptr = source_buf + spitch*y + start_x;

       for (int x = start_x; x < end_x; ++x)
       {
@@ -265,7 +287,6 @@
         }

         tptr += 4;
-        sptr += 1;
       }
     }
   }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]