Siv3D / OpenSiv3D

C++20 framework for creative coding 🎮🎨🎹 / Cross-platform support (Windows, macOS, Linux, and the Web)
https://siv3d.github.io/
MIT License
994 stars 136 forks source link

BMP サポートの強化(1-bit, 4-bit, 16-bit, 特殊なヘッダやパレットのロード) #1204

Closed Reputeless closed 1 month ago

Reputeless commented 6 months ago
Raclamusi commented 6 months ago
  1. 16-bit BMP は Microsoft Paint で保存できる形式ではなく、マイナーですが、1, 4, 8, 24, 32-bit に対応して 16-bit だけ対応しないのも変なので、16-bit にも一緒に実装していいですか?
  2. 現在の実装では、バッファの確保 ( std::malloc ) に失敗すると透明な画像を返す実装になっているので、std::bad_alloc もしくは std::length_error を投げるように変更したいです。一緒に実装しようと思っていますが、別で issue 立てたほうがいいですか?

https://github.com/Siv3D/OpenSiv3D/blob/33ec9281b6968592a6835ec1772d7571fc94228f/Siv3D/src/Siv3D/ImageFormat/BMP/BMPDecoder.cpp?ts=4#L126

Reputeless commented 6 months ago
  1. では対応しましょう。テスト用に各フォーマットの bmp ファイルを用意してください(コミットには含まず)。
  2. std::bad_alloc を使うようにして大丈夫です。
Raclamusi commented 6 months ago

ヘッダと画像データの間にギャップがあるとき、および、パレットの色数が最大でないときに正しく読み込めないバグがありました。 一緒に直します。

スクリーンショット

Raclamusi commented 6 months ago

テスト用ソースコード: https://gist.github.com/Raclamusi/039af3aa2698424a3bfc48e885224f94 テスト用画像ファイル: https://drive.google.com/drive/folders/1UFL-rqHZ3wjn-5efr_9ghWNtZ-GqYlOD?usp=sharing

Raclamusi commented 6 months ago

テスト用コード、実装完了しました。

ソースコード

Raclamusi commented 6 months ago

PR #1207 のコメントに変更についての詳しい説明を書きました。