ARGBData Property
Retrieves the raw image bits as a Vector of Long values.
Syntax
[ ppResult = ] ImageFile.ARGBData
Possible Values
ppResult Vector value of image bits. The property is read-only. The property has no default value.
Remarks
The ARGBData property returns a Vector of Long values that contain raw ARGB bitmap data. Each Long value represents a pixel. The first value corresponds to the pixel at the upper left and proceeds to the right, then down. When organized this way, the count of Long values in the Vector will be the product of the image's width and height.
You can use the following function to calculate the index of a specific pixel by its (x,y) coordinate and return the value of the Vector at that location.
Function GetPixel(v, x, y, width, height) If x > width Or x < 1 Or _ y > height Or y < 1 Or _ v.Count <> width * height Then GetPixel = 0 Exit Function End If GetPixel = v(x + (y - 1) * width) End Function
Each Long value contains 4 bytes, the first byte (or high-order byte) represents the Alpha value. An Alpha value of 255 is completely opaque. An Alpha value of 0 is completely transparent (for Image types that support tranparency). Each subsequent byte corresponds to the Red, Green, and Blue value respectively.
The following example includes functions that show how to acquire the individual Alpha, Red, Green, and Blue values from a Long ARGB value.
Function Get4ByteHex(val) Dim s As String s = Hex(val) Do While Len(s) < 8 s = "0" & s Loop Get4ByteHex = Right(s, 8) End Function Function Get1ByteHex(val) Dim s As String s = Hex(val) Do While Len(s) < 2 s = "0" & s Loop Get1ByteHex = Right(s, 2) End Function Function GetAlpha(val) Dim s As String s = Get4ByteHex(val) GetAlpha = CLng("&h" & Left(s, 2)) End Function Function GetRed(val) Dim s As String s = Get4ByteHex(val) GetRed = CLng("&h" & Mid(s, 3, 2)) End Function Function GetGreen(val) Dim s As String s = Get4ByteHex(val) GetGreen = CLng("&h" & Mid(s, 5, 2)) End Function Function GetBlue(val) Dim s As String s = Get4ByteHex(val) GetBlue = CLng("&h" & Right(s, 2)) End Function Function GetARGB(a, r, g, b) Dim s As String s = "&h" & Get1ByteHex(a) & Get1ByteHex(r) & Get1ByteHex(g) & Get1ByteHex(b) GetARGB = CLng(s) End Function
For additional example code, see ARGB Filter: Create a Modified Version of an Image.
Property Information
Minimum operating systems Windows XP SP1
See Also