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

Different bitmap output based on makeCopy parameter in ToBitmap method #210

Open
ankitbko opened this issue Dec 9, 2021 · 2 comments
Open

Comments

@ankitbko
Copy link
Member

ankitbko commented Dec 9, 2021

public override async void Receive(Message<Shared<Image>> message)
{
    var bmp = message.Data.Resource.ToBitmap(false);
    bmp.Save("img.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

    // ...... removed for brevity
}

When var bmp = message.Data.Resource.ToBitmap(false); I get this image
image

When I change the Boolean using var bmp = message.Data.Resource.ToBitmap(true); I get this image.
image

Not sure if this is a bug or not.

@sandrist
Copy link
Contributor

Hmm, I wasn't able to replicate this behavior with a simple test. I saved your second image as "C:\Temp\test-image.png", loaded it as a \psi Image, and called ToBitmap in both ways.

var image = Image.FromBitmap(new Bitmap(@"C:\Temp\test-image.png"));
image.ToBitmap(false).Save(@"C:\Temp\test-image-false.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
image.ToBitmap(true).Save(@"C:\Temp\test-image-true.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

but both resulting images look fine...

There still might be a bug in ToBitmap if something is screwed up with stride or pixel format, but I think I would have to see more of your code showing how the Shared<Image> stream gets created that is being passed to your Receive method.

@ankitbko
Copy link
Member Author

After troubleshooting together, we found out that the incorrect behavior happens in linux only and not in windows (mac is untested). The sample code that @sandrist wrote leads to reproducible behavior in linux machine.

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

No branches or pull requests

2 participants