Libraryless. Click here for Pure Java version (11138L/64K).
static Image2B resizeImage2B(int w, int h default widthToHeight(w, img), Image2B img) { if (img == null) null; int w1 = img.getWidth(), h1 = img.getHeight(); if (w == w1 && h == h1) ret img; byte[] pixels1 = img.pixels, pixels2 = new byte[(w*h+7)/8]; int i = 0; double y1 = 0, ystep = doubleRatio(h1, h), xstep = doubleRatio(w1, w); for y to h: { int i1 = ifloor(y1)*w1; y1 += ystep; double x1 = 0; for x to w: { int i2 = i1+ifloor(x1); if ((pixels1[i2/8] & (1 << (i2 & 7))) != 0) pixels2[i/8] |= 1 << (i & 7); x1 += xstep; i++; } } ret new Image2B(w, h, pixels2); }
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: | 124 / 178 |
Version history: | 2 change(s) |
Referenced in: | [show references] |