Libraryless. Click here for Pure Java version (11138L/64K).
1 | static Image2B resizeImage2B(int w, int h default widthToHeight(w, img), Image2B img) { |
2 | if (img == null) null; |
3 | int w1 = img.getWidth(), h1 = img.getHeight(); |
4 | if (w == w1 && h == h1) ret img; |
5 | byte[] pixels1 = img.pixels, pixels2 = new byte[(w*h+7)/8]; |
6 | int i = 0; |
7 | double y1 = 0, ystep = doubleRatio(h1, h), xstep = doubleRatio(w1, w); |
8 | for y to h: { |
9 | int i1 = ifloor(y1)*w1; |
10 | y1 += ystep; |
11 | double x1 = 0; |
12 | for x to w: { |
13 | int i2 = i1+ifloor(x1); |
14 | if ((pixels1[i2/8] & (1 << (i2 & 7))) != 0) |
15 | pixels2[i/8] |= 1 << (i & 7); |
16 | x1 += xstep; |
17 | i++; |
18 | } |
19 | } |
20 | ret new Image2B(w, h, pixels2); |
21 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1035819 |
Snippet name: | resizeImage2B (pixelated) - analog to #1031991 |
Eternal ID of this version: | #1035819/3 |
Text MD5: | 1c1ac06c2a28f5e8344f43b78f045bb1 |
Transpilation MD5: | f55528a2e7134f61b25b31013ddf6975 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-01 19:48:50 |
Source code size: | 656 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 125 / 180 |
Version history: | 2 change(s) |
Referenced in: | [show references] |