VintaSoft Imaging .NET SDK and Plug-ins Discussions

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

Board index < VintaSoft Imaging < VintaSoft Imaging .NET SDK and Plug-ins Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

Load, change and save image to the same file in Image Viewer



Re: Load, change and save image to the same file in Image Viewer

Post 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

Post 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

Post 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:
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:
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

Post by DanielLW »

Hello Yuri,

thank you for your answer and code suggestions. I will have a look into it. 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

Post by Yuri »

Hello Daniel,

Why can't you modify and use our Imaging Demo? It does what you need.

--
Regards, Yuri


Page 2 from 2: 1 2