Skip to content

Commit

Permalink
Merge pull request #592 from mveunen/feature/ico-width-and-height-of-…
Browse files Browse the repository at this point in the history
…0-are-256

In case of an ico file a height or with of 0 actually means 256
  • Loading branch information
drewnoakes authored Nov 29, 2022
2 parents e9ff975 + 8430d89 commit 5754a0d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Source/com/drew/metadata/ico/IcoReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ public void extract(@NotNull final SequentialReader reader, @NotNull final Metad
try {
directory.setInt(IcoDirectory.TAG_IMAGE_TYPE, type);

directory.setInt(IcoDirectory.TAG_IMAGE_WIDTH, reader.getUInt8());
directory.setInt(IcoDirectory.TAG_IMAGE_HEIGHT, reader.getUInt8());
//See https://docs.fileformat.com/image/ico/ - An image width/height of 0 means 256
int imageWidth = reader.getUInt8();
int imageHeight = reader.getUInt8();
directory.setInt(IcoDirectory.TAG_IMAGE_WIDTH, imageWidth == 0 ? 256 : imageWidth);
directory.setInt(IcoDirectory.TAG_IMAGE_HEIGHT, imageHeight == 0 ? 256 : imageHeight);
directory.setInt(IcoDirectory.TAG_COLOUR_PALETTE_SIZE, reader.getUInt8());
// Ignore this byte (normally zero, though .NET's System.Drawing.Icon.Save method writes 255)
reader.getUInt8();
Expand Down

0 comments on commit 5754a0d

Please sign in to comment.