Execute more then one command on ImageProcessingPreview

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

Moderator: Alex

Post Reply
SteveK
Posts: 2
Joined: Wed Nov 02, 2011 12:41 pm

Execute more then one command on ImageProcessingPreview

Post by SteveK » Wed Nov 02, 2011 1:50 pm

Hello VintaSoft Team,
my company plans to purchase Imaging.NET SDK. Therefore I was asked to test the evaluate version, by writing a small test program that would use the functions we need.

I looked at the ImagingDemo project, and want to create a ImageProcessing Dialog that handles brightness/contrast command as well as hue/saturation/luminance command.

When I perform both commands behind each other using the ExecuteInPlace function it works as expected.

Code: Select all

imageViewer1.Images.Add(filename);

Vintasoft.Imaging.ImageProcessing.Color.ChangeBrightnessContrastCommand command =
 new Vintasoft.Imaging.ImageProcessing.Color.ChangeBrightnessContrastCommand(50, 5);
command.ExecuteInPlace(imageViewer1.FocusedImage);

Vintasoft.Imaging.ImageProcessing.Color.ChangeHueSaturationLuminanceCommand command2 =
 new Vintasoft.Imaging.ImageProcessing.Color.ChangeHueSaturationLuminanceCommand(0, -100, 0);
command2.ExecuteInPlace(imageViewer1.FocusedImage);
When I anyhow try to do it with an ImageProcessingPreview object, I can only perform one of the two commands, the other gets lost or not executed. I'm not sure if I miss something or if the current version of the Assembly (4.3.33.1) even possible. The code I have currently looks like this, but the Brightness / Contrast command seems to be not executed:

Code: Select all

public ColorEditingDialog(VintasoftImage image,                                   Rectangle processingRectangle) : this()
{
ImageProcessingPreview imgPreview;
imgPreview = new ImageProcessingPreview(previewImageViewer, image, processingRectangle);

ProcessingCommandBase command1 = GetProcessingCommand1(50, 5);
if (command1 != null)
   imgPreview.ExecuteProcessing(command1);

ProcessingCommandBase command2 = GetProcessingCommand2(0, -100, 0);
if (command2 != null)
   imgPreview.ExecuteProcessing(command2);
}

protected virtual ProcessingCommandBase GetProcessingCommand1(Int32 b, Int32 c)
{
return new Vintasoft.Imaging.ImageProcessing.Color.ChangeBrightnessContrastCommand(b, c);
}

protected virtual ProcessingCommandBase GetProcessingCommand2(Int32 h, Int32 s, Int32 l)
{
return new Vintasoft.Imaging.ImageProcessing.Color.ChangeHueSaturationLuminanceCommand(h, s, l);
}
What I now like to know is, if I do something wrong or if its even possible to do this.

Best regards
Steve Kirchmer

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

Re: Execute more then one command on ImageProcessingPreview

Post by Alex » Mon Nov 07, 2011 2:00 pm

Hello Steve,

Sorry for a delay.

Please send us a project (to support@vintasoft.com) which demonstrates your problem - we need to reproduce the problem.

Best regards, Alexander

SteveK
Posts: 2
Joined: Wed Nov 02, 2011 12:41 pm

Re: Execute more then one command on ImageProcessingPreview

Post by SteveK » Mon Nov 21, 2011 11:44 am

Hello Alexander,

I excause me for my delay as well. I haven't been in the office for the past two weeks.
I packed my current work project in a Zip and sended it to the support address as you suggested.

Thanks for responding to me question.

Best Regards
Steve

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

Re: Execute more then one command on ImageProcessingPreview

Post by Alex » Tue Nov 22, 2011 4:29 pm

Hello Steve,

Your code has logical mistake.

Here is your code:

Code: Select all

public void ExecuteProcessing(ProcessingCommandBase command)
{
   if (!_enabled)
       return;

   // clone preview image
   // NEXT CODE LINE HAS LOGICAL MISTAKE
   using (VintasoftImage processedImage = new VintasoftImage(_thumbnail.GetAsBitmap(), false))
   {
      // process image in place
      command.ExecuteInPlace(processedImage);

      // preview processing image
      _imageViewer.Image.SetImage(processedImage);
   }
}
You store an original image in the _thumbnail object, you store processed image in the _imageViewer.Image object - these objects are different and images of these objects also are different.

You need to execute both processing commands at one moment.
Here is possible code:

Code: Select all

public void ExecuteProcessing(ProcessingCommandBase command1, ProcessingCommandBase command2)
{
   if (!_enabled)
      return;

   // clone preview image
   using (VintasoftImage processedImage = new VintasoftImage(_thumbnail.GetAsBitmap(), false))
   {
      // process image in place
      command1.ExecuteInPlace(processedImage);
      command2.ExecuteInPlace(processedImage);

      // preview processing image
      _imageViewer.Image.SetImage(processedImage);
   }
}
Best regards, Alexander

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest