Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GPIplus
Message
From
03/08/2007 12:32:54
 
 
To
03/08/2007 11:50:14
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01245840
Message ID:
01245849
Views:
26
>I have a project where I need to manage and display/print scanned images.
>The scanner is a Savin8855 network printer/scanner/fax etc.
>It creates multipage tiffs in a designated folder.
>I have a routine which grabs those tiff and moves them into a folder under my apps control.
>now i used to convert them to individual jpgs to show them in a browser control (My browse does not display tiffs!!)
>
>Now I think I want my app to do one better.
>With Cesar Chaloms help/white papers I managed to grab the frams and show them in an image control on my form.
>Great.
>In order to do so I again save the frame as a jpg in a temp folder to hook to the image control. This I would prefer to be don in memory without a intermediate file. Possible?
>also once displayed a letter sized picture on a vfp form 600*800 is rather small! I there a way to zoom in/out?
>
>I really appreciat Cesar work on GDI+!
>
>Thanks
>
>Peter

Hi Peter,

Thanks for the kind words and the positive feedback.

You can show pictures using the Image control's pictureVal property.

In the last release of GdiPlusX we've added two possibilities for this, using the new "GetPictureVal" and "GetPictureVal" functions of the Image / Bitmap classes.

You can use it this way:

In this sample, I'll use a phisic image file to load the image just for you to understand how it works. For your case, you can start from your Image/Bitmap object.
It also uses the encoder for saving JPEGS with quality of 25% (that means low).

The code has many comments, and it's very easy to maintain.
* Using GetPictureVal and Quality encoder
 
_SCREEN.AddProperty("System", NEWOBJECT("xfcSystem", LOCFILE("system.vcx"))) 

WITH _SCREEN.System.Drawing

LOCAL lnJpegQuality
lnJpegQuality = 25

LOCAL loBmp as xfcBitmap
LOCAL loEncoderParameter AS xfcEncoderParameter
LOCAL loEncoderParameters AS xfcEncoderParameters
LOCAL loImgFormat as xfcImageFormat

loImgFormat = .Imaging.ImageFormat.Jpeg

&& Create an EncoderParameters object.
&& An EncoderParameters object has an array of EncoderParameter objects
&& In this case, there is only one EncoderParameter object in the array.
loEncoderParameters = .Imaging.EncoderParameters.New(1)

&& Save the bitmap as a JPEG file with quality level "lnJpegQuality".
&& Using an Encoder object based on the GUID
&& for the Quality parameter category.
loEncoderParameter = .Imaging.EncoderParameter.New(.Imaging.Encoder.Quality, lnJpegQuality)
loEncoderParameters.Param[1] = loEncoderParameter

loBmp = .Bitmap.FromFile(GETPICT())
lcPictVal = loBmp.GetPictureVal(loImgFormat, loEncoderParameters)
lnSize = LEN(lcPictVal)
 
MESSAGEBOX("Image size: " + transform(lnSize) + " bytes")

* Here you send the PictureVal to the Image object of your form
Thisform.Image1.PictureVal = lcPictVal

ENDWITH
This 2nd sample is simpler, and uses another function, GETPICTUREVALFROMHBITMAP, that does not need any parameter, and returns the pictureval for BMPs, that are bigger than JPGs from the prior sample.
*Sample 2:
* Using GetPictureValfromHBitmap
 
_SCREEN.AddProperty("System", NEWOBJECT("xfcSystem", LOCFILE("system.vcx"))) 

WITH _SCREEN.System.Drawing

LOCAL loBmp as xfcBitmap
loBmp = .Bitmap.FromFile(GETPICT())

lcPictVal = loBmp.GetPictureValfromHBitmap()

* Here you send the PictureVal to the Image object of your form
Thisform.Image1.PictureVal = lcPictVal

ENDWITH
Hope this helps you to get started

Cesar
Previous
Reply
Map
View

Click here to load this message in the networking platform