ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Best practice: AdjustBrightnessContrastSaturation
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

AScomp

Germany
17 Posts

Posted - Jan 06 2021 :  19:16:04  Show Profile  Reply
Hi,

I've been experimenting with ImageEn for a few days now and I'm really impressed of its functionality!

Right now I'm implementing a trackbar to adjust the contrast and I'm not sure I'm applying it correctly. The trackbar should adjust the contrast of the loaded image in real-time, which works properly.

Info: In order to optimize the performance, I first resize the image to match the TImageEnView's dimensions.

Here is the source code:


procedure TForm1.FormCreate(Sender: TObject);
begin
     ImageEnView1.IO.LoadFromFile('C:\Temp\Test\20190911_160859.jpg');
     ImageEnView1.IEBitmap.Resample(ImageEnView1w.Width, ImageEnView1.Height, rfFastLinear, true, true);
end;

procedure TForm1.TrackBar1Changing(Sender: TObject; NewPos: Integer;
  var AllowChange: Boolean);
begin
     ImageEnView1.Proc.Undo();
     ImageEnView1.Proc.ClearUndo;
     ImageEnView1.Proc.ClearRedo;
     ImageEnView1.Proc.AdjustBrightnessContrastSaturation(0, NewPos, 0);
end;


Since I want to adjust the original image's contrast (not the contrast of changed image), I use Proc.Undo to "reset" the image and ClearRedo to keep the memory clean. Is there a better way than using Undo maybe?

Thanks in advance!

Kind regards

Andreas

xequte

38180 Posts

Posted - Jan 06 2021 :  23:30:35  Show Profile  Reply
Firstly, you can use ioJPEG_AUTOCALC to speed up loading if you will resize anyway.

https://www.imageen.com/help/TIOParams.JPEG_Scale.html

Other than that I can't see many ways to optimize it.


Though have you considered just using Contrast?

https://www.imageen.com/help/TIEBitmap.Contrast.html

Then you can apply the changes to the image using FixContrast.

See the demo:

\Demos\Display\DisplayAdjust\Display.dpr




Nigel
Xequte Software
www.imageen.com
Go to Top of Page

AScomp

Germany
17 Posts

Posted - Jan 07 2021 :  08:24:10  Show Profile  Reply
Hi Nigel,

thanks for getting back!

I will use brightness and saturation as well. And it works pretty fast with the code above, so everything is fine. Just wanted to make sure there is no better practice.

Kind regards

Andreas
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: