I wrote my own BMP class, but just to be sure this is a wacky bug, I went to this website: write your own bitmaps and downloaded the source code. In the main source file you can set four pixels a RGB value. The code looks like this:
// Red Green
// |---------------| |--------------|
uint8_t data[] = { 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00,
0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF };
// |--------------| |--------------|
// Blue Purple
And the image that it saves on the computer looks fine. (First 2x2 image is RedGreenBluePurple)
And now, for example, I set each pixel to (11, 255, 255):
// Blue Blue
// |---------------| |--------------|
uint8_t data[] = { 0x0B, 0xFF, 0xFF, 0x0B, 0xFF, 0xFF,
0x0B, 0xFF, 0xFF, 0x0B, 0xFF, 0xFF };
// |--------------| |--------------|
// Blue Blue
And the image looks fine. (Second 2x2 image is light blue)
But now, for the weird stuff. If you set ANY of the RGB elements to the NUMBER 10 or 0x0A, the image gets completely messed up!! For consistency purposes, I will change the 0x0B or number 11 to simply 10:
// What? What?
// |---------------| |--------------|
uint8_t data[] = { 0x0A, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF,
0x0A, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF };
// |--------------| |--------------|
// What? What?
The bmp is all wrong! (Third 2x2 image which is RedBlueLightBlueYellow)
Here is something fun. Let's set everything to Purple:
// Purple! Purple!
// |---------------| |--------------|
uint8_t data[] = { 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF,
0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF };
// |--------------| |--------------|
// Purple! Purple!
Image is fourth one down. (All Purple)
And again, let's set one of the elements in one of the pixels to 0x0A:
// ?! ?!
// |---------------| |--------------|
uint8_t data[] = { 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF,
0xFF, 0x00, 0xFF, 0xFF, 0x0A, 0xFF };//set green element to 0x0A
// |--------------| |--------------|
//
Image looks all whacky. It is the bottom one. (GreenLightBluePurpleDarkBlue)
I may have given too many examples, but I am really stumped on why this is happening! I get the exact same thing in my very own program as well and I believe I am doing padding right and everything. Your thoughts? Thanks.
Here is the link to the 2x2 bmp images. They are organized top to bottom in accordance with each code snippet. 2b2_bmp_images