Page 2 of 2
Re: Load, change and save image to the same file in Image Viewer
Posted: Tue Sep 01, 2015 6:48 pm
by Alex
Hello Daniel,
i'm running into the same problem, using the image collection of an ImageViewer-control:
...
Could you send us a small working project which demonstrates your problem? If yes, please send your project to
support@vintasoft.com.
Best regards, Alexander
Re: Load, change and save image to the same file in Image Viewer
Posted: Wed Sep 02, 2015 10:00 am
by DanielLW
Hello Alex,
i've recognized that the problem occurs only, if there is a thumbnailviewer attached to the ImageViewer (property "MasterViewer").
You can easily reproduce it by creating a form with an ImageViewer and ThumbnailViewer-control added to it, and then executing my code.
I've tried to de-attach the thumbnailviewer before saving, setting the "MasterViewer"-property to NULL, but this does not help. It seems if the image-collection has been changed once, the ThumbnailViewer holds some reference to it. I've also tried to call "ClearAndDisposeItems" on the image-collection of the ThumbnailViewer, but no success either.
Is there any other way to completely disconnect the ThumbnailViewer from the ImageViewer temporary?
Best regards,
Daniel
Re: Load, change and save image to the same file in Image Viewer
Posted: Fri Sep 04, 2015 11:39 am
by Yuri
Hello Daniel,
Your code looks correct, however the simultaneous image decoding (asynchronously in viewer) with encoding of the same image causes a mutual locking.
It isn't a good practice because, theoretically, there might take place any changes in image collection: removing images, insert etc. and this may cause a failure in decoding.
What is your task?
You can at first rotate the image, save changes and then open the file in viewer:
Code: Select all
ImageCollection images = new ImageCollection();
images.Add(@"c:\test\test.tif", false);
images[0].Rotate(90);
Vintasoft.Imaging.Codecs.Encoders.TiffEncoder teTest =
new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder();
teTest.SaveAndSwitchSource = true;
images.SaveSync(@"c:\test\test.tif", teTest);
this.imageViewer1.Images.AddRange(images.ToArray());
Or another way is to copy the file into memory:
Code: Select all
Vintasoft.Imaging.Codecs.Encoders.TiffEncoder teTest;
MemoryStream ms = new MemoryStream(File.ReadAllBytes(@"c:\test\test.tif"));
this.imageViewer1.Images.Add(ms, true);
this.imageViewer1.Images[0].Rotate(90);
teTest = new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder();
teTest.SaveAndSwitchSource = true;
this.imageViewer1.Images.SaveSync(@"c:\test\test.tif", teTest);
--
Kind regards, Yuri
Re: Load, change and save image to the same file in Image Viewer
Posted: Fri Sep 04, 2015 3:32 pm
by DanielLW
Hello Yuri,
thank you for your answer and code suggestions. I will have a look into it.
Yuri wrote:
What is your task?
Simple, build a picture viewer with thumbnail-view, where the user can rotate the currently viewed page and save it back to the file.
Re: Load, change and save image to the same file in Image Viewer
Posted: Fri Sep 04, 2015 6:02 pm
by Yuri
Hello Daniel,
Why can't you modify and use our Imaging Demo? It does what you need.
--
Regards, Yuri