I need to come back again. I have the following declare, which implicit needs a color as hex literal Integer Value:
[code]
g.ForeColor = &cEA8906
Dim pen As Integer
Declare Function GdipCreatePen1 Lib “Gdiplus” (colour As Int32, width As Single, unit As GraphicsUnit, ByRef pen As Integer) As Status
s = GdipCreatePen1(Int32(g.ForeColor), g.PenWidth, GraphicsUnit.Pixel, pen)[/code]
Int32(g.ForeColor) doesn’t work. It needs to be &hFFEA8906 (Pattern: &hAARRGGBB). How do I get this to work?
An Xojo color value is RRGGBBAA and the alpha value looks like it is inverted (00=opaque in Xojo, but might be FF for GDI)
So do some bitwise math to strip the alpha off the end, divide by 256 (or rotR 8) then OR the alpha back on the front again
or for brute force
FUNCTION GDI_RGB(c as Color) As Integer
dim r as integer = c.red
dim g as integer = c.green
dim b as integer= c.blue
dim a as integer = 255 - c.alpha
dim s as string="&H"+right("00"+hex(a),2)+right("00"+hex(r),2)right("00"+hex(g),2)+right("00"+hex(b),2)
return val(s)
END FUNCTION