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!

Format  BoldItalicizedUnderline Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailBrowse for an image to attach to your post Browse for a zip to attach to your post Insert CodeInsert QuoteInsert List


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

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);
     ImageEnView1.IEBitmap.Resample(ImageEnView1w.Width, ImageEnView1.Height, rfFastLinear, true, true);

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

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

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

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

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

Though have you considered just using Contrast?

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

See the demo:


Xequte Software