Browse Source

* pixels.c: support more conversion combinations.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2655 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 years ago
parent
commit
99d8af784e
3 changed files with 14 additions and 3 deletions
  1. +0
    -2
      examples/dither.c
  2. +0
    -1
      examples/edd.c
  3. +14
    -0
      pipi/pixels.c

+ 0
- 2
examples/dither.c View File

@@ -27,7 +27,6 @@ int main(int argc, char *argv[])
dstname = argv[3];

img = pipi_load(srcname);
pipi_getpixels(img, PIPI_PIXELS_RGBA_F);

switch(atoi(argv[2]))
{
@@ -42,7 +41,6 @@ int main(int argc, char *argv[])

pipi_free(img);

pipi_getpixels(newimg, PIPI_PIXELS_RGBA_F);
pipi_save(newimg, dstname);
pipi_free(newimg);



+ 0
- 1
examples/edd.c View File

@@ -50,7 +50,6 @@ int main(int argc, char *argv[])

/* Load image, convert it to grayscale, dither it with Floyd-Steinberg */
img = pipi_load(argv[1]);
pipi_getpixels(img, PIPI_PIXELS_RGBA_F);
pipi_getpixels(img, PIPI_PIXELS_Y_F);
gauss = pipi_gaussian_blur(img, sigma);
dither = pipi_floydsteinberg(img);


+ 14
- 0
pipi/pixels.c View File

@@ -48,6 +48,20 @@ pipi_pixels_t *pipi_getpixels(pipi_image_t *img, pipi_format_t type)
if(img->last_modified == type)
return &img->p[type];

/* Preliminary conversions */
if(img->last_modified == PIPI_PIXELS_RGBA32
&& type == PIPI_PIXELS_Y_F)
pipi_getpixels(img, PIPI_PIXELS_RGBA_F);
else if(img->last_modified == PIPI_PIXELS_BGR24
&& type == PIPI_PIXELS_Y_F)
pipi_getpixels(img, PIPI_PIXELS_RGBA_F);
else if(img->last_modified == PIPI_PIXELS_Y_F
&& type == PIPI_PIXELS_RGBA32)
pipi_getpixels(img, PIPI_PIXELS_RGBA_F);
else if(img->last_modified == PIPI_PIXELS_Y_F
&& type == PIPI_PIXELS_BGR24)
pipi_getpixels(img, PIPI_PIXELS_RGBA_F);

/* Allocate pixels if necessary */
if(!img->p[type].pixels)
{


Loading…
Cancel
Save