Skip to content

Commit

Permalink
Added support for BMP images saved by GIMP 2.10.22 with color space i…
Browse files Browse the repository at this point in the history
…nfo. (compression method = 3)
  • Loading branch information
NagyD committed Nov 15, 2020
1 parent 2712ff3 commit 8b5194d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions doc/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ This program is open source under the GNU General Public License terms.
x See todo.txt for future plans.
-------------------------------------------------

-------------------------------------------------
upcoming version (no release date yet)
-------------------------------------------------
- Made the highest compression level the default.
- Added support for BMP images saved by GIMP 2.10.22 with color space info. (compression method = 3)

-------------------------------------------------
PR v1.3.1 (released 2018-05-12)
-------------------------------------------------
Expand Down
10 changes: 8 additions & 2 deletions src/lib/formats/bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ int readBmp(const char* file, unsigned char** data, int *ph, int *pw, int *pbit
/* info header */
ok=ok&&freadlong(&aux ,bitmap);
/* http://en.wikipedia.org/wiki/BMP_file_format#DIB_header_.28bitmap_information_header.29 */
/* GIMP saves 108 byte headers by default */
/* GIMP saves 108-byte headers by default (if color space info is enabled) */
/* 124-byte headers since GIMP 2.10.22 */
ok=ok&&(aux>=40);
headersize=aux;
ok=ok&&freadlong(&width ,bitmap);
Expand All @@ -159,7 +160,12 @@ int readBmp(const char* file, unsigned char** data, int *ph, int *pw, int *pbit
ok=ok&&(aux==1);
ok=ok&&freadshort(&bits ,bitmap);
ok=ok&&freadlong(&aux ,bitmap); /* Compression type (0=none) */
if (ok&&aux!=0) { fclose(bitmap); return -1; /* PR_NO_COMPRESS_SUPPORT */ }
/* 0 means no compression, 3 is used in files saved by GIMP 2.10.22 with color space info. */
if (ok&&aux!=0 && aux!=3) {
printf("Error: BMP uses an unknown compression method: %lu\n", aux);
fclose(bitmap);
return -1; /* PR_NO_COMPRESS_SUPPORT */
}
ok=ok&&freadlong(&aux ,bitmap); /* Image size in bytes (junk) */
ok=ok&&freadlong(&aux ,bitmap); /* Pixels per meter x (junk) */
ok=ok&&freadlong(&aux ,bitmap); /* Pixels per meter y (junk) */
Expand Down

0 comments on commit 8b5194d

Please sign in to comment.