Libraryless. Click here for Pure Java version (60L/1K).
static BufferedImage byteArrayToGrayBufferedImage(byte[] pixels, int w, int h) { PixelInterleavedSampleModel sm = new( DataBuffer.TYPE_BYTE, w, h, 1, // pixelStride w, // scanlineStride, new int[] {0} // bandOffsets ); DataBufferByte db = new(pixels, pixels.length); WritableRaster wr = Raster.createWritableRaster(sm, db, new Point); ret new BufferedImage(grayColorModel(), wr, false, null); }
Began life as a copy of #1025281
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033441 |
Snippet name: | byteArrayToGrayBufferedImage |
Eternal ID of this version: | #1033441/3 |
Text MD5: | 2cb6ece291e52aea33db84d2107565a6 |
Transpilation MD5: | ad028867fdffeff049dd93e84f17ccd6 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-27 15:53:29 |
Source code size: | 440 bytes / 13 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 130 / 191 |
Version history: | 2 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |