Post the definitions of RED, BLUE, and GREEN.
Are they placeholders for the 0-2 index range?
In RGB picture each pixel consists of 3 colours: Red, Green and Blue, and the value is between 0 and 255 for each colour. Say, I want a pixel with coordinate (50, 50) to be Red, so I will have
Code:
image[50][50][RED] = 255;
image[50][50][GREEN] = 0;
image[50][50][BLUE] = 0;
What does "something is wrong when putting data in" mean?
Thanks for the reply, I've modernized my code
Code:
int XSIZE, YSIZE;
int ***image;
int x,y;
int Xcount, Ycount;
printf("Image width:");
scanf("%d", &Xcount);
printf("Array height: ");
scanf("%d",&Ycount);
image = malloc(YSIZE*sizeof(int**));
for (YSIZE=0; YSIZE<Ycount; YSIZE++)
{
image[YSIZE] = malloc(XSIZE*sizeof(int*));
for (XSIZE=0; XSIZE<Xcount; XSIZE++)
image[YSIZE][XSIZE] = malloc(3*sizeof(int));
}
for(y = 0; y < YSIZE; y++) //putting data into the array
for(x = 0; x < XSIZE; x++)
{
image[y][x][RED] = 255; // Value of red colour in the image
image[y][x][GREEN]= 100; // Value of green colour in the image
image[y][x][BLUE]= 100;// Value of blue colour
}
The main problem is when I start the programm. It builds with no error, but when I try to debug it gives an error and points an arrow to the row image[Ycount][Xcount][RED] = 255;