Hi Prashant,
On 7 May 2016 at 13:46, Prashant Saxena <
anima...@gmail.com> wrote:
> Could you please let me know the definition of 'somefunction' in C in this
> case?
That's a C question. It is a bit outside the scope of this mailing
list, but let me try.
> void somefunction(unsigned char *buffer){
> pixel *p;
> p = (pixel*)buffer[0][0];
> p->r, p->g, p->b
> ...
> }
An "unsigned char *" argument is a pointer to the start of the data,
which is a contiguous array, "rgbrgbrgbrgb...". There is no
information about the fact that this was originally organized as a 2D
matrix. If you need this, you need to pass extra arguments to the C
function, like "int width, int height". Then you access the pixel at
(x, y) with this kind of code:
pixel *corner, *line_start, *p;
corner = (pixel *)buffer;
line_start = corner + y * width;
p = line_start + x;
A bientôt,
Armin.