Since a 32 bit integer consumes exactly 4 bytes and an ARGB color is also exactly 4 bytes, every 32 bit integer represents a color. This article will outline how to convert those integers into colors.
*As a statement of clarification, this article is aware of the Color.FromArgb(value
as Integer) method, this article, however is intended to explain on a lower level how to convert a 32 bit integer into a color.
Using a .Net language of your choice, you can follow these steps to create a Function that will convert 32 bit integers into colors. *This example will be given in Visual Basic.Net
() = BitConverter.GetBytes(RGB)
Color.FromArgb(Alpha, Red, Green, Blue)
'Alpha is 128
Color = IntegerToColor(RGB)
= Color.FromArgb(255, MyColor)
This is obviously written for a lay person, The bit manipulation could be speed up if it weren't written for new programmers.
I was wondering if there is a reason you have used ByRef instead of ByVal in your Function IntegerToColor?
In the final code snippet regarding line14. I reckon it should read as follows:>>
If Not Button1.GetStyle(ControlStyles.SupportsTransparentBackColor) Then
as the "Me" you have used refers to Form1.
Sorry, please ignore that part of my last comment regarding "Me"
as you are setting the BackColor of the FORM itself.
That will make me re-read things two or three times in future or when I am less tired.