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

Fix parsing of bitmap resources #156

Merged
merged 3 commits into from
Aug 2, 2022
Merged

Fix parsing of bitmap resources #156

merged 3 commits into from
Aug 2, 2022

Conversation

TerryFogg
Copy link
Contributor

@TerryFogg TerryFogg commented Aug 1, 2022

Description

Bitmap as embedded resources were not working.
Note:
Mono.Cecil reader returns resources as strings, and System.Byte[ ].
System.Drawing.Bitmap is read by Mono.Cecil as a System.Byte[ ].
A try to convert the System.Byte[ ] is the only way to detect bitmaps.

Motivation and Context

Embedding resources has been an issue.
The work around was to embed byte arrays of images and use as a binary resource.
This fix allows embedding resources of jpeg,gif,and many bitmap types.

How Has This Been Tested

Created a C# example that displays the bitmaps.
Paint.net was used to import a 32 bit colour image and save in various qualities.
JPEG - 2K bytes.
JPEG - 9K bytes.
JPEF - 12KB bytes ( best for this image size)
GIF - 9KB, dither =8.
GIF - 9KB, dither = 0.
NOTE: Bitmaps are read and then re-written as a16 bit rgb565 format resulting in a 16,520 byte size for all of these examples.
Bitmap - (1Bit) 2KBytes - stored in Flash as 16,520 (Increase)
Bitmap - (4Bit) 5KBytes - stored in Flash as 16,520 (Increase)
Bitmap - (8Bit) 10KBytes - stored in Flash as 16,520 (Increase)
Bitmap - (24it) 24KBytes - stored in Flash as 16,520 (decrease)
Bitmap - (32Bit) 33KBytes - stored in Flash as 16,520 (decrease)

Screenshots

IMG_9001

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Unit Tests (add new Unit Test(s) or improved existing one(s), has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist:

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).
  • I have added new tests to cover my changes.

@nfbot
Copy link
Member

nfbot commented Aug 1, 2022

@TerryFogg I've fixed the checklist for you.
FYI, the correct format is [x], no spaces inside brackets.

@nfbot nfbot added Type: bug Something isn't working Type: enhancement New feature or request labels Aug 1, 2022
@dnfadmin
Copy link

dnfadmin commented Aug 1, 2022

CLA assistant check
All CLA requirements met.

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work with these! Thanks for the important fix.
Just some comments and it should be good to merge

@josesimoes josesimoes changed the title Changes to fix error with bitmaps ( Must be used in conjunction with visual studio extension fix) Changes to fix error with bitmaps Aug 1, 2022
Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@josesimoes josesimoes changed the title Changes to fix error with bitmaps Fix parsing of bitmap resources Aug 2, 2022
@josesimoes josesimoes merged commit 707f248 into nanoframework:develop Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Update Dependents Type: bug Something isn't working Type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants