-
Notifications
You must be signed in to change notification settings - Fork 32
Fix BMP palette loading #386
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
Merged
kaixiong
merged 5 commits into
add-palette-iteration-comparison-api
from
fix-bmp-palette-loading
Jan 25, 2025
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3132dfb
Core (LV::Video): Fix BMP loader not returning error despite not supp…
kaixiong 17dcf87
Core (LV::Video): Fix BMP loader not loading palette from the correct…
kaixiong 0b41ed7
Core (LV::Video): Check palettes are equal in has_same_content().
kaixiong 54a9d7e
Core (LV::Video): Add BI_BITFIELDS #define in BMP loader for clarity.
kaixiong 175e9b2
Core (LV::Video): Additional comments in BMP loader on color table re…
kaixiong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,6 +286,8 @@ namespace LV { | |
| fp.read (reinterpret_cast<char*> (&bf_bits), 4); | ||
| bf_bits = VISUAL_ENDIAN_LEI32 (bf_bits); | ||
|
|
||
| auto dib_header_pos = fp.tellg (); | ||
|
|
||
| /* Read the info structure size */ | ||
| fp.read (reinterpret_cast<char*> (&bi_size), 4); | ||
| bi_size = VISUAL_ENDIAN_LEI32 (bi_size); | ||
|
|
@@ -341,12 +343,14 @@ namespace LV { | |
| return nullptr; | ||
| } | ||
|
|
||
| if (bi_compression > 3) { | ||
| if (bi_compression >= 3) { | ||
| visual_log (VISUAL_LOG_ERROR, "Bitmap uses an invalid or unsupported compression scheme"); | ||
| fp.seekg (saved_stream_pos); | ||
| return nullptr; | ||
| } | ||
|
|
||
| fp.seekg (dib_header_pos + std::streampos {bi_size}, std::ios::beg); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add comments (or make otherwise more obvious) that…
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea, let me make that change. |
||
|
|
||
| /* Load the palette */ | ||
| if (bi_bitcount < 24) { | ||
| if (bi_clrused == 0) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm not a big fan of approach "undocumented unnamed magic number". This seems to be 3 because
BI_BITFIELDS == 3in Windows. If we cannot use that constant without including Windows headers, let's either (a) add a good comment or (b) make our own copy of that constant (or both)?