From 12d623fa250db43dce653e432e49c59f44db664a Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 15 Sep 2014 11:42:21 +0100 Subject: [PATCH] fix hist_find crash with non-u8/u16 input --- libvips/arithmetic/hist_find.c | 8 ++++---- python/try12.py | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100755 python/try12.py diff --git a/libvips/arithmetic/hist_find.c b/libvips/arithmetic/hist_find.c index 8646225a..7e24c08b 100644 --- a/libvips/arithmetic/hist_find.c +++ b/libvips/arithmetic/hist_find.c @@ -349,13 +349,13 @@ vips_hist_find_scan( VipsStatistic *statistic, void *seq, VipsStatisticScanFn scan; if( hist_find->which < 0 ) { - if( statistic->in->BandFmt == VIPS_FORMAT_UCHAR ) + if( statistic->ready->BandFmt == VIPS_FORMAT_UCHAR ) scan = vips_hist_find_uchar_scan; else scan = vips_hist_find_ushort_scan; } else { - if( statistic->in->BandFmt == VIPS_FORMAT_UCHAR ) + if( statistic->ready->BandFmt == VIPS_FORMAT_UCHAR ) scan = vips_hist_find_uchar_extract_scan; else scan = vips_hist_find_ushort_extract_scan; @@ -371,7 +371,7 @@ vips_hist_find_scan( VipsStatistic *statistic, void *seq, /* Type mapping: go to uchar or ushort. */ -static const VipsBandFormat vips_histgr_format_table[10] = { +static const VipsBandFormat vips_hist_find_format_table[10] = { /* UC C US S UI I F X D DX */ UC, UC, US, US, US, US, US, US, US, US }; @@ -393,7 +393,7 @@ vips_hist_find_class_init( VipsHistFindClass *class ) sclass->start = vips_hist_find_start; sclass->scan = vips_hist_find_scan; sclass->stop = vips_hist_find_stop; - sclass->format_table = vips_histgr_format_table; + sclass->format_table = vips_hist_find_format_table; VIPS_ARG_IMAGE( class, "out", 100, _( "Output" ), diff --git a/python/try12.py b/python/try12.py new file mode 100755 index 00000000..978faf38 --- /dev/null +++ b/python/try12.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +import sys + +#import logging +#logging.basicConfig(level = logging.DEBUG) + +from gi.repository import Vips +from vips8 import vips + +im = Vips.Image.new_from_file(sys.argv[1]) + +im = im | im + +black = Vips.Image.black(im.width, 150) +red = black + [255, 0, 0] +left = Vips.Image.text("Left corner").embed(50, 50, im.width, 150) +right_text = Vips.Image.text("Right corner") +right = right_text.embed(im.width - right_text.width - 50, 50, im.width, 150) + +footer = (left | right).blend(black, red) + +im = im.insert(footer, 0, im.height - footer.height) + +im.write_to_file(sys.argv[2])