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

14
LINES

< > BotCompany Repo | #1033939 // bwImageFromString

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

Libraryless. Click here for Pure Java version (8123L/47K).

// use x for black and _ for white
static BWImage bwImageFromString(S s) {
  LS lines = tlft(s);
  if (empty(lines)) null;
  int h = l(lines), w = l(first(lines));
  BWImage out = new(w, h);
  for y to h: {
    S line = lines.get(y);
    for x to w:
      if (charAt(line, x) == '_')
        out.setInt(x, y, 255);
  }
  ret out;
}

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: 81 / 147
Version history: 6 change(s)
Referenced in: [show references]