Libraryless. Click here for Pure Java version (37L/1K).
// from: https://stackoverflow.com/questions/14416107/int-array-to-bufferedimage // pixels are RGB pixels static BufferedImage intArrayToBufferedImageWithoutAlpha(int[] pixels, int w, int h) { int[] bitMasks = {0xFF0000, 0xFF00, 0xFF}; SinglePixelPackedSampleModel sm = new(DataBuffer.TYPE_INT, w, h, bitMasks); DataBufferInt db = new(pixels, pixels.length); WritableRaster wr = Raster.createWritableRaster(sm, db, new Point); DirectColorModel cm = new (24, bitMasks[0], bitMasks[1], bitMasks[2], 0); ret new BufferedImage(cm, wr, false, null); }
Began life as a copy of #1025281
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1034531 |
| Snippet name: | intArrayToBufferedImageWithoutAlpha |
| Eternal ID of this version: | #1034531/6 |
| Text MD5: | e529019ec2ee5e890ab7b399942c8216 |
| Transpilation MD5: | 3cd07c21cf6d4479429893b46e9642c1 |
| Author: | stefan |
| Category: | javax / imaging |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-02-11 03:49:33 |
| Source code size: | 567 bytes / 10 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 416 / 554 |
| Version history: | 5 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |