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



Image Info with GdiPlus X

Another very easy task for GDI+.

To obtain some basic image information, such as Width, Height, Resolution and PixelFormat, all we need is to Initialize a GDI+ Image object and get some property values, as shown below:

IMPORTANT:

All samples below use the new GDIPlus-X library, that is still in ALPHA version, but is already stable and reliable to do the majority of GDI+ tasks. Download the latest stable release from Codeplex:

http://www.codeplex.com/Wiki/View.aspx?ProjectName=VFPX&title=GDIPlusX

LOCAL lcImage
lcImage =
GETPICT()
IF EMPTY(lcImage)
   RETURN
ENDIF

DO LOCFILE("System.App")

LOCAL loImg AS xfcImage
WITH _SCREEN.System.Drawing
loImg = .
Image.FromFile(lcImage)
IF ISNULL(loImg)
   MESSAGEBOX("Could not load image file")
   RETURN
ENDIF

* Get PixelFormat name
LOCAL lnPix, lcPixFormat
lnPix = loImg.PixelFormat
DO CASE 
CASE
lnPix = .Imaging.PixelFormat.Format1bppIndexed
   lcPixFormat = "1bppIndexed"
CASE lnPix = .Imaging.PixelFormat.Format4bppIndexed
   lcPixFormat = "4bppIndexed"
CASE lnPix = .Imaging.PixelFormat.Format8bppIndexed
   lcPixFormat = "8bppIndexed"
CASE lnPix = .Imaging.PixelFormat.Format16bppGrayScale
   lcPixFormat = "16bppGrayScale"
CASE lnPix = .Imaging.PixelFormat.Format16bppRGB555
   lcPixFormat = "16bppRGB555"
CASE lnPix = .Imaging.PixelFormat.Format16bppRGB565
   lcPixFormat = "16bppRGB565"
CASE lnPix = .Imaging.PixelFormat.Format16bppARGB1555
   lcPixFormat = "16bppARGB1555"
CASE lnPix = .Imaging.PixelFormat.Format24bppRGB
   lcPixFormat = "24bppRGB"
CASE lnPix = .Imaging.PixelFormat.Format32bppRGB
   lcPixFormat = "32bppRGB"
CASE lnPix = .Imaging.PixelFormat.Format32bppARGB
   lcPixFormat = "32bppARGB"
CASE lnPix = .Imaging.PixelFormat.Format32bppPARGB
   lcPixFormat = "32bppPARGB"
CASE lnPix = .Imaging.PixelFormat.Format48bppRGB
   lcPixFormat = "48bppRGB"
CASE lnPix = .Imaging.PixelFormat.Format64bppPARGB
   lcPixFormat = "64bppPARGB"
OTHERWISE
   lcPixFormat = "Unidentified"
ENDCASE

ENDWITH
 
LOCAL
lcInfo
lcInfo = ;
   "Width : " +
TRANSFORM(loImg.Width) + SPACE(25) +;
   "Height : " +
TRANSFORM(loImg.Height) + CHR(13) +;
   "Resolution - Vertical : " +
TRANSFORM(loImg.VerticalResolution) +  SPACE(6) +;
   "Horizontal : " +
TRANSFORM(loImg.HorizontalResolution) + CHR(13) +;
   "PixelFormat : " + lcPixFormat

MESSAGEBOX(lcInfo, 64, "Image Properties for " + JUSTFNAME(lcImage))

Published Sunday, April 08, 2007 2:47 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

 

Franklin Garzón said:

Felicitaciones Cesar, muy bueno tu apoyo a la comunidad.

Saludos.

Gracias Franklin!

Esta es una hora en que debemos nos unir y crear nuevas opciones, y muestrar que con VFP todo se puede hacer. Para eso, solo se necesita un poco de creatividad !

Saludos

Cesar

April 8, 2007 5:48 PM
 

Cesar Chalom said:

Franklin,
Mas un dato interesante:
UD paso hace un mes un link para la clase de objectos degradados en FoxEcuador. Hubieron mas de 100 acesos a este articulo desde FoxEcuador ! Esto fue la origen que mas acesos tuve !
April 8, 2007 9:34 PM
 

Ana María Bisbé said:

Versión en Español de este artículo en / Spanish version at  http://www.portalfox.com/article.php?sid=2405
July 24, 2007 7:30 PM

What do you think?

(required) 
(optional)
(required) 

This Blog

Post Calendar

<April 2007>
SuMoTuWeThFrSa
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

Syndication