Add new comment

Each row contains not visible

Each row contains not visible pixels on both ends:
- on left (0.... left_margin-1)
- and on right (from visible area end to row end)
Also, rows may be aligned for efficient SSE/AVX access. LibRaw internal code do not align rows, but if you use LibRaw+RawSpeed, RawSpeed will align rows on 16 bytes.
So, it is better to use imgdata.sizes.raw_pitch (it is in bytes, so divide /2 for bayer data) instead of raw_width.

So, right (pseudo)code is something like this:

#define VISIBLE_PIXEL(row,col)  \
imgdata.rawdata.raw_image[(row+imgdata.sizes.top_margin)*imgdata.sizes.raw_pitch/2 + imgdata.sizes.left_margin+col]
 
for(int r = 0; r < imgdata.sizes.height; r++)
 for(int c=0; c<imgdata.sizes.width; r++)
  next_pixel = VISIBLE_PIXEL(r,c);

Add your data object name before imgdata to get correct code

-- Alex Tutubalin @LibRaw LLC