Bläddra i källkod

* pixels.c: store byte length and bits-per-pixel value in the pipi_pixels_t

structure.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2667 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 år sedan
förälder
incheckning
a17c6753e3
5 ändrade filer med 23 tillägg och 2 borttagningar
  1. +4
    -0
      pipi/codec/imlib.c
  2. +4
    -0
      pipi/codec/opencv.c
  3. +4
    -0
      pipi/codec/sdl.c
  4. +4
    -1
      pipi/pipi.h
  5. +7
    -1
      pipi/pixels.c

+ 4
- 0
pipi/codec/imlib.c Visa fil

@@ -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].h = img->h;
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->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].h = imlib_image_get_height();
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_format = PIPI_PIXELS_RGBA32;


+ 4
- 0
pipi/codec/opencv.c Visa fil

@@ -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].h = priv->height;
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->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].h = priv->height;
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_format = PIPI_PIXELS_BGR24;


+ 4
- 0
pipi/codec/sdl.c Visa fil

@@ -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].h = priv->h;
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->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].h = priv->h;
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_format = PIPI_PIXELS_RGBA32;


+ 4
- 1
pipi/pipi.h Visa fil

@@ -19,6 +19,8 @@
#ifndef __PIPI_H__
#define __PIPI_H__

#include <stdio.h>

#ifdef __cplusplus
extern "C"
{
@@ -53,7 +55,8 @@ pipi_format_t;
typedef struct
{
void *pixels;
int w, h, pitch;
int w, h, pitch, bpp;
size_t bytes;
}
pipi_pixels_t;



+ 7
- 1
pipi/pixels.c Visa fil

@@ -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)
{
size_t bytes = 0;
int x, y, i;
int x, y, i, bpp = 0;

if(type < 0 || type >= PIPI_PIXELS_MAX)
return NULL;
@@ -69,21 +69,27 @@ pipi_pixels_t *pipi_getpixels(pipi_image_t *img, pipi_format_t type)
{
case PIPI_PIXELS_RGBA32:
bytes = img->w * img->h * 4 * sizeof(uint8_t);
bpp = 4 * sizeof(uint8_t);
break;
case PIPI_PIXELS_BGR24:
bytes = img->w * img->h * 3 * sizeof(uint8_t);
bpp = 3 * sizeof(uint8_t);
break;
case PIPI_PIXELS_RGBA_F:
bytes = img->w * img->h * 4 * sizeof(float);
bpp = 4 * sizeof(float);
break;
case PIPI_PIXELS_Y_F:
bytes = img->w * img->h * sizeof(float);
bpp = sizeof(float);
break;
default:
return NULL;
}

img->p[type].pixels = malloc(bytes);
img->p[type].bytes = bytes;
img->p[type].bpp = bpp;
}

/* Convert pixels */


Laddar…
Avbryt
Spara