mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 16:47:28 +01:00
std: limit supported image dimensions to 0xFF_FFFF
This commit is contained in:
1 parent
d8c23a3a66
commit
e126c998e0
10 files changed
+175
-123
No files matched your search
@@ -6,6 +6,8 @@
|
||||
- Changed `lzw.set_literal_width` to `lzw.set_quirk`.
|
||||
- Changed `set_quirk_enabled!(quirk: u32, enabled: bool)` to `set_quirk!(key:
|
||||
u32, value: u64) status`.
|
||||
- Set image decoder pixel width and height inclusive maximum to `0xFF_FFFF`,
|
||||
down from `0x7FFF_FFFF`.
|
||||
|
||||
The dot points below probably aren't of interest unless you're _writing_ Wuffs
|
||||
code (instead of writing C/C++ code that _uses_ Wuffs' standard library).
|
||||
|
||||
@@ -7,12 +7,19 @@ but the `gif` could be replaced by `jpeg`, `png`, etc.
|
||||
Some image formats (GIF) are animated, consisting of an image header and then N
|
||||
frames. The image header gives e.g. the overall image's width and height. Each
|
||||
frame consists of a frame header (e.g. frame rectangle bounds, display
|
||||
duration) and a payload (the pixels).
|
||||
duration) and a payload (the pixels). Headers are also known as configurations.
|
||||
|
||||
Wuffs image decoders will reject an image dimension (width or height) that is
|
||||
above `0xFF_FFFF = 16_777215` pixels, even if the underlying image file format
|
||||
permits more. This limit simplifies handling potential overflow. For example,
|
||||
`width * bytes_per_pixel` will not overflow an `i32` and `width * height *
|
||||
bytes_per_pixel` will not overflow an `i64`. Similarly, converting a pixel
|
||||
width from integers to 26.6 fixed point units will not overflow an `i32`.
|
||||
|
||||
In general, there is one `wuffs_base__image_config` and then N pairs of
|
||||
(`wuffs_base__frame_config`, frame). Non-animated (still) image formats are
|
||||
treated the same way: that their N is 1 and their single frame's bounds equals
|
||||
the overall image bounds.
|
||||
(`wuffs_base__frame_config`, frame payload). Non-animated (still) image formats
|
||||
are treated the same way: that their N is 1 and their single frame's bounds
|
||||
equals the overall image bounds.
|
||||
|
||||
To decode everything (without knowing N in advance) sequentially:
|
||||
|
||||
|
||||
Reference in new issue
Block a user