Foxite.COM Community Weblog

Foxite.COM Community Weblog - free weblog service for the Visual FoxPro Community.
Welcome to Foxite.COM Community Weblog Sign in | Join | Help
in
Home Blogs Forum Photos Forum Archives

VFP IMAGING



Blur Images with GdiPlus X

Blurring images is also very easy.

The simplest technique is to resize the original image to a MUCH SMALLER size, and then resize it to the original size.

The reason is very obvious, when we enhance the dimensions of any image we have a loss of quality, causing the blur effect.

 
IMPORTANT
Requires VFP9 and GdiPlusX to run. 
Please make sure that you have the latest version!
http://www.codeplex.com/VFPX/Wiki/View.aspx?title=GDIPlusX&referringTitle=Home

 

* Init GdiPlusX
DO LOCFILE("System.App")

WITH _SCREEN.System.Drawing

* Load source Image
LOCAL loBmp as xfcBitmap
loBmp = .
Bitmap.New(GETPICT())

* Get a rectangle with the bitmap dimensions
LOCAL loRect as xfcRectangle
loRect = loBmp.GetBounds()

* Initialize the graphics object to be able to draw in the Image
LOCAL loGfx AS xfcGraphics
loGfx = .Graphics.FromImage(loBmp)
loGfx.
Clear(.Color.White)

LOCAL lnReduceFactor as Integer
lnReduceFactor = 10 && The image will be reduced in 10 times

* Get the thumbnail with the desired size
LOCAL loDestBmp as xfcImage
loDestBmp = loBmp.GetThumbnailImage(loBmp.
Width / lnReduceFactor, loBmp.Height / lnReduceFactor)
 
* Draw the image, showing the intensity of the CYAN channel.
loGfx.DrawImage(loDestBmp, loRect)
loBmp.
Save("c:\blurred.jpg", .Imaging.ImageFormat.Jpeg)

RUN
/N Explorer.exe c:\Blurred.Jpg

ENDWITH
RETURN

 

 Original Image 

 

 Factor = 4 

Factor = 8

Factor = 8

Factor = 12

Factor = 20

 

 

Original Image

Factor = 4

Factor = 8

Factor = 12

Factor = 20
Published Friday, June 22, 2007 5:03 AM by cesarchalom
Filed Under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Cesar Chalom said:

Este articulo fue traducido a Espanol:

Imágenes con aspecto borroso (blur) con GdiPlusX

June 27, 2007 7:14 PM

What do you think?

(required) 
(optional)
(required)