Explorar el Código

Add pipi_release_pixels and pipi_set_colorspace in prevision of

pipi_get_pixels using the tiles system. These functions should
disappear one day, because they're going to leak like crazy.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3341 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam hace 16 años
padre
commit
0494eff2ef
Se han modificado 14 ficheros con 41 adiciones y 11 borrados
  1. +1
    -1
      examples/edd.c
  2. +1
    -0
      examples/img2rubik.c
  3. +5
    -0
      pipi-sharp/Picture.cs
  4. +5
    -1
      pipi/analysis/histogram.c
  5. +1
    -0
      pipi/analysis/measure.c
  6. +4
    -0
      pipi/codec/gdi.c
  7. +1
    -1
      pipi/codec/imlib.c
  8. +2
    -0
      pipi/codec/modular/jpeg.c
  9. +1
    -1
      pipi/codec/opencv.c
  10. +6
    -5
      pipi/codec/oric.c
  11. +1
    -1
      pipi/codec/sdl.c
  12. +2
    -0
      pipi/pipi.h
  13. +11
    -0
      pipi/pixels.c
  14. +0
    -1
      pipi/tiles.c

+ 1
- 1
examples/edd.c Ver fichero

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

/* Load image, convert it to grayscale, dither it with Floyd-Steinberg */
img = pipi_load(argv[1]);
pipi_get_pixels(img, PIPI_PIXELS_Y_F);
pipi_set_colorspace(img, PIPI_PIXELS_Y_F);
gauss = pipi_gaussian_blur(img, sigma);
kernel = pipi_load("ediff:fs");
dither = pipi_dither_ediff(img, kernel, PIPI_SCAN_RASTER);


+ 1
- 0
examples/img2rubik.c Ver fichero

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

pipi_save(dst, argv[2]);
pipi_release_pixels(dst, p);

return 0;
}


+ 5
- 0
pipi-sharp/Picture.cs Ver fichero

@@ -90,6 +90,9 @@ namespace Pipi
[DllImport("libpipi-0.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern IntPtr pipi_get_pixels(IntPtr img, int type);
[DllImport("libpipi-0.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern void pipi_release_pixels(IntPtr img, IntPtr p);
public byte[] GetPixels(int w, int h, int x, int y)
{
byte[] array = new byte[w * h * 4];
@@ -116,6 +119,8 @@ namespace Pipi
}
}

pipi_release_pixels(_picture, pixels);

return array;
}
}


+ 5
- 1
pipi/analysis/histogram.c Ver fichero

@@ -35,6 +35,7 @@ pipi_histogram_t* pipi_new_histogram(void)

int pipi_get_image_histogram(pipi_image_t *img, pipi_histogram_t*h, int flags)
{
pipi_pixels_t *p;
uint8_t *data;
float n;
unsigned int max;
@@ -42,7 +43,8 @@ int pipi_get_image_histogram(pipi_image_t *img, pipi_histogram_t*h, int flags)

if(!h) return -1;

data = (uint8_t *)pipi_get_pixels(img, PIPI_PIXELS_RGBA_C)->pixels;
p = pipi_get_pixels(img, PIPI_PIXELS_RGBA_C);
data = (uint8_t *)p->pixels;
memset(h->a, 0, 256*(sizeof(unsigned int)));
memset(h->r, 0, 256*(sizeof(unsigned int)));
memset(h->g, 0, 256*(sizeof(unsigned int)));
@@ -118,6 +120,8 @@ int pipi_get_image_histogram(pipi_image_t *img, pipi_histogram_t*h, int flags)
h->y[i]*=n;
}

pipi_release_pixels(img, p);

return 0;
}



+ 1
- 0
pipi/analysis/measure.c Ver fichero

@@ -41,6 +41,7 @@ double pipi_measure_msd(pipi_image_t *i1, pipi_image_t *i2)
f1 = i1->last_modified;
f2 = i2->last_modified;

/* FIXME: this is not right */
pipi_get_pixels(i1, PIPI_PIXELS_Y_F);
pipi_get_pixels(i2, PIPI_PIXELS_Y_F);



+ 4
- 0
pipi/codec/gdi.c Ver fichero

@@ -70,6 +70,8 @@ pipi_image_t *pipi_load_gdi(const char *name)
/* FIXME: do we need to swap bytes? Apparently Vista doesn't need it,
* but we'd need a more thorough test. */

pipi_release_pixels(img, p);

img->codec_priv = NULL;

img->wrap = 0;
@@ -135,6 +137,8 @@ int pipi_save_gdi(pipi_image_t *img, const char *name)
}
CloseHandle(hfile);

pipi_release_pixels(img, p);

return 0;
}



+ 1
- 1
pipi/codec/imlib.c Ver fichero

@@ -98,7 +98,7 @@ int pipi_save_imlib2(pipi_image_t *img, const char *name)
img->u8 = 1;
}

pipi_get_pixels(img, img->codec_format);
pipi_set_colorspace(img, img->codec_format);
imlib_context_set_image(img->codec_priv);
imlib_save_image(name);



+ 2
- 0
pipi/codec/modular/jpeg.c Ver fichero

@@ -205,6 +205,8 @@ end:
free(line);
fclose(fp);

pipi_release_pixels(img, pixels);

return 1;
}



+ 1
- 1
pipi/codec/opencv.c Ver fichero

@@ -91,7 +91,7 @@ int pipi_save_opencv(pipi_image_t *img, const char *name)
img->u8 = 1;
}

pipi_get_pixels(img, img->codec_format);
pipi_set_colorspace(img, img->codec_format);
cvSaveImage(name, img->codec_priv);

return 0;


+ 6
- 5
pipi/codec/oric.c Ver fichero

@@ -110,6 +110,8 @@ pipi_image_t *pipi_load_oric(char const *name)
img->wrap = 0;
img->u8 = 1;

pipi_release_pixels(img, p);

return img;
}

@@ -139,16 +141,15 @@ int pipi_save_oric(pipi_image_t *img, char const *name)
fwrite("\x00", 1, 1, fp);

if(img->w != WIDTH || img->h != HEIGHT)
{
tmp = pipi_resize(img, WIDTH, HEIGHT);
p = pipi_get_pixels(tmp, PIPI_PIXELS_RGBA_F);
}
else
p = pipi_get_pixels(img, PIPI_PIXELS_RGBA_F);
tmp = img;
p = pipi_get_pixels(tmp, PIPI_PIXELS_RGBA_F);
data = p->pixels;
screen = malloc(WIDTH * HEIGHT / 6);
write_screen(data, screen);
if(tmp)
pipi_release_pixels(tmp, p);
if(tmp != img)
pipi_free(tmp);

fwrite(screen, 1, WIDTH * HEIGHT / 6, fp);


+ 1
- 1
pipi/codec/sdl.c Ver fichero

@@ -95,7 +95,7 @@ int pipi_save_sdl(pipi_image_t *img, const char *name)
img->u8 = 1;
}

pipi_get_pixels(img, img->codec_format);
pipi_set_colorspace(img, img->codec_format);
SDL_SaveBMP(img->codec_priv, name);

return 0;


+ 2
- 0
pipi/pipi.h Ver fichero

@@ -144,6 +144,8 @@ __extern int pipi_save(pipi_image_t *, const char *);

__extern void pipi_set_gamma(double);
__extern pipi_pixels_t *pipi_get_pixels(pipi_image_t *, pipi_format_t);
__extern void pipi_release_pixels(pipi_image_t *, pipi_pixels_t *);
__extern void pipi_set_colorspace(pipi_image_t *, pipi_format_t);
__extern int pipi_get_image_width(pipi_image_t *img);
__extern int pipi_get_image_height(pipi_image_t *img);
__extern int pipi_get_image_pitch(pipi_image_t *img);


+ 11
- 0
pipi/pixels.c Ver fichero

@@ -250,6 +250,17 @@ pipi_pixels_t *pipi_get_pixels(pipi_image_t *img, pipi_format_t type)
return &img->p[type];
}

void pipi_release_pixels(pipi_image_t *img, pipi_pixels_t *p)
{
return;
}

void pipi_set_colorspace(pipi_image_t *img, pipi_format_t fmt)
{
pipi_pixels_t *p = pipi_get_pixels(img, fmt);
pipi_release_pixels(img, p);
}

void pipi_set_gamma(double g)
{
if(g > 0.)


+ 0
- 1
pipi/tiles.c Ver fichero

@@ -107,6 +107,5 @@ pipi_tile_t *pipi_create_tile(pipi_format_t fmt, int plane)

return ret;
}

#endif /* USE_TILES */


Cargando…
Cancelar
Guardar