当前位置: 首页 > news >正文

学做网站有前长春网站seo

学做网站有前,长春网站seo,网站网站制作价格建站网站,找不到网页文章目录 【Java】Java 使用 Graphics2D 在图片上添加文字,并解决图片变红问题完整案例 【Java】Java 使用 Graphics2D 在图片上添加文字,并解决图片变红问题 完整案例 public static void main(String[] args) {try {String filePath "D:\\Works…

文章目录

  • 【Java】Java 使用 Graphics2D 在图片上添加文字,并解决图片变红问题
    • 完整案例

【Java】Java 使用 Graphics2D 在图片上添加文字,并解决图片变红问题

完整案例

    public static void main(String[] args) {try {String filePath = "D:\\Workspace\\XunshuWorkspace\\engage\\engage-service\\uploadPath\\upload\\template\\register-certificate.jpg";Image src = Toolkit.getDefaultToolkit().getImage(filePath);BufferedImage image = BufferedImageBuilder.toBufferedImage(src);Graphics2D g = image.createGraphics();Font font = new Font("宋体", Font.BOLD, 80);g.setFont(font);g.setColor(Color.black);g.drawString("张三", 500, 950);g.drawString("522323199812345678", 1750, 950);String date = "2024-03-01";String end = "2024-03-11";g.drawString(date.substring(0, 4), 550, 1150);g.drawString(date.substring(5, 7), 950, 1150);g.drawString(date.substring(8, 10), 1250, 1150);g.drawString(end.substring(0, 4), 1650, 1150);g.drawString(end.substring(5, 7), 2000, 1150);g.drawString(end.substring(8, 10), 2350, 1150);g.drawString("耳鼻咽喉头颈外科", 1000, 1350);long day = DateUtil.betweenDay(DateUtil.parse(date), DateUtil.parse(end), true);g.drawString(String.valueOf(day), 2800, 1350);String currentDate = DateUtil.today();g.drawString(currentDate.substring(0, 4), 2320, 2100);g.drawString(currentDate.substring(5, 7), 2660, 2100);g.drawString(currentDate.substring(8, 10), 2900, 2100);g.dispose();// ServletOutputStream outputStream = ServletUtils.getResponse().getOutputStream();File output = new File(filePath.replace(".jpg", "-" + UUID.randomUUID() + ".jpg"));ImageIO.write(image, "jpg", output);} catch (IOException e) {throw new RuntimeException(e);}}/*** 使用 ImageIO.read(file); 压缩后的图片会变红改为使用* Toolkit.getDefaultToolkit().getImage*/public static class BufferedImageBuilder {public static BufferedImage toBufferedImage(Image image) {if (image instanceof BufferedImage) {return (BufferedImage) image;}// This code ensures that all the pixels in the image are loadedimage = new ImageIcon(image).getImage();BufferedImage bimage = null;GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();try {int transparency = Transparency.OPAQUE;GraphicsDevice gs = ge.getDefaultScreenDevice();GraphicsConfiguration gc = gs.getDefaultConfiguration();bimage = gc.createCompatibleImage(image.getWidth(null),image.getHeight(null), transparency);} catch (HeadlessException e) {// The system does not have a screen}if (bimage == null) {// Create a buffered image using the default color modelint type = BufferedImage.TYPE_INT_RGB;bimage = new BufferedImage(image.getWidth(null),image.getHeight(null), type);}// Copy image to buffered imageGraphics g = bimage.createGraphics();// Paint the image onto the buffered imageg.drawImage(image, 0, 0, null);g.dispose();return bimage;}}
http://www.zhongyajixie.com/news/24144.html

相关文章:

  • 如何提高 网站的点击量电脑系统优化工具
  • 网站背景尺寸石家庄seo全网营销
  • 济南网站建设平台官网广州seo运营
  • wordpress编辑网站百度搜索关键词优化
  • 酒泉网站建设公司小红书推广运营
  • 做网站多少钱 优帮云营销型网站建设排名
  • 做网站建设的一般在哪儿找seo收费标准多少
  • 环保网站建设说明互联网
  • 沧州建设网站公司手机百度正式版
  • 网络策划公司官方正版清理优化工具
  • 医院关于建设官方网站的请示做网站用什么软件
  • 深圳宝安房价seo零基础视频教程
  • 徐州市鼓楼区建设局网站第三方网络营销平台有哪些
  • 许昌网站建设汉狮套餐推广平台有哪些渠道
  • 哪个网站开发是按月付费的成功的网络营销案例及分析
  • 大型企业名录查询seo网站优化方案书
  • 做网站很挣多少钱朝阳区搜索优化seosem
  • 网站建设和网站开发的区别电商运营培训课程有哪些
  • 网站挂黑链百度官网网站首页
  • 重庆网站建设网络推广关键词吉他谱
  • 安徽疫情最新消息情况网站seo外包价格
  • 一站式做网站哪家强网站提交
  • 兰州网站的优化长沙seo免费诊断
  • 长安网站建设哪家好百度投诉中心24人工
  • 公司做彩票网站违法吗网络热词英语
  • 世纪佳缘网站模板企业建站
  • 广安哪里做网站关键词排名优化顾问
  • 西安网站开发培训多少钱移动端优化
  • 设计一个网站代码seo网络推广公司报价
  • 赤水网站建设seo如何优化关键词上首页