Help required for understanding coordinates

Hi there,
I am a student, who tries to implement a routine for homework. I am totally new to this library and it took me a while to link it to my VS2019 environment. But now it basically works fine, but...

I am currently starting with a vertical slice of my homework. So I try to figure out, how to read out indivduell pixel color information. Unfortunately I pick implausible values.

There is a Raw Picture, I use as a test-picture. It contains a red road-sign, so I am assuming, that the red-value, I am logging out for debugging purpose should be much higher than the blue or green values. But it isn't.

So now I wonder how to calculate the right coordinates.

I figured out there are some border pixels, do I have to add them to the x and y values? Or am I doing something else wrong?

conditions
- I use the parameter RawProc.imgdata.params.half_size = 1
- I am using Nikon D5100 NEF files

Expectation:
I try to address the pixel 1370x2894. According to the color picker of IrfanView the RGB (24bit) value is {119,12,6}.
According to my debug output the same pixel has the RGBG (48bit) value is {70,124,74,132}.

I am addressing the pixel by following value

#define IMGWIDTH 4928
#define RED 0
const unsigned long coordinat = y/2 * (IMGWIDTH/2) + x/2;
printf("[DEBUG] Red at 1370x2894: %d \n", RawProc.imgdata.image[coordinate][RED]);

Thanks so much in advance!

Forums: 

coordinate is (y * width) + x

coordinate is (y * width) + x (unless you use half_size option).

Values in imgdata.image array are 16 bit/linear space, IrfanView values are, most likely, 8bit/gamma corrected.

-- Alex Tutubalin @LibRaw LLC

Thank you Alex,

Thank you Alex,
but is the coordinate with or without the border?
If it's with border, is the border always the same size left/right and top/bottom. So the "real" picture is always centred?
And where is the viewport? Is it at top/left or bottom/left or even somewhere else?
Thanks once again!

imgdata.image is already

imgdata.image is already cropped to visible area.

-- Alex Tutubalin @LibRaw LLC

Thanks

Thanks for the quick reply!