fix hist_find crash with non-u8/u16 input

This commit is contained in:
John Cupitt 2014-09-15 11:42:21 +01:00
parent e09aa1d4be
commit 12d623fa25
2 changed files with 29 additions and 4 deletions

View File

@ -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" ),

25
python/try12.py Executable file
View File

@ -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])