Hi all,

I am currently working on a small project that involves processing images (for fun/to learn the language). While I have already had relative success with the project, I keep finding myself pondering on whether or not I chose the best data structure.

Currently, I am using a "two dimensional" array of Pixel structs (which contain r, g, b, and alpha). I have seen other code examples, however, that store the raw image data in a single dimensional arrayin which the color channel alternates (for example: int image[] = {r,g,b,r,g,b,r,g,b...}).

Is there any advantage to storing the image as a single dimensional array (other than the fact that it is a little bit easier to allocate)? I originally chose the "two dimensional" paradigm for the fact that it better resembles an actual image.

Also, a question about accessing the data stored in these data structures: should I write special functions to retrieve data from the image structs when I write filters/image processing algorithms or is it better to simply access the data directly (e.g. image->data[x][y].r)... The reason I ask is because I come from a java background, where everything is driven by OO and accessor methods, so I am not sure what is the most "C-like" approach.

If you feel that viewing my code for the image structures would help to better evaluate the situation, I can post it a bit later.

Thanks,
Lilrayray