Libraryless. Click here for Pure Java version (9269L/51K).
static BufferedImageWithMeta cloneBufferedImageWithMeta(BufferedImage img) { if (img == null) null; if (img cast BufferedImageWithMeta) ret img; new Hashtable<S, O> properties; var names = img.getPropertyNames(); if (names != null) for (key : names) properties.put(key, img.getProperty(key)); if (!properties.containsKey("meta")) properties.put(meta := new Meta); var cm = img.getColorModel(); var img2 = new BufferedImageWithMeta(cm, img.getRaster(), cm.hasAlpha() && cm.isAlphaPremultiplied(), properties); assertNotNull(toIMeta(img2)); ret img2; }
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: | 176 / 278 |
Version history: | 7 change(s) |
Referenced in: | [show references] |