1 | sclass Image332 implements MakesBufferedImage { |
2 | int w; |
3 | byte[] pixels; |
4 | |
5 | *() {} // for persistence |
6 | |
7 | *(BufferedImage img) { this(RGBImage(img)); } |
8 | *(RGBImage img) { |
9 | w = img.getWidth(); |
10 | int h = img.getHeight(); |
11 | pixels = new byte[w*h]; |
12 | for y to h: for x to w: |
13 | pixels[y*w+x] = to332(img.getInt(x, y)); |
14 | } |
15 | |
16 | public int getWidth() { ret w; } |
17 | public int getHeight() { ret h(); } |
18 | |
19 | int h() { |
20 | ret l(pixels)/w; |
21 | } |
22 | |
23 | RGBImage toRGB() { |
24 | int h = h(); |
25 | RGBImage img = new RGBImage(w, h); |
26 | int i = 0; |
27 | for y to h: for x to w: |
28 | img.setPixel(x, y, from332(pixels[i++])); |
29 | ret img; |
30 | } |
31 | |
32 | public BufferedImage getBufferedImage() { |
33 | ret toRGB().getBufferedImage(); |
34 | } |
35 | |
36 | // 0 to 255 |
37 | int get332Pixel(int x, int y) { |
38 | ret ubyteToInt(pixels[y*w+x]); |
39 | } |
40 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005378 |
Snippet name: | Image332 - image in 332 (8 bit) format |
Eternal ID of this version: | #1005378/6 |
Text MD5: | 71b67d10e63471259adbfc754251cf0e |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-04-29 14:16:40 |
Source code size: | 855 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 597 / 1209 |
Version history: | 5 change(s) |
Referenced in: | [show references] |