2006-08-10

New VFP-X GDI+ classes

In the last weeks I've been doing some extensive tests and creating some examples using the new VFP-X GdiplusX library. These classes are terrific, completely insane. this library is already making my life with gdi+ a lot easier.

The more I use it, the more I like it. I'm really having fun.

As Craig Boyd said in one of his blog posts: "the GdiplusX library is a pure Visual FoxPro reproduction of the drawing related namespaces in .NET. We've coded well over 40,000 lines of vfp code and the library consists of 80+ classes now. at nearly 95% complete. It is safe to say that no other library on the planet gives visual foxpro developers the functionality and power that this one does when working with gdi+. " - That's totally true.

 

If you're planning to start a new project and will need to use gdi+, or are interested to help in the project, coding, testing making suggestions, i strongly recommend to enter the codeplex vfp-x page, select the "releases" tab, and download the most recent stable version available.

Start running the file demo.prg in the samples folder, and you'll have a good idea of the power of the class.

Bo has suggested that from now on we should do our communication only via codeplex, using the discussions and issue tracker sections. this way, as bo said "other people may pitch in and get involved if they see there is some activity and that it is easy for them to collaborate also".

By the way, the VFP-X project now has a new logo too !

1000.107.2193.vfpxlogo

 

From now on, I'll use this space to show some examples using these classes. You may use the comments space of this blog to make this kind of requests.

 

code samples

My first example comes to attend Bernard Bout, to create an image to be used in his "blueglass" example. You can obtain more information at this link: http://weblogs.foxite.com/bernardbout/archive/2006/06/15/1838.aspx

Create a 2x2 pixel image, with a blue background and a magenta pixel at (0,0)

Here's the code:

** creates an image to be used in the "blueglass" example
** from bernard bout
** 2x2 pixel image, with blue background and a magenta pixel at (0,0)

do locfile("system.app")

* define the colors to be used
lnrgbpointclr = rgb(0,0,255) && blue
lnrgbbackgclr = rgb(255,0,255) && magenta

with _screen.system.drawing
local lobitmap as xfcbitmap
local locolor as xfccolor
local logfx as xfcgraphics

* create a new 2x2 bitmap in the default pixelformat - 32bppargb
lobitmap = .bitmap.new(2,2)

* create a graphics object to be able to use the clear function,
* that will fill all the bitmap with the desired color.
* for this case that is not fundamental, because the bitmap is
* small, so we could calls "setpixel" 4 times to cover
the bitmap.
logfx = .graphics.fromimage(lobitmap)
logfx.clear(.color.fromrgb(lnrgbbackgclr))

* draw the pixel
lobitmap.setpixel(0,0, .color.fromrgb(lnrgbpointclr))

* save the image as png
lobitmap.save("c:\blueglass.png", .imaging.imageformat.png)
endwith

And here's the image created in a bigger size.

1000.107.2192.BlueGlassBig

I just can't wait for Bernard's next blog post using it !

2 comments:

  1. [:                                         )

    Thanks Cesar. Will download the latest class and then blog about it...
    Cool, I hope that it will help you.

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

    ReplyDelete