]> marstr Code Repo - marstr/orthographic.git/commitdiff
Implemented fix to correct alpha on final image so that DDSTool for X-Plane works...
authorMarcus Str. <marcus@marstr.online>
Wed, 25 Sep 2024 19:24:06 +0000 (21:24 +0200)
committerMarcus Str. <marcus@marstr.online>
Wed, 25 Sep 2024 19:24:06 +0000 (21:24 +0200)
photogen.py

index 6ce11fabb2f28b84a8ce27276b4dc93a0f755d96..c1ffeb056b5c21d75446cce201c912407e03e27f 100644 (file)
@@ -129,6 +129,17 @@ class mstr_photogen:
                         wp = wtr_pix[x,y]\r
                         if wp[0] == 255 and wp[1] == 0 and wp[2] == 255 and wp[3] == 255:\r
                             tilepix[x,y] = (0,0,0,0)\r
+\r
+        # Alpha correction on final image\r
+        corrpix = self._tile.load()\r
+        for y in range(0, self._tile.height):\r
+            for x in range(0, self._tile.width):\r
+                c = corrpix[x,y]\r
+                if c[3] > 0:\r
+                    nc = (c[0], c[1], c[2], 255)\r
+                    corrpix[x,y] = nc\r
+                if c[3] == 0:\r
+                    corrpix[x,y] = (0,0,0,0)\r
         \r
         # We are now in posession of the final image.\r
 \r
@@ -172,18 +183,18 @@ class mstr_photogen:
 \r
     # This returns a mask of the empty space to cover, should there be any\r
     def buildCompletionMask(self):\r
-        mask = Image.new("RGBA", (self._imgsize, self._imgsize), (0,0,0,255))\r
-        #mask_pix = mask.load()\r
+        mask = Image.new("RGBA", (self._imgsize, self._imgsize), (0,0,0,0))\r
+        mask_pix = mask.load()\r
 \r
         # Load photo\r
-        #layer_pix = self._tile.load() \r
+        layer_pix = self._tile.load() \r
         \r
         # Scan!\r
-        #for y in range(self._tile.width-1):\r
-        #    for x in range(self._tile.height-1):\r
-        #        p = layer_pix[x,y]\r
-        #        if p[3] < 255: # <- Check for empty or non-complete alpha\r
-        #            mask_pix[x,y] = (0,0,0,255)\r
+        for y in range(self._tile.width-1):\r
+            for x in range(self._tile.height-1):\r
+                p = layer_pix[x,y]\r
+                if p[3] < 255: # <- Check for empty or non-complete alpha\r
+                    mask_pix[x,y] = (0,0,0,255)\r
         # We do not apply any blur or other effects here - we only want the\r
         # exact pixel positions.\r
 \r