Browse Source

* Fixed a non-initialized memory bug, which caused histogram function to fail here and there

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3084 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
jylam 16 years ago
parent
commit
cf55ba13db
1 changed files with 10 additions and 4 deletions
  1. +10
    -4
      pipi/histogram/histogram.c

+ 10
- 4
pipi/histogram/histogram.c View File

@@ -43,17 +43,23 @@ int pipi_get_image_histogram(pipi_image_t *img, pipi_histogram_t*h, int flags)
if(!h) return -1;

data = (uint8_t *)pipi_getpixels(img, PIPI_PIXELS_RGBA_C)->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)));
memset(h->b, 0, 256*(sizeof(unsigned int)));
memset(h->y, 0, 256*(sizeof(unsigned int)));


for(i=0; i< img->w*img->h*4; i+=4)
{
if(flags&PIPI_COLOR_A)
h->a[data[i+3]]++;
h->a[data[i+3]]++;
if(flags&PIPI_COLOR_R)
h->r[data[i+2]]++;
h->r[data[i+2]]++;
if(flags&PIPI_COLOR_G)
h->g[data[i+1]]++;
h->g[data[i+1]]++;
if(flags&PIPI_COLOR_B)
h->b[data[i]]++;
h->b[data[i]]++;
if(flags&PIPI_COLOR_Y)
{
uint32_t p = 0.;


Loading…
Cancel
Save