Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pixel color : long to ARGB

Status
Not open for further replies.

vitaloverdose

Programmer
Jan 29, 2006
13
GB
Hi im using Microsoft's WIA to gain access to the ARGB of PNG images. The WIA has an ARGB filter that breaks the image up into long values for the color of each pixel. How can i then break this number down into its separate alpha,red,green and blue values?
thanks.
 
I see you've asked this on other sites, and got what I consider to be over complicated results.

I tend to do these sort of easy conversions with UDTs:
Code:
[blue]Option Explicit

' Declaration order of bytes important because of how a long is held in PC memory
Private Type ARGB
    Blue As Byte
    Green As Byte
    Red As Byte
    Alpha As Byte
End Type

Private Type udtLong
    l As Long
End Type

Public Sub example()
    Dim Filter As ARGB
    Dim WIAFilter As udtLong
    
    ' Convert an ARGB long into component parts
    WIAFilter.l = &HFF001234
    LSet Filter = WIAFilter
    MsgBox "Alpha: " & Filter.Alpha & " Red: " & Filter.Red & " Green: " & Filter.Green & " Blue: " & Filter.Blue
    
    'Convert component parts into ARGB long
    With Filter
        .Alpha = 17
        .Red = 127
        .Green = 37
        .Blue = 100
    End With
    LSet WIAFilter = Filter
    MsgBox "ARGB: " & Hex(WIAFilter.l)

End Sub
[/blue]



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top