windstille-devel
[Top][All Lists]
Advanced

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

[Windstille-devel] rev 330 - trunk/src


From: Ingo Ruhnke
Subject: [Windstille-devel] rev 330 - trunk/src
Date: Sat, 15 May 2004 20:58:29 +0200

Author: grumbel
Date: 2004-05-15 20:58:29 +0200 (Sat, 15 May 2004)
New Revision: 330

Modified:
   trunk/src/tilemap.cxx
   trunk/src/tilemap.hxx
Log:


Modified: trunk/src/tilemap.cxx
===================================================================
--- trunk/src/tilemap.cxx       2004-05-15 12:53:49 UTC (rev 329)
+++ trunk/src/tilemap.cxx       2004-05-15 18:58:29 UTC (rev 330)
@@ -31,7 +31,8 @@
 #include "tile_brush.hxx"
 #include "editor_map_component.hxx"
 #include "editor_map_component.hxx"
-#include "tilemap.hxx"
+#include "tilemap_layer.hxx"
+#include "blitter.hxx"
 #include "editor_map_component.hxx"
 
 TileMap* TileMap::current_ = 0;
@@ -205,97 +206,6 @@
   return draw_grid;
 }
 
-void 
-blit(CL_PixelBuffer& target, CL_PixelBuffer& brush, int x_pos, int y_pos)
-{
-  target.lock();
-  brush.lock();
-
-  int start_x = std::max(0, -x_pos);
-  int start_y = std::max(0, -y_pos);
-  
-  int end_x = std::min(brush.get_width(),  target.get_width()  - x_pos);
-  int end_y = std::min(brush.get_height(), target.get_height() - y_pos);
-
-  unsigned char* target_buf = static_cast<unsigned char*>(target.get_data());
-  unsigned char* brush_buf  = static_cast<unsigned char*>(brush.get_data());
-
-  int target_width = target.get_width();
-  int brush_width  = brush.get_width();
-
-  if (brush.get_format().get_type() == pixelformat_rgba)
-    {
-      if (brush.get_format().get_depth() == 32)
-        {
-          for (int y = start_y; y < end_y; ++y)
-            for (int x = start_x; x < end_x; ++x)
-              {
-                int target_pos = (y + y_pos) * target_width + x + x_pos;
-                int brush_pos  = y * brush_width + x;
-
-                unsigned char a  = brush_buf[4*brush_pos + 0];
-                unsigned char r  = brush_buf[4*brush_pos + 1];
-                unsigned char g  = brush_buf[4*brush_pos + 2];
-                unsigned char b  = brush_buf[4*brush_pos + 3];
-
-                unsigned char ta = target_buf[4*target_pos + 0];
-                unsigned char tr = target_buf[4*target_pos + 1];
-                unsigned char tg = target_buf[4*target_pos + 2];
-                unsigned char tb = target_buf[4*target_pos + 3];
-
-                float alpha  = a/255.0f;
-        
-                target_buf[4*target_pos + 0] = std::min(255, ta + a);
-                target_buf[4*target_pos + 1] = std::min(255, int((1-alpha)*tr 
+ alpha*r));
-                target_buf[4*target_pos + 2] = std::min(255, int((1-alpha)*tg 
+ alpha*g));
-                target_buf[4*target_pos + 3] = std::min(255, int((1-alpha)*tb 
+ alpha*b));
-              }
-        }
-      else if (brush.get_format().get_depth() == 24)
-        {
-          for (int y = start_y; y < end_y; ++y)
-            for (int x = start_x; x < end_x; ++x)
-              {
-                int target_pos = (y + y_pos) * target_width + x + x_pos;
-                int brush_pos  = y * brush_width + x;
-
-                target_buf[4*target_pos + 0] = 255;
-                target_buf[4*target_pos + 1] = brush_buf[3*brush_pos + 0];
-                target_buf[4*target_pos + 2] = brush_buf[3*brush_pos + 1];
-                target_buf[4*target_pos + 3] = brush_buf[3*brush_pos + 2];
-              }
-        }
-      else
-        {
-          std::cout << "Unsupported bpp: " << brush.get_format().get_depth() 
<< std::endl;
-        }
-    }
-  else if (brush.get_format().get_type() == pixelformat_index)
-    {
-      CL_Palette palette = brush.get_palette();
-      for (int y = start_y; y < end_y; ++y)
-        for (int x = start_x; x < end_x; ++x)
-          {
-            int target_pos = (y + y_pos) * target_width + x + x_pos;
-            int brush_pos  = y * brush_width + x;
-            
-            target_buf[4*target_pos + 0] = 255;
-            target_buf[4*target_pos + 1] = 
palette.colors[brush_buf[brush_pos]].get_blue();
-            target_buf[4*target_pos + 2] = 
palette.colors[brush_buf[brush_pos]].get_green();
-            target_buf[4*target_pos + 3] = 
palette.colors[brush_buf[brush_pos]].get_red();
-          }
-    }
-  else
-    {
-      assert(!"Unknown pixelformat type");
-    }
-    
-
-
-  brush.unlock();
-  target.unlock();
-}
-
 CL_PixelBuffer
 TileMap::create_pixelbuffer()
 {

Modified: trunk/src/tilemap.hxx
===================================================================
--- trunk/src/tilemap.hxx       2004-05-15 12:53:49 UTC (rev 329)
+++ trunk/src/tilemap.hxx       2004-05-15 18:58:29 UTC (rev 330)
@@ -48,6 +48,7 @@
   bool draw_attribute;
 
   static TileMap* current_;
+
 public:
   static TileMap* current() { return current_; }
   static void set_current(TileMap* c) { current_ = c; }





reply via email to

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