Exception in Rotate Image

Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.

Moderator: Alex

Post Reply
ruserNET
Posts: 2
Joined: Tue Apr 14, 2009 4:12 am

Exception in Rotate Image

Post by ruserNET » Tue May 19, 2009 11:35 pm

Alex,
I am trying to rotate an image by using the example in ImageViewer Demo Application. Here is a link to the demo application with my changes. This one throws the exception.

http://www.box.net/shared/sa7g3dpv29

My image is loaded in ImageViewer control and I call Rotate(90) on the FocusedImage, just as in ImageViewer Demo.

The only difference between my code and ImageViewer Demo is in
Line 77 of ImageViewerDemo.cs
In Demo it is
imageViewer1.Images.Add(openFileDialog1.FileName);

In demo the Image is loaded by File Path and
I need to load the image using Stream. So the line 77 looks like this
using (FileStream fs = File.Open(openFileDialog1.FileName, FileMode.Open))
{
imageViewer1.Images.Add(fs);
fs.Close();
}

It loads the image fine but when I right click and rotate it, throws this exception.
The exception is 'Rotate: Image is too big and cannot be processed."
The reason I need to load the image as a stream is because I do not want to lock the file. And the same image could be used/or be in use by other application.
Could you please let me know if there is a workaround for this or a fix can be provided for this.
Thanks,
Satrsi

Alex
Site Admin
Posts: 1443
Joined: Thu Jul 10, 2008 2:21 pm

Re: Exception in Rotate Image

Post by Alex » Wed May 20, 2009 10:43 am

Hi Satrsi,

The exception "Image is too big and cannot be processed" in the VintasoftImage.Rotate(90) method means that Bitmap object had thrown an ExternalException exception in the Bitmap.Rotate(FlipRotateFlipType.Rotate90FlipNone) method.

What is the size of your image? We will create a custom rotation algorithm for big images in next version of library.

Best regards, Alexander

ruserNET
Posts: 2
Joined: Tue Apr 14, 2009 4:12 am

Re: Exception in Rotate Image

Post by ruserNET » Wed May 20, 2009 5:12 pm

Alex,
ImageViewer is very good in handling Tiff files. I have not had any problems in any of the image file. I think the main problem is with loading the image as a stream.

The images I am trying are small 25 KB and 85KB. Here are the links to them
Image 1
http://www.box.net/shared/55dqcagke5
Image 2
http://www.box.net/shared/zqsc6aa05b

and the link to demo where I load the image as stream(this is same as the last post). This one says 'Image too big'
Project that throws Image too big to rotate on the above Images
http://www.box.net/shared/sa7g3dpv29


I tried couple of different ways to load image
- by opening FileStream and copying it to MemoryStream and then calling ImageViewer.Images.Add(stream)
- by not closing the FileStream also.
But both of them eventually fail. It loads the image fine, and when rotating it says 'unsupported format'. Here is the link to the project which tries to
rotate the image after opening image in a stream.
Project that throws unsupported image on the above Images, after opening them successfully
http://www.box.net/shared/la1kk48ivh

Could you please try these samples and let me know if I am doing something wrong in loading the Image as a stream or (byte[])?

Thanks,
Satrsi

Alex
Site Admin
Posts: 1443
Joined: Thu Jul 10, 2008 2:21 pm

Re: Exception in Rotate Image

Post by Alex » Thu May 28, 2009 9:42 am

Hi Satrsi,

About your project that throws Image too big to rotate on the above Images:
You must keep the stream open for the lifetime of the VintasoftImage object.
Here is your code:

Code: Select all

using (FileStream fs = File.Open(openFileDialog1.FileName, FileMode.Open))
{
    imageViewer1.Images.Add(fs);
    fs.Close();
}
and here is correct code:

Code: Select all

FileStream fs = File.Open(openFileDialog1.FileName, FileMode.Open);
imageViewer1.Images.Add(fs);
also you can use this code:

Code: Select all

byte[] buf = File.ReadAllBytes(openFileDialog1.FileName);
imageViewer1.Images.Add(new MemoryStream(buf));
Project that throws unsupported image on the above Images, after opening them successfully:
I cannot reproduce the problem - all is working fine. Please send me step-by-step instruction how to reproduce the problem.

Best regards, Alexander

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest