Changeset 3341


Ignore:
Timestamp:
Jan 13, 2009, 12:51:17 AM (12 years ago)
Author:
Sam Hocevar
Message:

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.

Location:
libpipi/trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/examples/edd.c

    r3340 r3341  
    5050    /* Load image, convert it to grayscale, dither it with Floyd-Steinberg */
    5151    img = pipi_load(argv[1]);
    52     pipi_get_pixels(img, PIPI_PIXELS_Y_F);
     52    pipi_set_colorspace(img, PIPI_PIXELS_Y_F);
    5353    gauss = pipi_gaussian_blur(img, sigma);
    5454    kernel = pipi_load("ediff:fs");
  • libpipi/trunk/examples/img2rubik.c

    r3340 r3341  
    112112
    113113    pipi_save(dst, argv[2]);
     114    pipi_release_pixels(dst, p);
    114115
    115116    return 0;
  • libpipi/trunk/pipi-sharp/Picture.cs

    r3340 r3341  
    9191         SuppressUnmanagedCodeSecurity]
    9292        private static extern IntPtr pipi_get_pixels(IntPtr img, int type);
     93        [DllImport("libpipi-0.dll", CallingConvention=CallingConvention.Cdecl),
     94         SuppressUnmanagedCodeSecurity]
     95        private static extern void pipi_release_pixels(IntPtr img, IntPtr p);
    9396        public byte[] GetPixels(int w, int h, int x, int y)
    9497        {
     
    117120            }
    118121
     122            pipi_release_pixels(_picture, pixels);
     123
    119124            return array;
    120125        }
  • libpipi/trunk/pipi/analysis/histogram.c

    r3340 r3341  
    3636int pipi_get_image_histogram(pipi_image_t *img, pipi_histogram_t*h, int flags)
    3737{
     38    pipi_pixels_t *p;
    3839    uint8_t  *data;
    3940    float n;
     
    4344    if(!h) return -1;
    4445
    45     data = (uint8_t *)pipi_get_pixels(img, PIPI_PIXELS_RGBA_C)->pixels;
     46    p = pipi_get_pixels(img, PIPI_PIXELS_RGBA_C);
     47    data = (uint8_t *)p->pixels;
    4648    memset(h->a, 0, 256*(sizeof(unsigned int)));
    4749    memset(h->r, 0, 256*(sizeof(unsigned int)));
     
    119121    }
    120122
     123    pipi_release_pixels(img, p);
     124
    121125    return 0;
    122126}
  • libpipi/trunk/pipi/analysis/measure.c

    r3340 r3341  
    4242    f2 = i2->last_modified;
    4343
     44    /* FIXME: this is not right */
    4445    pipi_get_pixels(i1, PIPI_PIXELS_Y_F);
    4546    pipi_get_pixels(i2, PIPI_PIXELS_Y_F);
  • libpipi/trunk/pipi/codec/gdi.c

    r3340 r3341  
    7171     * but we'd need a more thorough test. */
    7272
     73    pipi_release_pixels(img, p);
     74
    7375    img->codec_priv = NULL;
    7476
     
    136138    CloseHandle(hfile);
    137139
     140    pipi_release_pixels(img, p);
     141
    138142    return 0;
    139143}
  • libpipi/trunk/pipi/codec/imlib.c

    r3340 r3341  
    9999    }
    100100
    101     pipi_get_pixels(img, img->codec_format);
     101    pipi_set_colorspace(img, img->codec_format);
    102102    imlib_context_set_image(img->codec_priv);
    103103    imlib_save_image(name);
  • libpipi/trunk/pipi/codec/modular/jpeg.c

    r3340 r3341  
    206206    fclose(fp);
    207207
     208    pipi_release_pixels(img, pixels);
     209
    208210    return 1;
    209211}
  • libpipi/trunk/pipi/codec/opencv.c

    r3340 r3341  
    9292    }
    9393
    94     pipi_get_pixels(img, img->codec_format);
     94    pipi_set_colorspace(img, img->codec_format);
    9595    cvSaveImage(name, img->codec_priv);
    9696
  • libpipi/trunk/pipi/codec/oric.c

    r3340 r3341  
    111111    img->u8 = 1;
    112112
     113    pipi_release_pixels(img, p);
     114
    113115    return img;
    114116}
     
    140142
    141143    if(img->w != WIDTH || img->h != HEIGHT)
    142     {
    143144        tmp = pipi_resize(img, WIDTH, HEIGHT);
    144         p = pipi_get_pixels(tmp, PIPI_PIXELS_RGBA_F);
    145     }
    146145    else
    147         p = pipi_get_pixels(img, PIPI_PIXELS_RGBA_F);
     146        tmp = img;
     147    p = pipi_get_pixels(tmp, PIPI_PIXELS_RGBA_F);
    148148    data = p->pixels;
    149149    screen = malloc(WIDTH * HEIGHT / 6);
    150150    write_screen(data, screen);
    151     if(tmp)
     151    pipi_release_pixels(tmp, p);
     152    if(tmp != img)
    152153        pipi_free(tmp);
    153154
  • libpipi/trunk/pipi/codec/sdl.c

    r3340 r3341  
    9696    }
    9797
    98     pipi_get_pixels(img, img->codec_format);
     98    pipi_set_colorspace(img, img->codec_format);
    9999    SDL_SaveBMP(img->codec_priv, name);
    100100
  • libpipi/trunk/pipi/pipi.h

    r3340 r3341  
    145145__extern void pipi_set_gamma(double);
    146146__extern pipi_pixels_t *pipi_get_pixels(pipi_image_t *, pipi_format_t);
     147__extern void pipi_release_pixels(pipi_image_t *, pipi_pixels_t *);
     148__extern void pipi_set_colorspace(pipi_image_t *, pipi_format_t);
    147149__extern int pipi_get_image_width(pipi_image_t *img);
    148150__extern int pipi_get_image_height(pipi_image_t *img);
  • libpipi/trunk/pipi/pixels.c

    r3340 r3341  
    251251}
    252252
     253void pipi_release_pixels(pipi_image_t *img, pipi_pixels_t *p)
     254{
     255    return;
     256}
     257
     258void pipi_set_colorspace(pipi_image_t *img, pipi_format_t fmt)
     259{
     260    pipi_pixels_t *p = pipi_get_pixels(img, fmt);
     261    pipi_release_pixels(img, p);
     262}
     263
    253264void pipi_set_gamma(double g)
    254265{
  • libpipi/trunk/pipi/tiles.c

    r3339 r3341  
    108108    return ret;
    109109}
    110 
    111110#endif /* USE_TILES */
    112111
Note: See TracChangeset for help on using the changeset viewer.