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

19
LINES

< > BotCompany Repo | #1007137 // mergeBWImagesHorizontally [with spacing]

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

Libraryless. Click here for Pure Java version (5142L/29K).

static BWImage mergeBWImagesHorizontally(BWImage... images) {
  ret mergeBWImagesHorizontally(toList(images));
}

static BWImage mergeBWImagesHorizontally(L<BWImage> images, O... _) {
  if (empty(images)) null;
  optPar int spacing = imageMergeSpacing();
  float spaceColor = toFloat(optPar(_, 'spaceColor, 0.9f));
  int w = intSum(images, "width")+(l(images)-1)*spacing, h = intMax(images, "height");
  BWImage out = new BWImage(w, h, spaceColor);
  int x = 0;
  for i over images: {
    BWImage img = images.get(i);
    int y = (h-img.h())/2;
    copyBWImage(img, 0, 0, out, x, y);
    x += img.w() + spacing;
  }
  ret out;
}

Author comment

Began life as a copy of #1006374

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1007137
Snippet name: mergeBWImagesHorizontally [with spacing]
Eternal ID of this version: #1007137/10
Text MD5: 80eeb876cd142ab1830457b7131c5945
Transpilation MD5: c56157e6a03ed883c3b334f36c398b40
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-11 15:09:49
Source code size: 646 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 510 / 623
Version history: 9 change(s)
Referenced in: [show references]