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

Support for additional PixelFormats in RawImage.ToImage #25

Open
camalot opened this issue May 19, 2016 · 0 comments
Open

Support for additional PixelFormats in RawImage.ToImage #25

camalot opened this issue May 19, 2016 · 0 comments
Labels

Comments

@camalot
Copy link
Owner

camalot commented May 19, 2016

Original Bug on CodePlex

In RawImage.ToImage (RawImage.cs:257), two pixel formats are hard coded. If the screen buffer is 32-bit, ARGB is always assumed; if the screen buffer is 16-bit, RGB565 is always assumed.

The Microsoft Visual Studio Android emulator uses a RGB format, so the colors are off.

The following code reads the ARGB offsets and determines the pixel format based on these values:

if(this.Bpp == 32) {
    if(this.Alpha.Offset == 0 && this.Red.Offset == 8 && this.Green.Offset == 16 && this.Blue.Offset == 24) {
        format = PixelFormat.Format32bppArgb;
    } else if(this.Red.Offset == 0 && this.Green.Offset == 8 && this.Blue.Offset == 16 && this.Alpha.Offset == 24) {
        format = PixelFormat.Format32bppRgb;
    }
} else if(this.Bpp == 16) {
    if (this.Red.Offset == 0 && Green.Offset == 5 && Red.Offset == 11) {
        format = PixelFormat.Format16bppRgb565;
    } else if(this.Red.Offset == 0 && Green.Offset == 5 && Red.Offset == 10) {
        format = PixelFormat.Format16bppRgb555;
    }
}

return ToImage ( format );
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

1 participant