BMPPixel GetBMPPixel( BMP* Bitmap, int x, int y ){ DWORD BytesPerLine = Bitmap->Width * 3; DWORD PaddingPerLine = 0; if( BytesPerLine % 4 != 0 ) { PaddingPerLine = 4 - (BytesPerLine % 4); } return *(BMPPixel*)&Bitmap->PixelData[(x * 3) + y * (BytesPerLine + PaddingPerLine)];}
It also looks like your buffer may be to small. Again assuming 24bpp bitmaps, it should be this size
unsigned char* bitmapBuffer = new unsigned char[bitmap.width * bitmap.rows * 3];
If that is the case, than this might even work.
bitmapBuffer[(j * 3) + i * bitmap.width] = bitmap.buffer[(j * 3) + i * bitmap.width];
The reason your code my work for some glyphs may be due to the glyphs already being a multiple of 4. So there is no need for padding. The diagonal-looking figure you have practically screams some sort of offset issue.