All pastes #490079 Raw Edit

dtony's bug

public c v1 · immutable
·published 2007-05-15 20:48 UTC
rendered paste body
/* standard headers */#include <X11/Xlib.h>#include <Imlib2.h>#include <stdio.h>#include <string.h>#include <stdlib.h>void compute_area(int x, int y, int size,Imlib_Color **image){  int a,b,cpt;  int red,green,blue=0;  Imlib_Color colors;  for(a = (x*size) ; a<((x*size)+size); a++){    for(b = (y*size) ; b<((y*size)+size); b++){      imlib_image_query_pixel(a, b, &colors);      red += colors.red;      green += colors.green;      blue += colors.blue;      cpt++;    }   }  colors.red = red/cpt;  colors.green = green/cpt;  colors.blue = blue/cpt;  printf("ok\n");  printf("ref fn : %p\n",image);  image[x][y] = colors;}/* main program */int main(int argc, char **argv){  /* an image handle */  Imlib_Image image;  Imlib_Color **new_image;  int tile_size = 100; /* size of tiles, height and width are equals */  int width, height,i,j;  Imlib_Color color;  /* if we provided < 2 arguments after the command - exit */    if (argc != 2){    printf("Bad argument number\n");    exit(1);  }  /* load the image */  image = imlib_load_image(argv[1]);  /* if the load was successful */  if (image){    /* set the image we loaded as the current context image to work on */    imlib_context_set_image(image);    /*get width and height*/    width = imlib_image_get_width();    height = imlib_image_get_height();    /*set new_image table */    new_image = malloc((width/tile_size)*(height/tile_size)*sizeof(Imlib_Color));    printf("size of table : %d\n",(int) ((width/tile_size)*(height/tile_size)*sizeof(Imlib_Color)));    new_image[0][0] = color;    for(i=0 ; i<width; i++){      for(j=0 ; j<height; j++){	printf("area : %d, %d\n",i,j);	compute_area(i,j,tile_size,new_image);      }    }          }  return 0;}