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

Format32bppRgb is acutally Format32bppRgba on Gtk #1458

Closed
nrother opened this issue Aug 1, 2019 · 4 comments · Fixed by #1698
Closed

Format32bppRgb is acutally Format32bppRgba on Gtk #1458

nrother opened this issue Aug 1, 2019 · 4 comments · Fixed by #1698
Milestone

Comments

@nrother
Copy link

nrother commented Aug 1, 2019

Expected Behavior

A Bitmap created with PixelFormat.Format32bppRgb and filled with 0x00FFFFFF should be all-white.

Actual Behavior

The Bitmap is completely transparent when shown in an ImageView on Gtk3. The documentation states 32-bits (4 bytes) per pixel, ordered by an Empty byte in the highest order, followed by Red, Green, and Blue., but actually the highest order byte is the alpha byte and not ignored.

Steps to Reproduce the Problem

see code

Code that Demonstrates the Problem

int[] pixelData = values.AsParallel().Select(x => {
    return (int)0x00FFFFFF; //broken
    //unchecked { return (int)0xFFFFFFFF; } //works
}).ToArray();

//create bitmap
var bitmap = new Bitmap(samplesPerLine, lines, PixelFormat.Format32bppRgb);

//copy data
using(var bitmapData = bitmap.Lock()) {
    IntPtr ptr = bitmapData.Data;
    GCHandle pixelHandle = GCHandle.Alloc(pixelData, GCHandleType.Pinned);
    for (int line = 0; line < lines; line++)
    {
        Marshal.Copy(pixelData, line * samplesPerLine, ptr, samplesPerLine);
        ptr += bitmapData.ScanWidth;
    }
}

Specifications

  • Version: 2.4.1
  • Platform(s): Gtk3
  • Operating System(s): Ubuntu 18.04
@cwensley
Copy link
Member

Hey @nrother, thanks for reporting the issue. Have you tried Eto 2.5?

@cwensley cwensley added this to the 2.x milestone Nov 21, 2019
@nrother
Copy link
Author

nrother commented Dec 16, 2019

Yes, this is the same in 2.5.0-rc.4

@cwensley
Copy link
Member

Thanks for checking, @nrother.

@cwensley cwensley modified the milestones: 2.x, 2.5.2 Mar 3, 2020
cwensley added a commit to cwensley/Eto that referenced this issue May 27, 2020
@cwensley
Copy link
Member

Fix is incoming. Note that Gtk/Cairo doesn't actually support 32bpp while ignoring alpha, so Eto now updates the alpha when necessary so that it shows it correctly. Using PixelFormats.Format32bppRgba is currently the most optimal format to use on all platforms.

@cwensley cwensley modified the milestones: 2.5.x, 2.5.2 May 28, 2020
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

Successfully merging a pull request may close this issue.

2 participants