zoukankan      html  css  js  c++  java
  • 小弟的程序有点问题 请高手帮忙改一下

    问题是 : 图片从数据库中拿出来有时显示正常(偶尔) 有时显示是黑的

    代码段:

     private String newstr="";
     private Image image;
     private Icon icon;
     private byte bimage[];

    。。。。

    if (imageResult.next())
         {
           bimage=imageResult.getBytes("image");
                       image=Toolkit.getDefaultToolkit().createImage(bimage);
                       newstr = "C://Documents and Settings//All Users//Templates//newimage.jpg";
                       BufferedImage tag = new BufferedImage(190, 130,BufferedImage.TYPE_INT_RGB);
           tag.getGraphics().drawImage(image, 0, 0, 190, 130, null); // 绘制缩小后的图
           FileOutputStream out = new FileOutputStream(newstr); // 输出到文件流
           JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
           encoder.encode(tag); // 近JPEG编码
          System.out.println(bimage);
          System.out.println(image);
          System.out.println(newstr);
          System.out.println(tag);
          System.out.println(encoder);
           icon= new ImageIcon( newstr);
           pictureLabel.setIcon(icon);
           out.close();
          } 

  • 相关阅读:
    http工作流程
    HTTP的响应码?
    原型链
    ubuntu查看IO
    ubuntu14.04 64位 安装H3C iNode客户端
    关于ubuntu14.04LTS 64位 播放优酷视频
    python 的字符串驻留机制
    【转】使用virtualenv在ubuntu上搭建python 3开发环境
    ubuntu14.04 python2.7 安装配置OpenCV3.0
    记录两个折磨了我三天的低级错误
  • 原文地址:https://www.cnblogs.com/wmlunge/p/2299289.html
Copyright © 2011-2022 走看看