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

Eto.Bitmap.Lock problem with macOS Big Sur #1824

Closed
TomQv opened this issue Nov 19, 2020 · 6 comments · Fixed by #1835 or #1859
Closed

Eto.Bitmap.Lock problem with macOS Big Sur #1824

TomQv opened this issue Nov 19, 2020 · 6 comments · Fixed by #1835 or #1859
Labels
Milestone

Comments

@TomQv
Copy link

TomQv commented Nov 19, 2020

Hi Curtis,

I'm not sure if this is already fixed, since I'm on a quiet old level of your sources.
With new macOS Big Sur the following bitmap.Lock returns null for pixels:

Eto.Drawing.Bitmap bitmap = somebitmap();
using (var pixels = bitmap.Lock())
{
}

Any ideas?

@cwensley
Copy link
Member

Hm, I'm not seeing the issue on the latest code. What is somebitmap()? Are you loading an existing image or creating a new Bitmap object?

I am noticing that the BitmapData.BytesPerPixel is reporting '8' for some images on Big Sur, probably due to supporting HDR so that will probably need fixing.

@TomQv
Copy link
Author

TomQv commented Nov 19, 2020

I did some more investigation. As said, I'm for some reason on an old version of Eto.
Testing with the current version of Eto this is fixed, the problem was in BitmapHandler.EnsureRep().
So bitmap.lock is working.

But now there is another problem, because bitmap.lock() returns a 64-bit bitmap. This is coming from BitmapHandler.EnsureRep().
So yes, maybe related to some new HD features on Retina display?

@TomQv
Copy link
Author

TomQv commented Nov 20, 2020

Ok, it seems that the problem is in BitmapHandler.EnsureRep()
rep as NSBitmapImageRep always gives null and then bmprep = new NSBitmapImageRep(new CGRect(CGPoint.Empty, Control.Size)); returns a 64bit bitmap.
I found the following workaround. just calling bmprep = new NSBitmapImageRep(rep.CGImage); instead. This returns the rep in the same pixelmode like the original. Don't know, if its the right way, but it seems to work for me.

@TomQv
Copy link
Author

TomQv commented Nov 20, 2020

Again, all this only with Big Sur, testing on a iMac retina 5K 27inch late 2015.

@TomQv
Copy link
Author

TomQv commented Dec 27, 2020

Thanks for the fix, but still one small bug in BitmapHandler.cs, line 352, should be:
bmprep = new NSBitmapImageRep(IntPtr.Zero, size.Width, size.Height, bitsPerComponent, numComponents, rep.HasAlpha, false, rep.ColorSpaceName, bytesPerRow, bitsPerPixel);

@cwensley
Copy link
Member

@TomQv thanks for the feedback! I've added that fix in.

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