這篇文章主要講解了“java怎么導(dǎo)出圖片并將其拼接到一個(gè)圖片文件”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“java怎么導(dǎo)出圖片并將其拼接到一個(gè)圖片文件”吧!

public static void test2() {
try {
// 讀取第一張圖片
// File fileOne = new File("D:qq.jpg");
// BufferedImage ImageOne = ImageIO.read(fileOne);
// int width = ImageOne.getWidth();//圖片寬度
// int height = ImageOne.getHeight();//圖片高度
// 對(duì)第二張圖片做相同的處理
File fileTwo = new File("D:qq.jpg");
BufferedImage ImageTwo = ImageIO.read(fileTwo);
int width = ImageTwo.getWidth();// 圖片寬度
int height = ImageTwo.getHeight();// 圖片高度
int height2 = 20;
BufferedImage ImageOne = new BufferedImage(width, height2,
BufferedImage.TYPE_4BYTE_ABGR);
// ImageOne.get
Graphics g = ImageOne.getGraphics();//
g.fillRect(0, 0, width, height);
g.setColor(Color.blue);
Font mFont = new Font("宋體", Font.PLAIN, 12);
g.setFont(mFont);
String text = "添加文字測(cè)試";
g.drawString(text, 0, 10);
// 從圖片中讀取RGB
int[] ImageArrayOne = new int[width * height2];
ImageArrayOne = ImageOne.getRGB(0, 0, width, height2,
ImageArrayOne, 0, width);
int[] ImageArrayTwo = new int[width * height];
ImageArrayTwo = ImageTwo.getRGB(0, 0, width, height, ImageArrayTwo,
0, width);
// 生成新圖片
BufferedImage ImageNew = new BufferedImage(width, height + height2,
BufferedImage.TYPE_INT_RGB);
ImageNew.setRGB(0, 0, width, height2, ImageArrayOne, 0, width);// 設(shè)置上半部分的RGB
// ImageNew.setRGB(width,0,width,height,ImageArrayTwo,0,width);//設(shè)置右半部分的RGB
ImageNew.setRGB(0, height2, width, height, ImageArrayTwo, 0, width);// 設(shè)置下半部分的RGB
File outFile = new File("d:qq2.jpg");
ImageIO.write(ImageNew, "jpg", outFile);// 寫圖片
} catch (Exception e) {
e.printStackTrace();
}
}
感謝各位的閱讀,以上就是“java怎么導(dǎo)出圖片并將其拼接到一個(gè)圖片文件”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)java怎么導(dǎo)出圖片并將其拼接到一個(gè)圖片文件這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
分享文章:java怎么導(dǎo)出圖片并將其拼接到一個(gè)圖片文件-創(chuàng)新互聯(lián)
文章URL:http://chinadenli.net/article8/cocsop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站建設(shè)、定制開發(fā)、標(biāo)簽優(yōu)化、做網(wǎng)站、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容