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

15
LINES

< > BotCompany Repo | #1010174 // cutOutPixelSet_scale with outline [dev.]

JavaX fragment (include)

1  
static BufferedImage cutOutPixelSet_scale(BufferedImage image, BufferedImage bigImg, PixelSet set, int outline) {
2  
  int scale = iround(bigImg.getWidth()/(double) image.getWidth());
3  
  Rect r = pixelSetBounds(set);
4  
  int bw = bigImg.getWidth(), bh = bigImg.getHeight();
5  
  BufferedImage img = transparentBufferedImage(r.w*scale+outline*2, r.h*scale+outline*2);
6  
  for (Pixel p : set) {
7  
    int x1 = (p.x-r.x)*scale+outline, y1 = (p.y-r.y)*scale+outline;
8  
    int xb = p.x*scale, yb = p.y*scale;
9  
    for (int y = 0; y < scale; y++)
10  
      for (int x = 0; x < scale; x++)
11  
        if (xb+x >= 0 && xb+x < bw && yb+y >= 0 && yb+y < bh)
12  
          img.setRGB(x1+x, y1+y, bigImg.getRGB(xb+x, yb+y));
13  
  }
14  
  ret img;
15  
}

Author comment

Began life as a copy of #1010173

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1010174
Snippet name: cutOutPixelSet_scale with outline [dev.]
Eternal ID of this version: #1010174/1
Text MD5: 84cb778b2b9ee3e103d88cca818aacd1
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-09-05 20:12:00
Source code size: 717 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 371 / 401
Referenced in: [show references]