I had a need to directly manipulate the bytes in a bitmap for my VB.Net app for Windows Phone. I found quite a few articles with The Google on how to do this in C#, using the unsafe keyword. That's a perfectly fine way of doing it for C# users. However, VB.Net does not have anything like the unsafe keyword, so there is no way to run unsafe (unmanaged) code blocks. Philosophically, this might be a "good" thing to Managed Code purists. I'm actually neutral on the issue. Still, just because you can't do arbitrary pointer and memory manipulation in VB.Net does not mean you can't do this very simple thing (dimming the color brightness of each byte of a bitmap). It's pretty easy and I can't believe nobody out there has posted how to do it this way VB.Net or C#. I came up with this code for the Compact Framework for Windows Phone specifically, but it will also work in the big Framework for big Windows. It will work in both VB.Net and C# just fine.
[ Read entire post ]