Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I save an image with GDIPlusX
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01301519
Message ID:
01301971
Vues:
17
Cesar,
I figured out the last problem but now I have a new one. I can't figure out how to get the resized image to show in the form.

I can bring in a file and display it in the imgCanvas container. I can then resize and save it. The only problem I have is that the resized image does not show on the form. The original stays in the imgCanvas. (on the form the name is Thisform.imgEdit)

Thanks for all your help so far. I am writing this program for users to edit images and then save them for upload to a web page. I need to load, resize, adjust colors, etc. and then save the changes.

The Procedures are in a container on the form that is created entirely in code. They are called from menu buttons on the form.

PROCEDURE lGetNewImage Gets the image, displays it on the form and saves an object reference created by ...Bitmap.FromFile(mImage)

PROCEDURE lResizeImage resizes the image. I put a save in it and the saved image is the new size.
*
* >>> THIS PROC WORKS 
PROCEDURE lGetNewImage
*
* Get a new picture Image
With Thisform
  *
  mImage = getpict()
  *
  * Draw the image into GdiPlusX
  * -----------------------------
  local loBmp as xfcBitmap
  local loGfx as xfcGraphics
  loGfx = Thisform.imgEdit.oGfx

  * Clear the image
  .imgEdit.Clear(rgb(255,255,255))

  loBmp = _Screen.System.Drawing.Bitmap.FromFile(mImage)
  *

  * >>> SAVE loBmp
  * Save pointer so we can use it for other things
  .oSrcImage = loBmp

  *
  * Now let's draw in the Canvas
  loGfx.DrawImage(loBmp,0,0, .OrgImageWidth, .OrgImageHeight)

  * Draw image to the image container.
  .imgEdit.Draw()
EndWith
*
* ------------------
*
* >>> THIS PROC WORKS BUT THE RESIZED IMAGE DOES NOT SHOW ON THE FORM.
PROCEDURE lResizeImage
*
lParameters lnWidth, lnHeight
*
* Resize the current image.
WITH _SCREEN.System.Drawing
  *
  * Load the original Image
  * LOCAL loSrcImage as xfcBitmap
  * loSrcImage = .Bitmap.New(GETPICT())

  * >>> GET THE OBJECT SAVED WHEN WE GOT THE FILE
  LOCAL loSrcImage as xfcBitmap
  loSrcImage = Thisform.oSrcImage  && Saved when we loaded the file

  * Create a New Image with the desired size
  LOCAL loResized as xfcBitmap
  loResized = .Bitmap.New(lnWidth, lnHeight, ;
  .Imaging.PixelFormat.Format32bppARGB)

  * Set the image resolution to be the same as the original
  loResized.SetResolution(loSrcImage.HorizontalResolution, ;
  loSrcImage.VerticalResolution)

  * Obtain a Graphics object to get the rights to draw on it
  LOCAL loGfx as xfcGraphics
  loGfx = .Graphics.FromImage(loResized)

  * Set some properties, to ensure to have a better quality of image
  loGfx.SmoothingMode = .Drawing2D.SmoothingMode.HighQuality
  loGfx.InterpolationMode = .Drawing2D.InterpolationMode.HighQualityBicubic

  * Draw the source image on the new image at the desired dimensions
  loGfx.DrawImage(loSrcImage, 0, 0, lnWIdth, lnHeight)


  * >>> THIS WORKS 
  * Save the resized image as Png
  loResized.Save("c:\Resized3.png", .Imaging.ImageFormat.Png)


  * >>> THIS DOES NOT WORK
  Thisform.imgEdit.Draw()
  Thisform.Refresh()

ENDWITH

Beer is proof that God loves man, and wants him to be happy. - Benjamin Franklin
John J. Henn
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform