Просмотр исходного кода

PNG can have transparent colored pixels. An Alpha-0 pixel doesn't mean it's the same color than the others. This fix intends to put all A0 pixels to the same colorkey.

Eiyeron Fulmincendii лет назад: 10
Родитель
Сommit
9ca00ebf92
1 измененных файлов с 9 добавлено и 1 удалено
  1. 9 1
      platform/nspire/Texure.cpp

+ 9 - 1
platform/nspire/Texure.cpp

@@ -35,15 +35,23 @@ Texture::Texture(File entry)
     data = new uint16_t[width * height + 3];
     data[0] = width;
     data[1] = height;
+    bool transparency_set(false);
     for(unsigned y = 0; y < height; y++)
     {
         for (unsigned x = 0; x < width; x++) {
+            bool is_transparent = (pic[(y*width + x)*4+3] == 0);
+            if(is_transparent && transparency_set)
+            {
+                data[y*width + x+3] = data[2];
+                continue;
+            }
             uint16_t color = (pic[(y*width + x)*4]>>3)<<11;
             color |= (pic[(y*width + x)*4 + 1]>>2)<<5;
             color |= (pic[(y*width + x)*4 + 2]>>3);
-            if(pic[(y*width + x)*4+3] == 0)
+            if(is_transparent && !transparency_set)
             {
                 data[2] = color;
+                transparency_set = true;
             }
             data[y*width + x+3] = color;
         }