Changeset 3084 for libpipi/trunk


Ignore:
Timestamp:
Oct 24, 2008, 2:18:42 PM (12 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Fixed a non-initialized memory bug, which caused histogram function to fail here and there
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/histogram/histogram.c

    r2905 r3084  
    4444
    4545    data = (uint8_t *)pipi_getpixels(img, PIPI_PIXELS_RGBA_C)->pixels;
     46    memset(h->a, 0, 256*(sizeof(unsigned int)));
     47    memset(h->r, 0, 256*(sizeof(unsigned int)));
     48    memset(h->g, 0, 256*(sizeof(unsigned int)));
     49    memset(h->b, 0, 256*(sizeof(unsigned int)));
     50    memset(h->y, 0, 256*(sizeof(unsigned int)));
     51
    4652
    4753    for(i=0; i< img->w*img->h*4; i+=4)
    4854    {
    4955        if(flags&PIPI_COLOR_A)
    50         h->a[data[i+3]]++;
     56            h->a[data[i+3]]++;
    5157        if(flags&PIPI_COLOR_R)
    52         h->r[data[i+2]]++;
     58            h->r[data[i+2]]++;
    5359        if(flags&PIPI_COLOR_G)
    54         h->g[data[i+1]]++;
     60            h->g[data[i+1]]++;
    5561        if(flags&PIPI_COLOR_B)
    56         h->b[data[i]]++;
     62            h->b[data[i]]++;
    5763        if(flags&PIPI_COLOR_Y)
    5864        {
Note: See TracChangeset for help on using the changeset viewer.