Libraryless. Click here for Pure Java version (11530L/67K).
1 | static BufferedImage scaledBufferedImageFromBWIntegralImage(int w, BWIntegralImage img) { |
2 | ret scaledBufferedImageFromBWIntegralImage(img, w); |
3 | } |
4 | |
5 | static BufferedImage scaledBufferedImageFromBWIntegralImage(BWIntegralImage img, int w, int h default heightForWidth(img.w, img.h, w)) { |
6 | int w1 = img.w, h1 = img.h; |
7 | int[] pixels = new[w*h]; |
8 | int i = 0; |
9 | for y to h: |
10 | for x to w: { |
11 | // TODO: optimize |
12 | int x1 = x*w1/w, x2 = max(x1+1, (x+1)*w1/w); |
13 | int y1 = y*h1/h, y2 = max(y1+1, (y+1)*h1/h); |
14 | int pixel = iround(img.getPixelAverage(x1, y1, x2, y2)); |
15 | pixels[i++] = brightnessToRGBA(pixel); |
16 | } |
17 | ret bufferedImage(w, h, pixels); |
18 | } |
Began life as a copy of #1019597
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033302 |
Snippet name: | scaledBufferedImageFromBWIntegralImage |
Eternal ID of this version: | #1033302/9 |
Text MD5: | 5c728efb2105c4e8a978330c77e2c443 |
Transpilation MD5: | 2f3a6f5340b06690ee4d52d437aa7922 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-27 15:36:41 |
Source code size: | 679 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 209 / 303 |
Version history: | 8 change(s) |
Referenced in: | [show references] |