瀏覽代碼

Merge remote-tracking branch 'damu/master'

Lasse Öörni 9 年之前
父節點
當前提交
2551e5698c
共有 1 個文件被更改,包括 14 次插入3 次删除
  1. 14 3
      Source/Urho3D/Resource/Image.cpp

+ 14 - 3
Source/Urho3D/Resource/Image.cpp

@@ -1114,9 +1114,20 @@ void Image::ClearInt(unsigned uintColor)
         return;
     }
 
-    unsigned char* src = (unsigned char*)&uintColor;
-    for (unsigned i = 0; i < width_ * height_ * depth_ * components_; ++i)
-        data_[i] = src[i % components_];
+    if (components_ == 4)
+    {
+        uint32_t color = uintColor;
+        uint32_t* data = (uint32_t*)GetData();
+        uint32_t* data_end = (uint32_t*)(GetData() + width_ * height_ * depth_ * components_);
+        for (; data < data_end; ++data)
+            *data = color;
+    }
+    else
+    {
+        unsigned char* src = (unsigned char*)&uintColor;
+        for (unsigned i = 0; i < width_ * height_ * depth_ * components_; ++i)
+            data_[i] = src[i % components_];
+    }
 }
 
 bool Image::SaveBMP(const String& fileName) const