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

20
LINES

< > BotCompany Repo | #1033129 // imageToMatrix

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

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

static Matrix<Int> imageToMatrix(BufferedImage etc img) {
  if (img == null) null;
  int _w = img.getWidth(), _h = img.getHeight();
  
  class ImageToMatrix extends AbstractMatrix<Int> {
    *() { super(_w, _h); }
    
    public Int get(int x, int y) {
      assertPointInBounds(x, y, w, h);
      ret img.getRGB(x, y);
    }
    
    public void set(int x, int y, Int val) {
      assertPointInBounds(x, y, w, h);
      img.setRGB(x, y, val);
    }
  };
  
  ret new ImageToMatrix;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1033129
Snippet name: imageToMatrix
Eternal ID of this version: #1033129/7
Text MD5: 83df79bc2f1248e9b6010e7384626634
Transpilation MD5: 00ad2167c5de7b7ecc9e13f86ecbf35f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-15 17:01:22
Source code size: 504 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 125 / 185
Version history: 6 change(s)
Referenced in: [show references]