In my session sample code for the Advisor Summit on Visual FoxPro, I showed using the gpColor class in the FFC\_gdiplus.vcx class library to convert a color from foxpro RGB to the GDI+ style ARGB, including the alpha channel byte:
: this.colorHelper.Set( mod(m.iRGB,256), ; mod(int(m.iRGB/256),256), ; mod(int(m.iRGB/(256*256)),256), ; this.alpha ) this.brush.BrushColor = this.colorHelper.ARGB :
I see that Walter Nicholls mentions this subject back in May and shows an alternative method that does not require the gpColor object:
this.brush.BrushColor = ; bitor( bitlshift(bitand(iif(vartype(this.alpha)=='N', this.alpha, 0xFF), 0xFF ),24) ; , bitlshift(bitand(m.iRGB,0xFF),16) ; , bitand(m.iRGB,0x0000FF00) ; , bitrshift(bitand(m.iRGB,0x00FF0000),16) )
Although I’m tempted to describe this as an example of “write-only code”, it does show good use of those binary manipulation functions.