diff options
Diffstat (limited to 'lib/picture/size.c')
-rw-r--r-- | lib/picture/size.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/lib/picture/size.c b/lib/picture/size.c index 8304995..2f4b771 100644 --- a/lib/picture/size.c +++ b/lib/picture/size.c @@ -18,49 +18,42 @@ * ************************************************************************* */ #include "picture.h" -/** - * casio_get_picture_size: - * Get a 'raw' picture size. - * - * @arg pixels the picture. - * @arg fmt the picture format. - * @arg width the picture width. - * @arg height the picture height. - * @return the raw size. - */ +/* `casio_get_picture_estimated_size()`: get the estimated size of a picture + * in bytes out of its format and dimensions. */ -size_t CASIO_EXPORT casio_get_picture_size(casio_pixel_t **pixels, - casio_pictureformat_t fmt, unsigned int width, unsigned int height) +CASIO_EXTERN(int) casio_get_picture_estimated_size(casio_pictureformat_t fmt, + unsigned int width, unsigned int height, size_t *sizep) { - (void)pixels; - switch (fmt) { case casio_pictureformat_1bit: /* FALLTHRU */ case casio_pictureformat_1bit_r: /* FALLTHRU */ case casio_pictureformat_1bit_old: - return (((width / 8) + !!(width % 8)) * height); + *sizep = ((width / 8) + !!(width % 8)) * height; case casio_pictureformat_1bit_packed: /* FALLTHRU */ case casio_pictureformat_1bit_packed_r: - return ((width * height / 8) + !!(width * height % 8)); + *sizep = (width * height / 8) + !!(width * height % 8); case casio_pictureformat_2bit_dual: - return (((width / 8) + !!(width % 8)) * height * 2); + *sizep = ((width / 8) + !!(width % 8)) * height * 2; case casio_pictureformat_4bit: /* FALLTHRU */ case casio_pictureformat_4bit_code: - return (width * height / 2); + *sizep = width * height / 2; case casio_pictureformat_4bit_color: /* FALLTHRU */ case casio_pictureformat_4bit_mono: - return (((width / 8) + !!(width % 8)) * height * 4); + *sizep = ((width / 8) + !!(width % 8)) * height * 4; case casio_pictureformat_casemul: - return (width * height); + *sizep = width * height; case casio_pictureformat_16bit: - return (width * height * 2); + *sizep = width * height * 2; + + default: + return (casio_error_op); } - return (0); + return (casio_ok); } |