Reputation: 5101
I know I can use
string base64Encoded = ...;
byte[] byteArray = Convert.FromBase64String(this.base64Encoded); // array size [31591]
var memoryStream = new MemoryStream(byteArray);
var bitmap = new Bitmap(memoryStream);
//byte[,] im = new byte[a.Width*a.Height,3];
// array size [891998, 3] - why this array is 90 times bigger?
but I want to do it manually.
What I really need is to know how from byteArray I can create 3dim pixel array [bitmap.width * bitmap.hight, 3 {Red,Green,Blue}]
Upvotes: 0
Views: 83
Reputation: 3685
1- size of byteArray
is different from size of bitmap
since bitmap
is actually an uncompressed 24 bit image without a header, but byteArray
is a compressed (RLE most likely) bitmap file.
2- you can use libbmp or another image processing library to load and manipulate pixels. These libraries are much better at handling that kind of stuff.
3- most bitmaps are compressed using RLE compression and bitmap is a very simple format. You can actually write a bitmap reader to read it to a byte array intead of Bitmap object.
Upvotes: 1