{"id":189,"date":"2006-09-03T15:09:46","date_gmt":"2006-09-03T23:09:46","guid":{"rendered":"http:\/\/spacefold.com\/colin\/morethanfour\/?p=189"},"modified":"2020-08-16T15:10:13","modified_gmt":"2020-08-16T23:10:13","slug":"argb-values-using-binary-manipulation-functions-in-vfp","status":"publish","type":"post","link":"https:\/\/spacefold.com\/colin\/morethanfour\/2006\/09\/03\/argb-values-using-binary-manipulation-functions-in-vfp\/","title":{"rendered":"ARGB values using binary manipulation functions in VFP"},"content":{"rendered":"\n<p>In my session sample code for the&nbsp;<a href=\"http:\/\/advisorevents.com\/\">Advisor Summit<\/a>&nbsp;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:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">:\nthis.colorHelper.Set( mod(m.iRGB,256), ;\n                      mod(int(m.iRGB\/256),256), ;\n                      mod(int(m.iRGB\/(256*256)),256), ;\n                      this.alpha )\n\t\t\nthis.brush.BrushColor = this.colorHelper.ARGB\n:<\/pre>\n\n\n\n<p>I see that Walter Nicholls&nbsp;<a href=\"http:\/\/www.cornerstone.co.nz\/archives\/7\">mentions this subject back in May<\/a>&nbsp;and shows an alternative method that does not require the gpColor object:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">this.brush.BrushColor = ;\n         bitor( bitlshift(bitand(iif(vartype(this.alpha)=='N', this.alpha, 0xFF), 0xFF ),24) ;\n              , bitlshift(bitand(m.iRGB,0xFF),16) ;\n                        , bitand(m.iRGB,0x0000FF00) ;\n              , bitrshift(bitand(m.iRGB,0x00FF0000),16) )\n<\/pre>\n\n\n\n<p>Although I&#8217;m tempted to describe this as an example of &#8220;write-only code&#8221;, it does show good use of those binary manipulation functions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my session sample code for the&nbsp;Advisor Summit&nbsp;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-189","post","type-post","status-publish","format-standard","hentry","category-foxpro","post-preview"],"_links":{"self":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts\/189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/comments?post=189"}],"version-history":[{"count":0,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts\/189\/revisions"}],"wp:attachment":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/media?parent=189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/categories?post=189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/tags?post=189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}