|
|
@@ -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.; |
|
|
|