diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2021-06-21 16:32:42 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2021-06-21 16:32:42 +0200 |
| commit | e036a321a054261d35c3ff241c327e1ba1daf39e (patch) | |
| tree | 438d495d6f8d8c2df7835b048714888a083986f6 /core/image/common.odin | |
| parent | 18471f358ea0e096bfdfb9dc04cd3fcbbb3ea50b (diff) | |
Replace `core:image`'s `sidecar` with explicit `metadata_ptr` and `metadata_type`.
To unpack, use:
```odin
v: ^png.Info;
if img.metadata_ptr != nil && img.metadata_type == png.Info {
v = (^png.Info)(img.metadata_ptr);
...
}
```
Diffstat (limited to 'core/image/common.odin')
| -rw-r--r-- | core/image/common.odin | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/core/image/common.odin b/core/image/common.odin index 2d1dcf0f8..8443a2d22 100644 --- a/core/image/common.odin +++ b/core/image/common.odin @@ -4,18 +4,20 @@ import "core:bytes" import "core:mem" Image :: struct { - width: int, - height: int, - channels: int, - depth: int, - pixels: bytes.Buffer, + width: int, + height: int, + channels: int, + depth: int, + pixels: bytes.Buffer, /* Some image loaders/writers can return/take an optional background color. For convenience, we return them as u16 so we don't need to switch on the type in our viewer, and can just test against nil. */ - background: Maybe([3]u16), - sidecar: any, + background: Maybe([3]u16), + + metadata_ptr: rawptr, + metadata_type: typeid, } /* @@ -190,13 +192,14 @@ return_single_channel :: proc(img: ^Image, channel: Channel) -> (res: ^Image, ok } res = new(Image); - res.width = img.width; - res.height = img.height; - res.channels = 1; - res.depth = img.depth; - res.pixels = t; - res.background = img.background; - res.sidecar = img.sidecar; + res.width = img.width; + res.height = img.height; + res.channels = 1; + res.depth = img.depth; + res.pixels = t; + res.background = img.background; + res.metadata_ptr = img.metadata_ptr; + res.metadata_type = img.metadata_type; return res, true; } |