Libraryless. Click here for Pure Java version (9269L/51K).
1 | static BufferedImageWithMeta cloneBufferedImageWithMeta(BufferedImage img) {
|
2 | if (img == null) null; |
3 | if (img cast BufferedImageWithMeta) ret img; |
4 | |
5 | new Hashtable<S, O> properties; |
6 | var names = img.getPropertyNames(); |
7 | if (names != null) for (key : names) |
8 | properties.put(key, img.getProperty(key)); |
9 | if (!properties.containsKey("meta"))
|
10 | properties.put(meta := new Meta); |
11 | |
12 | var cm = img.getColorModel(); |
13 | |
14 | var img2 = new BufferedImageWithMeta(cm, |
15 | img.getRaster(), |
16 | cm.hasAlpha() && cm.isAlphaPremultiplied(), |
17 | properties); |
18 | assertNotNull(toIMeta(img2)); |
19 | ret img2; |
20 | } |
Began life as a copy of #1034005
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1034006 |
| Snippet name: | cloneBufferedImageWithMeta - try to make another instance of a BufferedImage with same contents but also having an IMeta property |
| Eternal ID of this version: | #1034006/8 |
| Text MD5: | 4b6209f34033c1f547d7ac5afd511a60 |
| Transpilation MD5: | 3c79988e9eb2afac610662de6bfd28d5 |
| Author: | stefan |
| Category: | javax / imaging |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-10-04 18:42:27 |
| Source code size: | 620 bytes / 20 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 476 / 631 |
| Version history: | 7 change(s) |
| Referenced in: | [show references] |