Transpiled version (10459L) is out of date.
sclass Hi15Image extends WAndHImpl is MakesBufferedImage { short[] pixels; *() {} // for persistence *(int *w, int *h, short[] *pixels) {} // TODO: optimize! *(BufferedImage img) { this(RGBImage(img)); } *(RGBImage img) { w = img.getWidth(); h = img.getHeight(); pixels = new short[w*h]; for y to h: for x to w: pixels[y*w+x] = rgbIntToHi15(img.getInt(x, y)); } *(MakesBufferedImage img) { this(toBufferedImage(img)); } RGBImage toRGB() { RGBImage img = new RGBImage(w, h); int i = 0, w = this.w, h = this.h; for y to h: for x to w: img.setPixel(x, y, hi15ToRGBInt(pixels[i++])); ret img; } public BufferedImage getBufferedImage() { ret toRGB().getBufferedImage(); } // 0 to 32767 short getHi15Pixel aka getHi15Color(int x, int y) { ret pixels[y*w+x]; } // idx = index in pixel array public short getHi15Pixel_noRangeCheck(int idx) { ret pixels[idx]; } static int perChannelBitCountMask(int bitCount) { int mask = ((~0x1F) >> bitCount) & 0x1F; int mask2 = (mask << 10) | (mask << 5) | mask; ret mask2; } void reducePerChannelBitCount(int bitCount) { if (bitCount >= 5) ret; int mask = perChannelBitCountMask(bitCount); short[] pixels = this.pixels; for (int i = 0; i < pixels.length; i++) pixels[i] = (short) (pixels[i] & mask); } void reduceColorCount(int numColors) { assertPowerOfTwo(numColors); int bits = dualLog(numColors); assertDivisibleBy(3, bits); int bitsPerChannel = bits/3; reducePerChannelBitCount(bitsPerChannel); } }
Began life as a copy of #1005378
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035585 |
Snippet name: | Hi15Image - HiColor image (15 bit / 32,768 colors) |
Eternal ID of this version: | #1035585/19 |
Text MD5: | 6dba2c9db048e8ce88481e122f26e462 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-08 15:51:24 |
Source code size: | 1681 bytes / 62 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 214 / 342 |
Version history: | 18 change(s) |
Referenced in: | [show references] |