2
votes

I loaded a 1 pixel image into a bitmap and then converted it to a byte[]

           _Image = "test.jpg";

            Bitmap testImage = new Bitmap(_Image);

            ImageConverter converter = new ImageConverter();
            byte[] byteTestImage =  (byte[])converter.ConvertTo(testImage,typeof(byte[]));

The single pixel has RGB values (255, 116, 25). Each of these can be represented by a byte, so I assumed that byteTestImage would correspond to this. But, byteTestImage is 635 elements in total.

What is the relationship between those bytes and the 1 pixel image?

2
Take a look at the Bitmap File Format.Dustin Kingen
The file itself isn't just the RGB elements. It can also feature an Alpha channel (another byte), and will have file header information. For example, header info denoting that it's a JPG. When you think about it, this must exist as how else does an image know how tall or wide it is in the very least?Adam Houldsworth

2 Answers

0
votes

There is no always RGB format for single pixel in Bitmap. It all depends on format. You can have a alfa component, you can have a palette to which martix of pixels refers to and more...

Check out: Bitmap format

0
votes

The file you loaded is a JPG. It has certain additional information (width, height, EXIF data) not just colors. Look at https://en.wikipedia.org/wiki/JPEG

Try opening it in a hex editor. You might even be able to read info about the camera used to take it.