- 1.如何从BufferedImage对象中获取InputStream对象
- public InputStream getImageStream(String layerName,List<Color> colors,String[] pixels){
- InputStream is = null;
- BufferedImage bi = createImage(layerName, colors, pixels);
- bi.flush();
- ByteArrayOutputStream bs = new ByteArrayOutputStream();
- ImageOutputStream imOut;
- try {
- imOut = ImageIO.createImageOutputStream(bs);
- ImageIO.write(bi, "png",imOut);
- is= new ByteArrayInputStream(bs.toByteArray());
- } catch (IOException e) {
- e.printStackTrace();
- }
- return is;
- }
转载于:https://blog.51cto.com/shpshao/647529