Add a --verbose option to output progress
This commit is contained in:
parent
e98116b276
commit
f87ca90fd4
|
@ -61,6 +61,9 @@ def main():
|
|||
'--show_palette', type=str, choices=list(palette_py.PALETTES.keys()),
|
||||
help="RGB colour palette to use when --show_output (default: "
|
||||
"value of --palette)")
|
||||
parser.add_argument(
|
||||
'--verbose', action=argparse.BooleanOptionalAction,
|
||||
default=False, help="Show progress during conversion")
|
||||
args = parser.parse_args()
|
||||
|
||||
palette = palette_py.PALETTES[args.palette]()
|
||||
|
@ -88,7 +91,7 @@ def main():
|
|||
|
||||
dither = dither_pattern.PATTERNS[args.dither]()
|
||||
output_nbit, _ = dither_pyx.dither_image(
|
||||
screen, resized, dither, lookahead)
|
||||
screen, resized, dither, lookahead, args.verbose)
|
||||
bitmap = screen.pack(output_nbit)
|
||||
|
||||
# Show output image by rendering in target palette
|
||||
|
|
|
@ -201,7 +201,7 @@ cdef find_nearest_colour(screen, float[3] pixel_rgb, unsigned char[::1] options_
|
|||
|
||||
@cython.boundscheck(False)
|
||||
@cython.wraparound(False)
|
||||
def dither_image(screen, float[:, :, ::1] image_rgb, dither, int lookahead):
|
||||
def dither_image(screen, float[:, :, ::1] image_rgb, dither, int lookahead, unsigned char verbose):
|
||||
cdef (unsigned char)[:, ::1] image_nbit = np.empty(
|
||||
(image_rgb.shape[0], image_rgb.shape[1]), dtype=np.uint8)
|
||||
|
||||
|
@ -240,6 +240,8 @@ def dither_image(screen, float[:, :, ::1] image_rgb, dither, int lookahead):
|
|||
cdither.pattern[i * cdither.x_shape + j] = dither.PATTERN[i, j, 0]
|
||||
|
||||
for y in range(yres):
|
||||
if verbose:
|
||||
print("%d/%d" % (y, yres))
|
||||
output_pixel_nbit = 0
|
||||
for x in range(xres):
|
||||
for i in range(3):
|
||||
|
|
Loading…
Reference in New Issue