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

19
LINES

< > BotCompany Repo | #1024673 // mergeBufferedImagesHorizontally [with spacing]

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

Libraryless. Click here for Pure Java version (2455L/15K).

1  
static BufferedImage mergeBufferedImagesHorizontally(BufferedImage... images) {
2  
  ret mergeBufferedImagesHorizontally(toList(images));
3  
}
4  
5  
static BufferedImage mergeBufferedImagesHorizontally(L<BufferedImage> images, O... _) {
6  
  if (empty(images)) null;
7  
  optPar int spacing = imageMergeSpacing();
8  
  RGB spaceColor = new RGB(0.9f);
9  
  int w = intSum(mapMethod getWidth(images))+(l(images)-1)*spacing, h = intMax(mapMethod getHeight(images));
10  
  BufferedImage out = newBufferedImage(w, h, spaceColor);
11  
  int x = 0;
12  
  for i over images: {
13  
    BufferedImage img = images.get(i);
14  
    int y = (h-img.getHeight())/2;
15  
    copyBufferedImage(img, out, x, y);
16  
    x += img.getWidth() + spacing;
17  
  }
18  
  ret out;
19  
}

Author comment

Began life as a copy of #1006374

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024673
Snippet name: mergeBufferedImagesHorizontally [with spacing]
Eternal ID of this version: #1024673/8
Text MD5: 9c96b14b4cf6488a5460508e488811f6
Transpilation MD5: 8a95b5f3d38c0cf27baa55119f4ea549
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-27 15:23:01
Source code size: 716 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 257 / 362
Version history: 7 change(s)
Referenced in: [show references]