Libraryless. Click here for Pure Java version (3924L/23K).
1 | // Note: This can probably be optimized if all pixels are direct-grabbed |
2 | // and image2 is expendable (then you can use it as output?) |
3 | static BufferedImage imageChangeOverlay(BufferedImage image1, BufferedImage image2) { |
4 | assertSameSize(image1, image2); |
5 | int w = image1.getWidth(), h = image1.getHeight(), n = w*h; |
6 | int[] pixels1 = pixelsOfBufferedImage(image1); |
7 | int[] pixels2 = pixelsOfBufferedImage(image2); |
8 | int[] pixelsOut = new[n]; |
9 | for i to n: { |
10 | int rgb = pixels1[i]; |
11 | pixelsOut[i] = rgb == pixels2[i] ? 0 : rgb; |
12 | } |
13 | ret newBufferedImage(w, h, pixelsOut); |
14 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032771 |
Snippet name: | imageChangeOverlay - returns image1 but transparent where both images are identical |
Eternal ID of this version: | #1032771/2 |
Text MD5: | b91a91f3ee1e747e25f7300e5473050a |
Transpilation MD5: | 48a1eb3f9fdd27aa4512bc3c7227b5ff |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-05 23:01:57 |
Source code size: | 591 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 172 / 268 |
Version history: | 1 change(s) |
Referenced in: | [show references] |