1 | static BufferedImage blendBufferedImages(BufferedImage bi1, BufferedImage bi2) { |
2 | ret blendBufferedImages(bi1, bi2, 0.5); |
3 | } |
4 | |
5 | static BufferedImage blendBufferedImages(BufferedImage bi1, BufferedImage bi2, double weight2) { |
6 | double weight = 1-weight2; |
7 | |
8 | int width = bi1.getWidth (); |
9 | if (width != bi2.getWidth ()) |
10 | fail("widths not equal"); |
11 | |
12 | int height = bi1.getHeight (); |
13 | if (height != bi2.getHeight ()) |
14 | fail("heights not equal"); |
15 | |
16 | BufferedImage bi3 = new BufferedImage (width, height, |
17 | BufferedImage.TYPE_INT_RGB); |
18 | int [] rgbim1 = new int [width]; |
19 | int [] rgbim2 = new int [width]; |
20 | int [] rgbim3 = new int [width]; |
21 | |
22 | for (int row = 0; row < height; row++) |
23 | { |
24 | bi1.getRGB (0, row, width, 1, rgbim1, 0, width); |
25 | bi2.getRGB (0, row, width, 1, rgbim2, 0, width); |
26 | |
27 | for (int col = 0; col < width; col++) |
28 | { |
29 | int rgb1 = rgbim1 [col]; |
30 | int r1 = (rgb1 >> 16) & 255; |
31 | int g1 = (rgb1 >> 8) & 255; |
32 | int b1 = rgb1 & 255; |
33 | |
34 | int rgb2 = rgbim2 [col]; |
35 | int r2 = (rgb2 >> 16) & 255; |
36 | int g2 = (rgb2 >> 8) & 255; |
37 | int b2 = rgb2 & 255; |
38 | |
39 | int r3 = (int) (r1*weight+r2*(1.0-weight)); |
40 | int g3 = (int) (g1*weight+g2*(1.0-weight)); |
41 | int b3 = (int) (b1*weight+b2*(1.0-weight)); |
42 | rgbim3 [col] = (r3 << 16) | (g3 << 8) | b3; |
43 | } |
44 | |
45 | bi3.setRGB (0, row, width, 1, rgbim3, 0, width); |
46 | } |
47 | |
48 | return bi3; |
49 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
1 comment(s) hidden. show
Snippet ID: | #1015024 |
Snippet name: | blendBufferedImages |
Eternal ID of this version: | #1015024/2 |
Text MD5: | e557eba863026cd3f3711671826d57f7 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-05-07 01:38:15 |
Source code size: | 1428 bytes / 49 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 559 / 604 |
Version history: | 1 change(s) |
Referenced in: | [show references] |