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

zebra_image_t* zebra_image_convert_resize ( const zebra_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:
zebra_image_convert()
Since:
0.4

Definition at line 879 of file convert.c.

References zebra_image_convert_resize(), zebra_image_create(), and zebra_image_free_data().

Referenced by zebra::Image::convert(), zebra_image_convert(), and zebra_image_convert_resize().

{
    zebra_image_t *dst = zebra_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 zebra_format_def_t *srcfmt = _zebra_format_lookup(src->format);
    const zebra_format_def_t *dstfmt = _zebra_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 = zebra_image_free_data;
    func(dst, dstfmt, src, srcfmt);
    return(dst);
}


Generated by  Doxygen 1.6.0   Back to index