Libraryless. Click here for Pure Java version (3026L/17K).
1 | static BufferedImage scaleBufferedImagePixelated(BufferedImage img, int w, int h) { |
2 | int w1 = img.getWidth(), h1 = img.getHeight(); |
3 | int[] pixels1 = pixelsOfBufferedImage(img); |
4 | int[] pixels = new[w*h]; |
5 | int i = 0; |
6 | double y1 = 0, ystep = doubleRatio(h1, h), xstep = doubleRatio(w1, w); |
7 | for y to h: { |
8 | int i1 = ifloor(y1)*w1; |
9 | y1 += ystep; |
10 | double x1 = 0; |
11 | for x to w: { |
12 | pixels[i++] = pixels1[i1+ifloor(x1)]; |
13 | x1 += xstep; |
14 | } |
15 | } |
16 | ret intArrayToBufferedImage(pixels, w, h); |
17 | } |
Began life as a copy of #1025282
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1031991 |
Snippet name: | scaleBufferedImagePixelated |
Eternal ID of this version: | #1031991/3 |
Text MD5: | 35390c77e0a2693fa293082153804af1 |
Transpilation MD5: | 79c0f08039f4a5650221dcb304fcefc5 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-08-07 16:35:22 |
Source code size: | 525 bytes / 17 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 161 / 220 |
Version history: | 2 change(s) |
Referenced in: | [show references] |