Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

13
LINES

< > BotCompany Repo | #1033069 // imagePixelsToRGBAWithSize

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4000L/23K).

1  
static byte[] imagePixelsToRGBAWithSize(BufferedImage etc img) {
2  
  if (img == null) null;
3  
  int w = img.getWidth(), h = img.getHeight(), n = w*h;
4  
  byte[] out = new[(n+2)*4];
5  
  
6  
  // store width and height
7  
  intToBytes_inArray_littleEndian(w, out, 0);
8  
  intToBytes_inArray_littleEndian(h, out, 4);
9  
  
10  
  // store pixels
11  
  copyIntArrayToByteArray_littleEndian(pixelsOfBufferedImage(img), out, 8);
12  
  ret out;
13  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033069
Snippet name: imagePixelsToRGBAWithSize
Eternal ID of this version: #1033069/2
Text MD5: 4d04ab746f4915af867b0a6e39a45da8
Transpilation MD5: 065e9e5f8a85d26f0e64f058d2877cf7
Author: stefan
Category: javax / compression /pattern recognition
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-13 00:49:12
Source code size: 419 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 150 / 223
Version history: 1 change(s)
Referenced in: [show references]