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

13
LINES

< > BotCompany Repo | #1004602 // utfToImage

JavaX fragment (include)

1  
static BWImage utfToImage(S text) {
2  
  byte[] data = toUtf8(text);
3  
  int h = 12, w = data.length+2;
4  
  BWImage img = new BWImage(w, h, 1f);
5  
  for (int i = 0; i < l(data); i++) {
6  
    img.setPixel(i+1, 0, 0f);
7  
    img.setPixel(i+1, 11, 0f);
8  
    for (int b = 0; b < 8; b++)
9  
      if (bitSet(data[i], 7-b))
10  
        img.setPixel(i+1, b+2, 0f);
11  
  }
12  
  ret img;
13  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004602
Snippet name: utfToImage
Eternal ID of this version: #1004602/1
Text MD5: bc59732213c5bef5ec4c597d1ace3d4e
Author: stefan
Category: javax / images
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-23 22:01:53
Source code size: 365 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 636 / 614
Referenced in: [show references]