Libraryless. Click here for Pure Java version (37L/1K).
1 | // from: https://stackoverflow.com/questions/14416107/int-array-to-bufferedimage |
2 | // pixels are RGB pixels |
3 | static BufferedImage intArrayToBufferedImageWithoutAlpha(int[] pixels, int w, int h) { |
4 | int[] bitMasks = {0xFF0000, 0xFF00, 0xFF}; |
5 | SinglePixelPackedSampleModel sm = new(DataBuffer.TYPE_INT, w, h, bitMasks); |
6 | DataBufferInt db = new(pixels, pixels.length); |
7 | WritableRaster wr = Raster.createWritableRaster(sm, db, new Point); |
8 | DirectColorModel cm = new (24, bitMasks[0], bitMasks[1], bitMasks[2], 0); |
9 | ret new BufferedImage(cm, wr, false, null); |
10 | } |
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: | 159 / 231 |
Version history: | 5 change(s) |
Referenced in: | [show references] |