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 VFPX project that can be downloaded from GitHub



* 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
    m.loBitmap = .BITMAP.New(300,270)

    * initialize the graphics object
    LOCAL loGfx AS xfcGraphics
    m.loGfx = .Graphics.FromImage(m.loBitmap)

    * make all image transparent
    m.loGfx.CLEAR(.COLOR.FromARGB(0,0,0,0))

    * draw the yellow rectangle
    m.loGfx.FillRectangle(.SolidBrush.New(.COLOR.FromRGB(254,254,228)), 10,9,278,249)

    * save as png to keep transparencies
    m.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