In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "java how to export a picture and splice it to a picture file", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "java how to export a picture and splice it into a picture file"!
Public static void test2 () {
Try {
/ / read the first picture
/ / File fileOne = new File ("D:qq.jpg")
/ / BufferedImage ImageOne = ImageIO.read (fileOne)
/ / int width = ImageOne.getWidth (); / / Picture width
/ / int height = ImageOne.getHeight (); / / Picture height
/ / do the same for the second picture
File fileTwo = new File ("D:qq.jpg")
BufferedImage ImageTwo = ImageIO.read (fileTwo)
Int width = ImageTwo.getWidth (); / / Picture width
Int height = ImageTwo.getHeight (); / / Picture height
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 (Song style, Font.PLAIN, 12)
G.setFont (mFont)
String text = "add text test"
G.drawString (text, 0,10)
/ / read RGB from the picture
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)
/ / generate a new picture
BufferedImage ImageNew = new BufferedImage (width, height + height2
BufferedImage.TYPE_INT_RGB)
ImageNew.setRGB (0, 0, width, height2, ImageArrayOne, 0, width); / / set the RGB of the upper part
/ / ImageNew.setRGB (width,0,width,height,ImageArrayTwo,0,width); / / set the RGB in the right half
ImageNew.setRGB (0, height2, width, height, ImageArrayTwo, 0, width); / / set the RGB of the lower part
File outFile = new File ("d:qq2.jpg")
ImageIO.write (ImageNew, "jpg", outFile); / / write pictures
} catch (Exception e) {
E.printStackTrace ()
}
}
Thank you for your reading, the above is the content of "java how to export a picture and splice it to a picture file". After the study of this article, I believe you have a deeper understanding of how java exports a picture and splice it to a picture file, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.