structure. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2667 92316355-f0b4-4df1-b90c-862c8a59935fremotes/tiles
| @@ -43,6 +43,8 @@ pipi_image_t *pipi_load_imlib2(const char *name) | |||||
| img->p[PIPI_PIXELS_RGBA32].w = img->w; | img->p[PIPI_PIXELS_RGBA32].w = img->w; | ||||
| img->p[PIPI_PIXELS_RGBA32].h = img->h; | img->p[PIPI_PIXELS_RGBA32].h = img->h; | ||||
| img->p[PIPI_PIXELS_RGBA32].pitch = 4 * img->w; | img->p[PIPI_PIXELS_RGBA32].pitch = 4 * img->w; | ||||
| img->p[PIPI_PIXELS_RGBA32].bpp = 32; | |||||
| img->p[PIPI_PIXELS_RGBA32].bytes = 4 * img->w * img->h; | |||||
| img->last_modified = PIPI_PIXELS_RGBA32; | img->last_modified = PIPI_PIXELS_RGBA32; | ||||
| img->codec_priv = (void *)priv; | img->codec_priv = (void *)priv; | ||||
| @@ -79,6 +81,8 @@ void pipi_save_imlib2(pipi_image_t *img, const char *name) | |||||
| img->p[PIPI_PIXELS_RGBA32].w = imlib_image_get_width(); | img->p[PIPI_PIXELS_RGBA32].w = imlib_image_get_width(); | ||||
| img->p[PIPI_PIXELS_RGBA32].h = imlib_image_get_height(); | img->p[PIPI_PIXELS_RGBA32].h = imlib_image_get_height(); | ||||
| img->p[PIPI_PIXELS_RGBA32].pitch = 4 * imlib_image_get_width(); | img->p[PIPI_PIXELS_RGBA32].pitch = 4 * imlib_image_get_width(); | ||||
| img->p[PIPI_PIXELS_RGBA32].bpp = 32; | |||||
| img->p[PIPI_PIXELS_RGBA32].bytes = 4 * img->w * img->h; | |||||
| img->codec_priv = (void *)priv; | img->codec_priv = (void *)priv; | ||||
| img->codec_format = PIPI_PIXELS_RGBA32; | img->codec_format = PIPI_PIXELS_RGBA32; | ||||
| @@ -45,6 +45,8 @@ pipi_image_t *pipi_load_opencv(const char *name) | |||||
| img->p[PIPI_PIXELS_BGR24].w = priv->width; | img->p[PIPI_PIXELS_BGR24].w = priv->width; | ||||
| img->p[PIPI_PIXELS_BGR24].h = priv->height; | img->p[PIPI_PIXELS_BGR24].h = priv->height; | ||||
| img->p[PIPI_PIXELS_BGR24].pitch = priv->widthStep; | img->p[PIPI_PIXELS_BGR24].pitch = priv->widthStep; | ||||
| img->p[PIPI_PIXELS_BGR24].bpp = 24; | |||||
| img->p[PIPI_PIXELS_BGR24].bytes = 3 * img->w * img->h; | |||||
| img->last_modified = PIPI_PIXELS_BGR24; | img->last_modified = PIPI_PIXELS_BGR24; | ||||
| img->codec_priv = (void *)priv; | img->codec_priv = (void *)priv; | ||||
| @@ -79,6 +81,8 @@ void pipi_save_opencv(pipi_image_t *img, const char *name) | |||||
| img->p[PIPI_PIXELS_BGR24].w = priv->width; | img->p[PIPI_PIXELS_BGR24].w = priv->width; | ||||
| img->p[PIPI_PIXELS_BGR24].h = priv->height; | img->p[PIPI_PIXELS_BGR24].h = priv->height; | ||||
| img->p[PIPI_PIXELS_BGR24].pitch = priv->widthStep; | img->p[PIPI_PIXELS_BGR24].pitch = priv->widthStep; | ||||
| img->p[PIPI_PIXELS_BGR24].bpp = 24; | |||||
| img->p[PIPI_PIXELS_BGR24].bytes = 3 * img->w * img->h; | |||||
| img->codec_priv = (void *)priv; | img->codec_priv = (void *)priv; | ||||
| img->codec_format = PIPI_PIXELS_BGR24; | img->codec_format = PIPI_PIXELS_BGR24; | ||||
| @@ -52,6 +52,8 @@ pipi_image_t *pipi_load_sdl(const char *name) | |||||
| img->p[PIPI_PIXELS_RGBA32].w = priv->w; | img->p[PIPI_PIXELS_RGBA32].w = priv->w; | ||||
| img->p[PIPI_PIXELS_RGBA32].h = priv->h; | img->p[PIPI_PIXELS_RGBA32].h = priv->h; | ||||
| img->p[PIPI_PIXELS_RGBA32].pitch = priv->pitch; | img->p[PIPI_PIXELS_RGBA32].pitch = priv->pitch; | ||||
| img->p[PIPI_PIXELS_RGBA32].bpp = 32; | |||||
| img->p[PIPI_PIXELS_RGBA32].bytes = 4 * img->w * img->h; | |||||
| img->last_modified = PIPI_PIXELS_RGBA32; | img->last_modified = PIPI_PIXELS_RGBA32; | ||||
| img->codec_priv = (void *)priv; | img->codec_priv = (void *)priv; | ||||
| @@ -83,6 +85,8 @@ void pipi_save_sdl(pipi_image_t *img, const char *name) | |||||
| img->p[PIPI_PIXELS_RGBA32].w = priv->w; | img->p[PIPI_PIXELS_RGBA32].w = priv->w; | ||||
| img->p[PIPI_PIXELS_RGBA32].h = priv->h; | img->p[PIPI_PIXELS_RGBA32].h = priv->h; | ||||
| img->p[PIPI_PIXELS_RGBA32].pitch = priv->pitch; | img->p[PIPI_PIXELS_RGBA32].pitch = priv->pitch; | ||||
| img->p[PIPI_PIXELS_RGBA32].bpp = 32; | |||||
| img->p[PIPI_PIXELS_RGBA32].bytes = 4 * img->w * img->h; | |||||
| img->codec_priv = (void *)priv; | img->codec_priv = (void *)priv; | ||||
| img->codec_format = PIPI_PIXELS_RGBA32; | img->codec_format = PIPI_PIXELS_RGBA32; | ||||
| @@ -19,6 +19,8 @@ | |||||
| #ifndef __PIPI_H__ | #ifndef __PIPI_H__ | ||||
| #define __PIPI_H__ | #define __PIPI_H__ | ||||
| #include <stdio.h> | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| extern "C" | extern "C" | ||||
| { | { | ||||
| @@ -53,7 +55,8 @@ pipi_format_t; | |||||
| typedef struct | typedef struct | ||||
| { | { | ||||
| void *pixels; | void *pixels; | ||||
| int w, h, pitch; | |||||
| int w, h, pitch, bpp; | |||||
| size_t bytes; | |||||
| } | } | ||||
| pipi_pixels_t; | pipi_pixels_t; | ||||
| @@ -40,7 +40,7 @@ static inline float u8tof32(uint8_t p) { return u8tof32_table[(int)p]; } | |||||
| pipi_pixels_t *pipi_getpixels(pipi_image_t *img, pipi_format_t type) | pipi_pixels_t *pipi_getpixels(pipi_image_t *img, pipi_format_t type) | ||||
| { | { | ||||
| size_t bytes = 0; | size_t bytes = 0; | ||||
| int x, y, i; | |||||
| int x, y, i, bpp = 0; | |||||
| if(type < 0 || type >= PIPI_PIXELS_MAX) | if(type < 0 || type >= PIPI_PIXELS_MAX) | ||||
| return NULL; | return NULL; | ||||
| @@ -69,21 +69,27 @@ pipi_pixels_t *pipi_getpixels(pipi_image_t *img, pipi_format_t type) | |||||
| { | { | ||||
| case PIPI_PIXELS_RGBA32: | case PIPI_PIXELS_RGBA32: | ||||
| bytes = img->w * img->h * 4 * sizeof(uint8_t); | bytes = img->w * img->h * 4 * sizeof(uint8_t); | ||||
| bpp = 4 * sizeof(uint8_t); | |||||
| break; | break; | ||||
| case PIPI_PIXELS_BGR24: | case PIPI_PIXELS_BGR24: | ||||
| bytes = img->w * img->h * 3 * sizeof(uint8_t); | bytes = img->w * img->h * 3 * sizeof(uint8_t); | ||||
| bpp = 3 * sizeof(uint8_t); | |||||
| break; | break; | ||||
| case PIPI_PIXELS_RGBA_F: | case PIPI_PIXELS_RGBA_F: | ||||
| bytes = img->w * img->h * 4 * sizeof(float); | bytes = img->w * img->h * 4 * sizeof(float); | ||||
| bpp = 4 * sizeof(float); | |||||
| break; | break; | ||||
| case PIPI_PIXELS_Y_F: | case PIPI_PIXELS_Y_F: | ||||
| bytes = img->w * img->h * sizeof(float); | bytes = img->w * img->h * sizeof(float); | ||||
| bpp = sizeof(float); | |||||
| break; | break; | ||||
| default: | default: | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| img->p[type].pixels = malloc(bytes); | img->p[type].pixels = malloc(bytes); | ||||
| img->p[type].bytes = bytes; | |||||
| img->p[type].bpp = bpp; | |||||
| } | } | ||||
| /* Convert pixels */ | /* Convert pixels */ | ||||