Reading Image from Open File Dialog

May 9, 2010 at 11:36 PM
Edited May 10, 2010 at 5:16 PM

Hello,

I am trying to Crop an image that i read from Open File Dialog and set it as a source for ImageTools.image object, i use this code 

OpenFileDialog openImage = new OpenFileDialog();

openImage.Filter = "JPEG Files (*.jpg;*.jpeg)|*.jpg;*.jpeg | All Files (*.*)|*.*;

openImage.ShowDialog();

Stream stream = openImage.File.OpenRead();

ImageTools.Image img = new ImageTools.Image();

img.SetSource(stream); 

ImageTools.Image image_result = new ImageTools.Image();

ImageTools.Rectangle rectangle = new ImageTools.Rectangle();

rectangle.X = 0;

rectangle.Y = 0;

rectangle.Width = 10;

rectangle.Height = 10;

image_result= ImageTools.Image.Crop(image_source, rectangle);

it crashes telling me Image has not been loaded, Note : the image size is 0x0....

Thnx in advance :)

Coordinator
May 10, 2010 at 1:51 AM
First, I would be perfect to format the text a little bit, it is very
hard to read it.

Back to topic: ImageTools works asynchronously, that means, that the
image is loaded in a seperate thread. You can use the Loaded event when
you want to be notified when the image is loaded or you can set the
IsLoadingSynchronously flag to true, which is not recommended and marked
as obsolete.
May 10, 2010 at 5:19 PM

First,Thnx 4 ur reply...and sry for this bas formatting .

Second,i will try what u have said.