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).

static BufferedImage mergeBufferedImagesHorizontally(BufferedImage... images) {
  ret mergeBufferedImagesHorizontally(toList(images));
}

static BufferedImage mergeBufferedImagesHorizontally(L<BufferedImage> images, O... _) {
  if (empty(images)) null;
  optPar int spacing = imageMergeSpacing();
  RGB spaceColor = new RGB(0.9f);
  int w = intSum(mapMethod getWidth(images))+(l(images)-1)*spacing, h = intMax(mapMethod getHeight(images));
  BufferedImage out = newBufferedImage(w, h, spaceColor);
  int x = 0;
  for i over images: {
    BufferedImage img = images.get(i);
    int y = (h-img.getHeight())/2;
    copyBufferedImage(img, out, x, y);
    x += img.getWidth() + spacing;
  }
  ret out;
}

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: 176 / 272
Version history: 7 change(s)
Referenced in: [show references]