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

16
LINES

< > BotCompany Repo | #1036007 // patchworkBufferedImagesHorizontally [with spacing]

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

Libraryless. Click here for Pure Java version (9856L/56K).

1  
static <A> PatchworkImage<A> patchworkBufferedImagesHorizontally(LPair<BufferedImage, A> imagesAndValues, O... _) {
2  
  if (empty(imagesAndValues)) null;
3  
  optPar int spacing = imageMergeSpacing();
4  
  var images = pairsA(imagesAndValues);
5  
  int w = intSum(mapMethod getWidth(images))+(l(images)-1)*spacing;
6  
  int h = intMax(mapMethod getHeight(images));
7  
  PatchworkImage<A> out = new(w, h);
8  
  int x = 0;
9  
  for (imageAndValue : imagesAndValues) {
10  
    BufferedImage img = imageAndValue.a;
11  
    int y = (h-img.getHeight())/2;
12  
    out.addPatch(img, x, y, imageAndValue.b);
13  
    x += img.getWidth() + spacing;
14  
  }
15  
  ret out;
16  
}

Author comment

Began life as a copy of #1024673

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036007
Snippet name: patchworkBufferedImagesHorizontally [with spacing]
Eternal ID of this version: #1036007/8
Text MD5: 3b1a294e80e2e9800da9f2679214450b
Transpilation MD5: 822d56f02d9c15df62a0ee6525a2115f
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-23 17:00:46
Source code size: 631 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 146 / 218
Version history: 7 change(s)
Referenced in: [show references]