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

18
LINES

< > BotCompany Repo | #1004605 // imageToUtf

JavaX fragment (include)

static S imageToUtf(BWImage img) {
  int w = img.getWidth(), h = img.getHeight();
  if (h < 12) null;
  
  byte[] data = new byte[w-2];
  for (int x = 1; x < w-1; x++) {
    int b = 0;
    if (img.getPixel(x, 0) != 0
      || img.getPixel(x, 11) != 0)
      fail("not an utf8 image");
      
    for (int y = 2; y < 2+8; y++)
      b = b << 1 | (img.getPixel(x, y) > .5f ? 0 : 1);
      
    data[x-1] = (byte) b;
  }
  ret fromUtf8(data);
}

Author comment

Began life as a copy of #1004602

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: #1004605
Snippet name: imageToUtf
Eternal ID of this version: #1004605/1
Text MD5: 6b13107240ef737221d9cb5579aa0d3c
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:02:02
Source code size: 458 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 592 / 560
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)