1. ## Question about array values

So I have an array (several, actually), which holds the RGB values of an image. I'm then doing some calculations with each of these arrays (let's say we're doing Red. Then Red[i][j] is the intensity of "redness" at the pixel (i,j)). Red is of type int, raster is of type uint32. My calculations depend on Red[i][j] being some nice number less than 256. When I run gdb, and tell it to print Red[7], for example, I get something along the lines of
Code:
(int*) 0xd3ff20
.
Can anyone tell me why it is doing this? Thanks.
Here is the relevant (hopefully) code
Code:
raster = (uint32*) _TIFFmalloc(npixels * sizeof(uint32));
if (raster == NULL) printf("no memory");
for (i = 0; i<h; i++)
{
for (j = 0; j<w; j++)
{

z = raster[i*w + j];
Red[i][j] = (z & 0xff);
Grn[i][j] = ((z>>8) & 0xff);
Blu[i][j] = ((z>>16) & 0xff);

}
}

2. Because red[7] is an array itself, and gets printed as a pointer. You do know pointers and arrays well, don't you?

3. Oh. I thought that Red[7] would decompose to Red[0][7]. Sorry.

4. A speedup:

Code:
raster = (uint32*) _TIFFmalloc(npixels * sizeof(uint32));
if (raster == NULL) printf("no memory");

DWORD dwOffset=0;
DWORD dwMaxOffset=w*h;
DWORD dwColor=0;

do
{
dwColor=raster[dwOffset];

Red[dwOffset]=(dwColor & 0xFF);
Grn[dwOffset]=((dwColor>>8) & 0xFF);
Blu[dwOffset]=((dwColor>>16) & 0xFF);

dwOffset++;
} while (dwOffset<dwMaxOffset);
One offset. One multiply. Linear array traversal.

5. 1) Use descriptive variable names, expecially if you have other people read your code.

2) For values less than 256 you can use unsigned char.