SET PROCEDURE TO gdiplus ADDITIVE
PRIVATE gdiplus, src, dst, himage
gdiplus = CREATEOBJECT("gdiplusinit")
src = CREATEOBJECT("gdiimage", "c:\windows\forest.bmp")
dst = CREATEOBJECT("gdiimage", src)
IF dst.imgtype=0 OR VARTYPE(dst.graphics) <> "O"
? "Error code:", dst.errorcode
RETURN
ENDIF
LOCAL gdibrush, gdipen, fnt
STORE 0 TO gdibrush, gdipen
* creating brush, pen and font objects
* note that the alpha channel is defined for the solid brush,
* which creates semi-transparent fill
= GdipCreateSolidFill(ARGB(255,255,255, 128), @gdibrush)
= GdipCreatePen1(ARGB(220,220,255), 2, 2, @gdipen)
fnt = CREATEOBJECT("gdifont", "Arial", 24, 1, ARGB(220,220,255))
* drawing filled semi-transparent rectangle with a border
= GdipFillRectangle(dst.graphics.graphics, gdibrush, 5,5, 160,50)
= GdipDrawRectangle(dst.graphics.graphics, gdipen, 5,5, 160,50)
* printing text
= dst.graphics.DrawText("SAMPLE",;
fnt, 10,10, dst.imgwidth-10, 0)
* releasing system resources
= GdipDeletePen(gdipen)
= GdipDeleteBrush(gdibrush)
* creating drawing surface based on main VFP window
LOCAL gr
gr = CREATEOBJECT("graphics", _screen.HWnd)
gr.DrawImage(src, 20,20)
gr.DrawImage(dst, 20+src.imgwidth+5,20)
*= dst.SaveToFile("d:\temp\tmp.bmp")
* end of main
|