如何实现把文字和图片合成一张图片计划

2021-08-24 合山装修公司

如何实现把文字和图片合成一张图片比如我现在 要把我这个字和一张图片放到一起组成一张新图,应该怎么实现阿

比如我现在要把我这个字和一张图片放到一起组成一张新图,应该怎么实现?

Java code import t.*; import ent.*; import .*; import age.*; import m.*; import eg.*; import ageio.*; public class ImgBean{ public void ImgBean(){} public void ImgYin(String s,String ImgName){ try{ File _file = new File(ImgName); Image src = ad(_file); int wideth=tWidth(null); int height=tHeight(null); BufferedImage image=new BufferedImage(wideth,height,PE_INT_RGB); Graphics g=eateGraphics(); awImage(src,0,0,wideth,height,null); String s=\"我要加的水印\"; tColor(D); tFont(new Font(\"宋体\",AIN,20)); Font aa=new Font(\"宋体\",AIN,20); awString(s,wideth-150,height-10); spose(); FileOutputStream out=new FileOutputStream(ImgName); JPEGImageEncoder encoder = eateJPEGEncoder(out); code(image); ose(); } catch(Exception e){ intln(e); } } }

我改了下,字体颜色再改改,换张图,调调字的位置就可以了.

既要“外部牵引” Java code /* * To change this template, choose Tools | Templates * and open the template in the editor. */package test1;/** * * @author ilrxx */import t.*; import .*; import age.*; import eg.*; import ageio.*; public class ImgBean{ public void ImgBean(){} public static void ImgYin(String s,String ImgName){ byte[] bytes = null; try{ String str = s; File _file = new File(ImgName); Image src = ad(_file); int wideth=tWidth(null); int height=tHeight(null); BufferedImage image=new BufferedImage(wideth,height,PE_INT_RGB); Graphics g=eateGraphics(); awImage(src,0,0,wideth,height,null); tColor(D); tFont(new Font(\"宋体\",AIN,20)); Font aa=new Font(\"宋体\",AIN,20); awString(str,wideth-150,height-10); spose(); ByteArrayOutputStream out1 = new ByteArrayOutputStream(); saveImage(image, out1); bytes = ByteArray(); ose(); FileOutputStream out2 = new FileOutputStream(ImgName); ite(bytes); ose(); } catch(Exception e){ intln(e); } } public static void saveImage(BufferedImage img, OutputStream out1) throws Exception { JPEGImageEncoder encoder = eateJPEGEncoder(out1); code(img);}public static void main(String[] args){ ImgYin(\"我要加的水印\" , \"d:/g\");}}

西安看妇科专科医院
人工泪液可以缓解视疲劳吗
达霏欣米诺地尔搽剂2%
为你推荐