Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gamma or brightness appears wrong after encoding. #11

Open
HSGorman opened this issue Jul 19, 2016 · 5 comments
Open

Gamma or brightness appears wrong after encoding. #11

HSGorman opened this issue Jul 19, 2016 · 5 comments
Labels

Comments

@HSGorman
Copy link

Using the following code to convert a jpg to a jp2. When I read the jp2 the image appears too light (brightness or gamma appear to be off). Any ideas?

BitmapImageCreator.Register();
using (var bitmap = (Bitmap)Image.FromFile(@"C:\temp\jp2\llb.jpg"))
{
var enc = J2kImage.ToBytes(bitmap);
File.WriteAllBytes(@"C:\temp\jp2\llb.jp2", enc);
}

@anders9ustafsson
Copy link
Contributor

@HSGorman Many thanks for reporting! Could you please include a sample image with this problem?

@anders9ustafsson
Copy link
Contributor

anders9ustafsson commented Mar 17, 2017

@HSGorman Could be related to the failure to properly display the logo (file14) in codectest. But it would be good to have the sample as well.

@tomerinb
Copy link

same here.
got a very bright an contrasted image after converting to jp2.
is there a fix?
i attached the sample (original file and converted one)

here is the code i used:
System.Drawing.Image image = System.Drawing.Bitmap.FromFile("c:\img.jpg");
byte[] j2kArray = CSJ2K.J2kImage.ToBytes(image);
File.WriteAllBytes("c:\newImage.jp2", j2kArray);

Images.zip

@MikeRosoft
Copy link

Happened to me as well. Code:

        public static byte[] Encode(byte[] image, decimal? quality)
        {
            using var bytes = new MemoryStream(image);
            using var bitmap = new Bitmap(bytes);

            var parameters = J2kImage.GetDefaultEncoderParameterList(null);
            if (!quality.HasValue)
                parameters["lossless"] = "on";
            else
                parameters["rate"] = quality.ToString();

            return J2kImage.ToBytes(bitmap, parameters);
        }

Original image is PNG, resulting image is way too bright (as shown by IrfanView with the most recent plugins). Tested with package version 3.0, on Windows 10.

@MikeRosoft
Copy link

Follow-up: I wasn't able to upload the file, so here is a share link: https://app.box.com/s/t7pi1u8klidvwgzvixgnfwdj163ciosx (file name: testImages.zip).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants