This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Notification

Icon
Error

Options
Go to last post Go to first unread
lauren@photoboothsupplyco.com  
#1 Posted : Saturday, October 28, 2017 2:27:03 PM(UTC)
lauren@photoboothsupplyco.com

Rank: Member

Groups: Guest
Joined: 7/30/2017(UTC)
Posts: 18

Thanks: 7 times
I'm trying to apply a brightness and contrast to an image and I'm not sure if I'm doing it right.

I already have an image loaded in a bitmap and from the sample code I saw where I have to create a new Brightness and Contrast object and then apply the values based on those objects. Here is my code:

Code:


    resizedBmp.Transforms.Resize(new Size(width, height), ResizeInterpolationMode.Medium, ResizeMode.ImageFill);

    using (var brightness = new Brightness())
    using (var contrast = new Contrast())
    {
        brightness.Auto = false;
        brightness.Amount = 0.3f;

        contrast.Auto = false;
        contrast.Amount = 0.15f;

        using (var brightnessBitmap = brightness.Apply(resizedBmp))
        {
            Aurigma.GraphicsMill.Bitmap finalBitmap = contrast.Apply(brightnessBitmap);

            var jpegSettings = new Aurigma.GraphicsMill.Codecs.JpegSettings();
            jpegSettings.Quality = 90;
            jpegSettings.UseSubsampling = false;
            jpegSettings.IsProgressive = true;

            finalBitmap.Save(filename, jpegSettings);

            finalBitmap.Dispose();
        }
    }

The issue I'm seeing is if I put in values of 0 for both Brightness and Contrast the image is looking washed out versus if I don't apply them at all.

Edited by moderator Sunday, October 29, 2017 9:26:37 PM(UTC)  | Reason: Not specified

Andrey Semenov  
#2 Posted : Sunday, October 29, 2017 9:25:43 PM(UTC)
Andrey Semenov

Rank: Advanced Member

Groups: Guest
Joined: 7/4/2017(UTC)
Posts: 43

Was thanked: 12 time(s) in 12 post(s)
Hi,

I believe the reason why output images are looking washing out is ResizeInterpolationMode.Medium. Please try Lanczos3 and compare results. I've testes this with 0 for Brightness and Contrast, and it works as expected.

Also, you can use shorter code to apply brightness and contrast, like below:

Code:
resizedBmp.Transforms.Resize(new Size(width, height), ResizeInterpolationMode.Lanczos3, ResizeMode.ImageFill);
resizedBmp.ColorAdjustment.Brightness(0.3f);
resizedBmp.ColorAdjustment.Contrast(0.15f);
...

Regards,

Andrew

thanks 1 user thanked Andrey Semenov for this useful post.
lauren@photoboothsupplyco.com on 10/30/2017(UTC)
Users browsing this topic
Guest
Similar Topics
Example in VB.Net Brightness and contrast on TrackBar1_Scroll with MultiLayerViewer1 (Discussions – Graphics Mill)
by maurib80@gmail.com 5/7/2010 7:35:25 PM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.