Libraryless. Click here for Pure Java version (8123L/47K).
1 | // use x for black and _ for white |
2 | static BWImage bwImageFromString(S s) { |
3 | LS lines = tlft(s); |
4 | if (empty(lines)) null; |
5 | int h = l(lines), w = l(first(lines)); |
6 | BWImage out = new(w, h); |
7 | for y to h: { |
8 | S line = lines.get(y); |
9 | for x to w: |
10 | if (charAt(line, x) == '_') |
11 | out.setInt(x, y, 255); |
12 | } |
13 | ret out; |
14 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033939 |
Snippet name: | bwImageFromString |
Eternal ID of this version: | #1033939/7 |
Text MD5: | 5a42941de9b90af17af2b2158a504404 |
Transpilation MD5: | c85168b48b1ca89d0877e2206723b447 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-15 23:25:12 |
Source code size: | 344 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 216 / 342 |
Version history: | 6 change(s) |
Referenced in: | [show references] |