mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-06 19:25:46 -04:00
Fix bugs with true colour PNG support
This commit is contained in:
parent
a32b7917b8
commit
2da59702c2
1 changed files with 9 additions and 13 deletions
|
@ -33,10 +33,7 @@ def parse_args():
|
||||||
"update-palette",
|
"update-palette",
|
||||||
description="This script takes a new palette, compares the new "
|
description="This script takes a new palette, compares the new "
|
||||||
"palette with the old one, and scans and updates images in the repo "
|
"palette with the old one, and scans and updates images in the repo "
|
||||||
"which use the colours that were replaced in the new palette. This "
|
"which use the colours that were replaced in the new palette."
|
||||||
"script only supports indexed-colour PNGs. You may need to run 'make "
|
|
||||||
"fix-deutex-pngs' before running this script in order to palettize "
|
|
||||||
"any true-colour PNGs in the repo."
|
|
||||||
)
|
)
|
||||||
parser.add_argument("palette", help="The new palette to use")
|
parser.add_argument("palette", help="The new palette to use")
|
||||||
# This is a potential vulnerability, and besides, it doesn't make
|
# This is a potential vulnerability, and besides, it doesn't make
|
||||||
|
@ -208,7 +205,7 @@ def process_png(colour_map, png_path, dry, directory):
|
||||||
)
|
)
|
||||||
if co_alpha is not None:
|
if co_alpha is not None:
|
||||||
new_colour = (*new_colour, co_alpha)
|
new_colour = (*new_colour, co_alpha)
|
||||||
modified = new_colour == co
|
modified = modified or new_colour != co
|
||||||
return new_colour
|
return new_colour
|
||||||
pixels = map(maybe_modify_colour,
|
pixels = map(maybe_modify_colour,
|
||||||
grouper(row, channels))
|
grouper(row, channels))
|
||||||
|
@ -233,17 +230,15 @@ def process_png(colour_map, png_path, dry, directory):
|
||||||
bit_depth = info.get("bitdepth")
|
bit_depth = info.get("bitdepth")
|
||||||
transparent_colour = info.get("transparent")
|
transparent_colour = info.get("transparent")
|
||||||
has_alpha = info.get("alpha", False)
|
has_alpha = info.get("alpha", False)
|
||||||
|
channels = info.get("planes")
|
||||||
if is_paletted:
|
if is_paletted:
|
||||||
plte_modified, new_palette = maybe_modify_plte(info["palette"])
|
plte_modified, new_palette = maybe_modify_plte(info["palette"])
|
||||||
if plte_modified:
|
if plte_modified:
|
||||||
idat_modified = any(map(is_paletted_colour_changed, rows))
|
idat_modified = any(map(is_paletted_colour_changed, rows))
|
||||||
# This code doesn't seem to work properly; it modifies plssa0.png, but it
|
elif not grayscale:
|
||||||
# should not modify bpaka0.png
|
new_palette = None
|
||||||
#
|
idat_modified, rows = maybe_modify_truecolour_image(
|
||||||
# elif not grayscale:
|
rows, channels, transparent_colour)
|
||||||
# new_palette = None
|
|
||||||
# idat_modified, rows = maybe_modify_truecolour_image(
|
|
||||||
# rows, info.get("planes"), transparent_colour)
|
|
||||||
|
|
||||||
# Write the modified PNG file
|
# Write the modified PNG file
|
||||||
if idat_modified:
|
if idat_modified:
|
||||||
|
@ -252,7 +247,8 @@ def process_png(colour_map, png_path, dry, directory):
|
||||||
with open(png_path, "wb") as png_file:
|
with open(png_path, "wb") as png_file:
|
||||||
png_writer = png.Writer(
|
png_writer = png.Writer(
|
||||||
width, height, bitdepth=bit_depth, palette=new_palette,
|
width, height, bitdepth=bit_depth, palette=new_palette,
|
||||||
alpha=has_alpha, transparent=transparent_colour)
|
alpha=has_alpha, transparent=transparent_colour,
|
||||||
|
greyscale=grayscale)
|
||||||
png_writer.write(png_file, rows)
|
png_writer.write(png_file, rows)
|
||||||
|
|
||||||
return idat_modified
|
return idat_modified
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue