国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - Java教程 - Java實現(xiàn)圖片拼接

Java實現(xiàn)圖片拼接

2021-05-24 12:18Abel-Luan Java教程

這篇文章主要為大家詳細(xì)介紹了Java實現(xiàn)圖片拼接的相關(guān)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了java實現(xiàn)圖片拼接的具體代碼,供大家參考,具體內(nèi)容如下

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
 * 拼接圖片(注:圖片需長寬一致)
 * @param files  img1 ,img2
 * @param type  1:橫向拼接 2:縱向拼接
 * @param targetfile 合成新的圖片地址
 */
public static void mergeimage(string[] files, int type, string targetfile) {
 int len = files.length;
 if (len < 1) {
  throw new runtimeexception("圖片數(shù)量小于1");
 }
 file[] src = new file[len];
 bufferedimage[] images = new bufferedimage[len];
 int[][] imagearrays = new int[len][];
 for (int i = 0; i < len; i++) {
  try {
   src[i] = new file(files[i]);
   images[i] = imageio.read(src[i]);
  } catch (exception e) {
   throw new runtimeexception(e);
  }
  int width = images[i].getwidth();
  int height = images[i].getheight();
  imagearrays[i] = new int[width * height];
  imagearrays[i] = images[i].getrgb(0, 0, width, height, imagearrays[i], 0, width);
 }
 int newheight = 0;
 int newwidth = 0;
 for (int i = 0; i < images.length; i++) {
  // 橫向
  if (type == 1) {
   newheight = newheight > images[i].getheight() ? newheight : images[i].getheight();
   newwidth += images[i].getwidth();
  } else if (type == 2) {// 縱向
   newwidth = newwidth > images[i].getwidth() ? newwidth : images[i].getwidth();
   newheight += images[i].getheight();
  }
 }
 if (type == 1 && newwidth < 1) {
  return;
 }
 if (type == 2 && newheight < 1) {
  return;
 }
 // 生成新圖片
 try {
  bufferedimage imagenew = new bufferedimage(newwidth, newheight, bufferedimage.type_int_rgb);
  int height_i = 0;
  int width_i = 0;
  for (int i = 0; i < images.length; i++) {
   if (type == 1) {
    imagenew.setrgb(width_i, 0, images[i].getwidth(), newheight, imagearrays[i], 0,
      images[i].getwidth());
    width_i += images[i].getwidth();
   } else if (type == 2) {
    imagenew.setrgb(0, height_i, newwidth, images[i].getheight(), imagearrays[i], 0, newwidth);
    height_i += images[i].getheight();
   }
  }
  //輸出想要的圖片
  imageio.write(imagenew, targetfile.split("\\.")[1], new file(targetfile));
 } catch (exception e) {
  throw new runtimeexception(e);
 }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:https://blog.csdn.net/qq_38114563/article/details/81408417

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 久久久久久久久久久免费视频 | 亚洲三区在线观看 | 一级色视频 | 国产专区在线 | 免费午夜视频 | 亚洲免费观看视频 | 亚洲成人精品一区 | 日韩欧美专区 | 91在线精品一区二区三区 | 操操操干干| 欧美日韩精品免费观看 | 一区二区三区免费播放 | 国产综合久久 | 欧美一级在线观看 | 龙珠z国语291集普通话 | 美女搞黄网站 | 亚洲日韩中文字幕一区 | 国产精品成人av | 欧美成人高清视频 | 欧美一级网站 | 久久久久久高清 | 特级av| 日韩精品在线免费观看 | 日本一区二区免费在线播放 | 午夜不卡视频 | 久久久国产精品视频 | 一区免费看 | 成人日韩在线视频 | 久热精品在线视频 | 欧美日韩精品一区 | 精品视频网 | 狠狠草视频 | 国产在线a | 国产精品久久久久久久久小说 | 久久婷婷丁香 | 免费看国产 | 成人综合久久 | 成人黄大片视频在线观看 | 精品日韩一区二区 | 国产黄免费 | 欧美在线免费视频 |