mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 21:30:53 +00:00
Add a parameter to allow saving RGB PNGs
This commit is contained in:
@@ -105,13 +105,13 @@ def sanitise_filename(name: str):
|
||||
return re.sub('^/', '', name)
|
||||
|
||||
|
||||
def png_save(out_path: str, rows: List[bytes], dimensions: Tuple[int, int]):
|
||||
def png_save(out_path: str, rows: List[bytes], dimensions: Tuple[int, int], has_alpha: bool):
|
||||
try:
|
||||
f = open(out_path, 'wb')
|
||||
except Exception as ex:
|
||||
raise FileNotFoundError("Can't open {} for write".format(sanitise_filename(out_path)))
|
||||
|
||||
writer = png.Writer(dimensions[0], dimensions[1], alpha=True, greyscale=False, compression=7)
|
||||
writer = png.Writer(dimensions[0], dimensions[1], alpha=has_alpha, greyscale=False, compression=7)
|
||||
writer.write(f, rows)
|
||||
f.close()
|
||||
|
||||
@@ -165,7 +165,7 @@ def png_compare(test_img: str, ref_img: str, tolerance: int = 2):
|
||||
if os.path.exists(diff_file):
|
||||
os.remove(diff_file)
|
||||
|
||||
png_save(diff_file, diff_data, (test_w, test_h))
|
||||
png_save(diff_file, diff_data, (test_w, test_h), True)
|
||||
|
||||
return False
|
||||
|
||||
|
||||
@@ -126,8 +126,8 @@ class VK_Sample_Locations(rdtest.TestCase):
|
||||
degenerate.append(combined_data[row][0:len])
|
||||
rotated.append(combined_data[row][len:])
|
||||
|
||||
rdtest.png_save(degenerate_path, degenerate, halfdim)
|
||||
rdtest.png_save(rotated_path, rotated, halfdim)
|
||||
rdtest.png_save(degenerate_path, degenerate, halfdim, True)
|
||||
rdtest.png_save(rotated_path, rotated, halfdim, True)
|
||||
|
||||
# first two degenerate images should be identical, as should the last two, and they should be different.
|
||||
if not rdtest.png_compare(degenerate_paths[0], degenerate_paths[1], 0):
|
||||
|
||||
Reference in New Issue
Block a user