-
-
Notifications
You must be signed in to change notification settings - Fork 181
Use only 32-bit ARGB or RGB565 formats #2822
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
Use only 32-bit ARGB or RGB565 formats #2822
Conversation
Previous use of BGR format has been eliminated. Transparency has been changed to not use an invaild colour as a test of transparency, as it was just by chance that BGR format caused it to work previously.
Automated fixes for code style.
…2e8-e84f-4ee2-9786-58cf4ef8a15a Code style fixes for nanoframework/nf-interpreter PR#2822
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TerryFogg LGTM! As usual, very detailed PR comment with a detailed explanation.
Thank you for your very professional work. 💯 😃
Let me ask @Ellerbach to have another pair of eyes on this because he's very familiar with this code. 😉 |
I need to look at the samples. The basic primitives works as expected, but I see there is another for managed drivers that converts the new System.Drawing colors to BGR before using, as I would expect as the original nanoFramework colors I loaded were already converted to BGR. |
@CoryCharlton care to take a look at this please? Possible impact on nanoframework/nanoFramework.Graphics#133. |
These changes don't change the native calls, so, it should not be an issue unless there is use of BGR color formats being used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks ok all up. I'm sure Terry tested it. And if it works with the primitives properly and the bitmap, it works for everything. Thanks!
I don't see any conflicts with my PR. |
Description
The code has been modified to only use ARGB or RGR565 format.
Code was also modified to the RotateImage method to properly rotate images with a transparent background.
This was not in place, although it was already in place for stretch image.
Motivation and Context
Problems with colours. This eliminates some confusion with the formats in memory.
How Has This Been Tested?
The modifed code was tested on
STM32769I_Discovery board
ESP32 Wrover Kit v4.1
ESP32 Wrover Kit 4.1 with Generic SPI class and C# class of ili9341 from the Managed Drivers.
All three tests showed the same resulting colours.
See the following testing notes below
Testing notes
A selection of 9 ARGB colours were selected to test operation
During native debugging, examination of the memory buffer of the Bitmap showed that it was correctly in the RGB565 format stored as little endian.
Many references to native color format are in the code and this native format is the RGB565 format.
There are assumptions in the code that a pixel is 2 bytes, this can be seen in the image manipulation routines which operate on memory copy of bytes assuming 16-bit pixels.
JPEG test was created using Paint.net to set 9 pixels to the ARGB colours then saved to disk and re-read. The values re-read from the disk are "compressed" so are slightly different. The expected values were found using the eye-dropper tool of paint.net to get the hex colour values.
Bitmaps saved in the resource file are all converted to RGB565 format before being embedded into the assembly and deployed to flash. (This is by design)
The graphics code supports reading in bitmaps of 32-bit, 24-bit and 8-bit indexed, usually from file. For this test the bitmaps are included as a C# byte arrays to eliminate the need to have a file system.
Restoring RGB565 to ARGB
Restored results are inexact values due to the loss of 3 bits red, 2 bits green and 3 bits blue. The restoration code uses an algorithm originally from .NetMF to approximate the original ARGB colour.
Gif values should be the same as SetPixel, GetPixel, unlike Jpeg GIF uses lossless compression.
Screenshots
Types of changes
Checklist
Checklist