Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Format32bppRgb is acutally Format32bppRgba on Gtk #1458

@nrother

Description

@nrother

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions