2006-09-12

Helper code to create image on the fly for "Using the Alpha Channel in Visual Foxpro Images" from Bernard Bout

Here's another very simple code that attends Bernard Bout, creating an image on the fly, based on his post entitled "Using the alpha channel in visual foxpro images". Again in this sample, I'm using the new gdiplus-x classes from vfp-x project that can be downloaded from here: http://www.codeplex.com/wiki/view.aspx?projectname=vfpx&title=gdiplusx


Hope this helps Bernard !


Target image: mainform.png



* Helper code to create image on the fly for
* bernard bout "Using the alpha channel in VFP images"
*
http://weblogs.foxite.com/bernardbout/archive/2006/09/11/2436.aspx
*    image dimensions 300 x 270 pixels
*    make all image totally transparent
*    draw a light yellow - rgb(254,254,228) rectangle
*         centered in the main image.
*    save as png, to preserve the transparencies


do locfile("system.app")


with _screen.system.drawing


* create an empty bitmap
local lobitmap as xfcbitmap
lobitmap = .bitmap.new(300,270)


* initialize the graphics object
local logfx as xfcgraphics
logfx = .graphics.fromimage(lobitmap)


* make all image transparent
logfx.clear(.color.fromargb(0,0,0,0))


* draw the yellow rectangle
logfx.fillrectangle(.solidbrush.new(.color.fromrgb(254,254,228)), 10,9,278,249)


* save as png to keep transparencies
lobitmap.save("c:\bernardboutagain.png", .imaging.imageformat.png)


endwith


return

2 comments:

  1. New to VFP

    I m using presently VFP6. Is it possible to change BUTTON Colors/Pictures
    in VFP6

    PLEASE PLASESESESESESESE!!!!!
    Yes, There are some workarounds.
    Check at www.news2news.com for an interesting aproach.

    ReplyDelete
  2. Versión en Español de este artículo en / Spanish version at http://www.portalfox.com/article.php?sid=2263

    ReplyDelete