Argh! It always comes to this when I'm working with images. Usually, when I need to programatically interpret data in a bitmap, I do it graphically, using GetPixel in a PictureBox. But that's slow and inefficient.
How can I load each pixel of a bitmap into a 2-dimensional array? Say the bitmap is 10 pixels by 10 pixels: the array would be Bitmap(10,10).
Each item in the array would contain a long value indicating the color at that location in the file.
Can someone help me with this?
It should explain everything you need to know about bitmap images on a raw binary level...
It's just basic theory, but you can adapt the code to basically anything bitmap related...
Hope this helps... enjoy...
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
I keep getting a 'Subscript out of Range' error...
I haven't tried to understand the code yet, but what exactly does it do? Does it open an existing bitmap and interprets it or does it create a bitmap file?
Basically what the program does is convert a bitmap into 24bit depth...
The reason I gave you the file (even tho it's irreleveant) is that it loads the bits for the bitmap directly from the file i.e. it stores the pixel location and the colour of the pixel directly into the array, without having to open the image and do a pixel scan....
That way it's much faster...
As for the error, I'll check it out and get back to you...
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
Alright, thanks. (There's an invalid label, too, but all you have to do is change "ErrHandler" to "ErrHandle" in the GoTo statement).
Now what is 24bit depth? Well, obviously, 24 bits of color but -- argh, I'm confused. I did some research, but it didn't help...
Just take a look at the part where the data is loaded into the arrays....
After a while at staring at it it begins to make sense...
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
Yes, but you still have to load the picture onto a device context...
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.