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

18
LINES

< > BotCompany Repo | #1006374 // mergeImagesHorizontally [with spacing]

JavaX fragment (include)

1  
static RGBImage mergeImagesHorizontally(RGBImage... images) {
2  
  ret mergeImagesHorizontally(toList(images));
3  
}
4  
5  
static RGBImage mergeImagesHorizontally(L<RGBImage> images, O... _) {
6  
  optPar int spacing = imageMergeSpacing();
7  
  RGB spaceColor = new RGB(0.9f);
8  
  int w = intSum(images, "width")+(l(images)-1)*spacing, h = intMax(images, "height");
9  
  RGBImage out = new RGBImage(w, h, spaceColor);
10  
  int x = 0;
11  
  for i over images: {
12  
    RGBImage img = images.get(i);
13  
    int y = (h-img.h())/2;
14  
    copyRGBImage(img, 0, 0, out, x, y);
15  
    x += img.w() + spacing;
16  
  }
17  
  ret out;
18  
}

Author comment

Began life as a copy of #1006081

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006374
Snippet name: mergeImagesHorizontally [with spacing]
Eternal ID of this version: #1006374/2
Text MD5: a6ae7f60e67f69abd84bee15951118fb
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-24 00:46:24
Source code size: 594 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 517 / 526
Version history: 1 change(s)
Referenced in: [show references]