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

24
LINES

< > BotCompany Repo | #1035605 // G22_RegionToSSI - chooses the leftmost scanline (not good)

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

Libraryless. Click here for Pure Java version (15754L/91K).

srecord noeq G22_RegionToSSI(IImageRegion region) {
  SSI get() {
    if (region == null) null;
    Rect r = region.bounds();
    int x1 = r.x1(), y1 = r.y1(), y2 = r.y2(), h = y2-y1, w = r.w;
    SSI ssi = new SSI(y1, y2);
    ssi.color(region.color());
    short[] data = new[h*2];
    for (int y = y1; y < y2; y++) {
      reMutable y;
      L<IntRange> streaks = genericStreaks(w, x -> region.contains(x1+x, y));
      IntRange range = selectHorizontalPart(streaks);
      int i = (y-y1)*2;
      data[i] = toShort_enforce(x1+range.start);
      data[i+1] = toShort_enforce(x1+range.end);
    }
    ssi.data(data);
    ret ssi;
  }
  
  swappable IntRange selectHorizontalPart(L<IntRange> parts) {
    ret first(parts);
  }
}

Author comment

Began life as a copy of #1035603

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035605
Snippet name: G22_RegionToSSI - chooses the leftmost scanline (not good)
Eternal ID of this version: #1035605/11
Text MD5: 69d7389201c154f9e1e818ffe796164b
Transpilation MD5: 2c915fb9f2ceec0b56a10bd508546c85
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-26 23:14:32
Source code size: 752 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 160 / 255
Version history: 10 change(s)
Referenced in: [show references]