I m developping imaging functions (yes I REALLY want to reinvent the wheel for various reasons).
I m copying bitmaps into unsigned char arrays but I m having some problem with byte size versus image pixel format.
for example a lot of images come as 24 bits per pixel for RGB representation so that s rather easy, every pixel has 3 unsigned chars (bytes) and everyone is happy
however sometimes the RGB has weirder types like 48 bits per pixel so 16 bits per color channel. Copying the whole image into the byte array works fine but its when I want to retrieve the data that things get blurry
Right now I have the following code to get a single pixel for grayscale images
unsigned char NImage::get_pixel(int i, int j)
{
return this->data[j * pitch + i];
}
NImage::data is unsigned char array
This returns a single byte. How can I access my data array with different pixel formats?