response.setCharacterEncoding("UTF-8"); response.setContentType("image/jpeg"); try { OutputStream out = response.getOutputStream(); byte[] bytes = *****;//获取图片字节数组 ByteArrayInputStream in = new ByteArrayInputStream(bytes); BufferedImage image = ImageIO.read(in); int h = image.getHeight(); int w=image.getWidth(); BufferedImage inputbig = new BufferedImage(w, h,BufferedImage.TYPE_INT_BGR); inputbig.getGraphics().drawImage(image, 0, 0, w, h, null); //画图 ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(baos); ImageIO.write(inputbig, "jpg", imageOutputStream); out.write(baos.toByteArray()); out.flush(); } catch (Exception e) { e.printStackTrace(); log.warn("e: " + e.getMessage()); }
后台获取图片
最新推荐文章于 2024-06-14 14:43:21 发布