Logo Search packages:      
Sourcecode: zbar version File versions  Download package

zbar_image_t* zbar_image_convert_resize ( const zbar_image_t image,
unsigned long  format,
unsigned  width,
unsigned  height 
)

image format conversion with crop/pad. if the requested size is larger than the image, the last row/column are duplicated to cover the difference. if the requested size is smaller than the image, the extra rows/columns are dropped from the right/bottom.

Returns:
a new image with the sample data from the original image converted to the requested format and size.
Note:
the image is not scaled
See also:
zbar_image_convert()
Since:
0.4

Definition at line 961 of file convert.c.

References zbar_image_convert_resize(), zbar_image_create(), zbar_image_destroy(), and zbar_image_free_data().

Referenced by zbar::Image::convert(), zbar_image_convert(), zbar_image_convert_resize(), and zbar_window_redraw().

{
    zbar_image_t *dst = zbar_image_create();
    dst->format = fmt;
    dst->width = width;
    dst->height = height;
    if(src->format == fmt &&
       src->width == width &&
       src->height == height) {
        convert_copy(dst, NULL, src, NULL);
        return(dst);
    }

    const zbar_format_def_t *srcfmt = _zbar_format_lookup(src->format);
    const zbar_format_def_t *dstfmt = _zbar_format_lookup(dst->format);
    if(!srcfmt || !dstfmt)
        /* FIXME free dst */
        return(NULL);

    if(srcfmt->group == dstfmt->group &&
       srcfmt->p.cmp == dstfmt->p.cmp &&
       src->width == width &&
       src->height == height) {
        convert_copy(dst, NULL, src, NULL);
        return(dst);
    }

    conversion_handler_t *func =
        conversions[srcfmt->group][dstfmt->group].func;

    dst->cleanup = zbar_image_free_data;
    func(dst, dstfmt, src, srcfmt);
    if(!dst->data) {
        /* conversion failed */
        zbar_image_destroy(dst);
        return(NULL);
    }
    return(dst);
}


Generated by  Doxygen 1.6.0   Back to index