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
|
|
|
|
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
|
1 user thanked Andrey Semenov for this useful post.
|
|
|
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.