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

15
LINES

< > BotCompany Repo | #1035974 // cutOutRegionFromImage - replaced by CutOutRegionFromImage

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

Transpiled version (13129L) is out of date.

static BufferedImage cutOutRegionFromImage(IImageRegion region) {
  if (region == null) null;
  var fullImage = toBufferedImage(region.image());
  var r = region.bounds();
  var clipped = clipBufferedImage(fullImage, r);
  int[] pixels = pixelsOfBufferedImage(clipped);
  int w = r.w, h = r.h, i = 0;
  for y to h:
    for x to w: {
      if (!region.contains(r.x+x, r.y+y))
        pixels[i] = 0;
      ++i;
    }
  ret bufferedImageWithAlpha(w, h, pixels);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1035974
Snippet name: cutOutRegionFromImage - replaced by CutOutRegionFromImage
Eternal ID of this version: #1035974/7
Text MD5: bc2513cfa8d6bb3acb51e3e3d5c1425b
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-20 20:11:19
Source code size: 474 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 18 / 39
Version history: 6 change(s)
Referenced in: [show references]