如题,需要用代码生成透明小图片在页面上显示,但又不能让用户看到图片。
哪位知道麻烦把代码放出,谢谢。

解决方案 »

  1.   

    生成图片的代码如下:
    public void genP() throws IOException{
    BufferedImage image = new BufferedImage(1,1,BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = image.createGraphics();

    image = g2d.getDeviceConfiguration().createCompatibleImage(1, 1,Transparency.TRANSLUCENT);
    g2d.dispose();
    g2d = image.createGraphics();

    g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.0f));
    g2d.setColor(new Color(0,0,0));
    g2d.setStroke(new BasicStroke(1));
    g2d.draw(new Line2D.Double(0, 0, 0, 0));
    g2d.dispose();
    ImageIO.write(image, "jpg", new File("E:/p003_1.jpg"));
    }生成的图片在页面上显示X,属性类型显示不可用,不知道什么原因