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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Best practice: AdjustBrightnessContrastSaturation

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AScomp Posted - Jan 06 2021 : 19:16:04
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
2   L A T E S T    R E P L I E S    (Newest First)
AScomp Posted - Jan 07 2021 : 08:24:10
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
xequte Posted - Jan 06 2021 : 23:30:35
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