Libraryless. Click here for Pure Java version (4005L/23K).
1 | static Matrix<Int> imageToMatrix(BufferedImage etc img) { |
2 | if (img == null) null; |
3 | int _w = img.getWidth(), _h = img.getHeight(); |
4 | |
5 | class ImageToMatrix extends AbstractMatrix<Int> { |
6 | *() { super(_w, _h); } |
7 | |
8 | public Int get(int x, int y) { |
9 | assertPointInBounds(x, y, w, h); |
10 | ret img.getRGB(x, y); |
11 | } |
12 | |
13 | public void set(int x, int y, Int val) { |
14 | assertPointInBounds(x, y, w, h); |
15 | img.setRGB(x, y, val); |
16 | } |
17 | }; |
18 | |
19 | ret new ImageToMatrix; |
20 | } |
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: | 189 / 266 |
Version history: | 6 change(s) |
Referenced in: | [show references] |