Implemented fix to correct alpha on final image so that DDSTool for X-Plane works correctly

This commit is contained in:
Marcus Str. 2024-09-25 21:24:06 +02:00
parent 728b4aa9c6
commit 1df4cd2ffc

View File

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