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

1  
static BWImage mergeBWImagesHorizontally(BWImage... images) {
2  
  ret mergeBWImagesHorizontally(toList(images));
3  
}
4  
5  
static BWImage mergeBWImagesHorizontally(L<BWImage> images, O... _) {
6  
  if (empty(images)) null;
7  
  optPar int spacing = imageMergeSpacing();
8  
  float spaceColor = toFloat(optPar(_, 'spaceColor, 0.9f));
9  
  int w = intSum(images, "width")+(l(images)-1)*spacing, h = intMax(images, "height");
10  
  BWImage out = new BWImage(w, h, spaceColor);
11  
  int x = 0;
12  
  for i over images: {
13  
    BWImage img = images.get(i);
14  
    int y = (h-img.h())/2;
15  
    copyBWImage(img, 0, 0, out, x, y);
16  
    x += img.w() + 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 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: 511 / 625
Version history: 9 change(s)
Referenced in: [show references]