Since GetPixel is slow and I keep having to access bitmap data with unsafe code, I thought it would be a nice thing to make into a snippet.
-
Home > .net
Since GetPixel is slow and I keep having to access bitmap data with unsafe code, I thought it would be a nice thing to make into a snippet.
Turns out, copying an image using Clone really does make an exact copy. You can’t just open an image, clone it, then safely close it as you might expect, because it also copies the file lock.
Instead, copy the image in memory using Image copy = new Image(source).
This is a really nice little feature.
If we have an enumerator, say:
public enum MyEnumerator { Oranges, Apples, Hedgehogs, Laptops, Budgies, Other }
Having a form with a ComboBox called comboBox1, put this in the constructor/form load etc:
this.comboBox1.DataSource = Enum.GetValues(typeof(MyEnumerator));
This fills the combobox with the values. To convert the current combobox value back into the enumerator’s value:
MyEnumerator [...]
Here’s a quick list of essential plug-ins and tools for Visual Studio. All of them are free, and this is mainly so the next time I reinstall windows I won’t spend ages trying to remember what that thing I use was called.
Microsoft StyleCop: http://code.msdn.microsoft.com/sourceanalysis
This is the source analysis tool from and used by Microsoft programmers, [...]
A CaptureBuffer is a buffer of a specified length that reads audio from a Capture object which represents the capture (or input) device, into a one-dimensional array of bytes with a specified WaveFormat.
A DirectSound Buffer is a one-dimensional array of bytes which represent sound waves in a digital form. The data is laid out in a specified Microsoft.DirectX.DirectSound.WaveFormat which specifies the format type, number of channels, number of samples per second and so on.1
Each byte is a part of a sample, and a sample represents the average [...]
After struggling with WinAPI code and hacks in .NET 1.0 I was really looking forward to the TextRenderer class when I first heard about it. But as it turns out, not only is TextRenderer horrible at measuring character size it is also monumentally slow at rendering text.
One of many flaws with the RichTextBox control is its lack of support for drag/drop operations. Luckily it’s simple to add. In fact, it’s so simple you’ll wonder why they didn’t just support it out of the box.
Recently while reworking the code for the Ascgen dotNET I needed to make sure that a variable is between 0 and 255 before converting it to a byte, and I needed it to be as fast as possible since it can get called several million times a second.