Take for example the classic 24-bit BMP. It is required to paint on it, say, in black a point with the coordinate (x,y) . Pixel data is presented in a one-dimensional array.
Since the BMP file is read from the end, it is logical to present the sought coordinate as m_pBits[((m_nHeight-y-1)*m_nWidth+m_nWidth-x-1)*3] (+1 and +2 for the green and red components) .
But as a result of the program, all points are located with an offset! That is, if a point has a coordinate (0,0) , then it is displayed as (смещение, 0) .
How to correctly represent a point with given coordinates in a one-dimensional array?