sclass Image332 implements MakesBufferedImage { int w; byte[] pixels; *() {} // for persistence *(BufferedImage img) { this(RGBImage(img)); } *(RGBImage img) { w = img.getWidth(); int h = img.getHeight(); pixels = new byte[w*h]; for y to h: for x to w: pixels[y*w+x] = to332(img.getInt(x, y)); } public int getWidth() { ret w; } public int getHeight() { ret h(); } int h() { ret l(pixels)/w; } RGBImage toRGB() { int h = h(); RGBImage img = new RGBImage(w, h); int i = 0; for y to h: for x to w: img.setPixel(x, y, from332(pixels[i++])); ret img; } public BufferedImage getBufferedImage() { ret toRGB().getBufferedImage(); } // 0 to 255 int get332Pixel(int x, int y) { ret ubyteToInt(pixels[y*w+x]); } }
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: | 598 / 1209 |
Version history: | 5 change(s) |
Referenced in: | #1006576 - Image2B - image in 2 bit format (just black and white) #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) #1035585 - Hi15Image - HiColor image (15 bit / 32,768 colors) |