【问题标题】:Reading an Image and Copying it on a predefined directory读取图像并将其复制到预定义目录
【发布时间】:2014-10-01 19:49:09
【问题描述】:

我一直在尝试将图像保存在我的包目录中,但我遇到了一个我不知道如何解决的问题,这是我的代码:

BufferedImage   bufim = new BufferedImage(500, 600,   BufferedImage.TYPE_INT_RGB );
String dof = "C:/myimage.jpg";
File  file = new File( dof );
String myimageFormat = "jpg";
ImageIO.write( bufim , myimageFormat,  file );

所以这会创建文件,但我得到了这个:

而不是这个:这是原始图像。

我的理论是它与:

BufferedImage   bufim = new BufferedImage(500, 600,   >>> THIS <<<  );
                                                  which is int imageType

【问题讨论】:

  • 您的 BufferedImage 对象没有在您的代码 sn-p 中使用?你的“image”和“myImageFormat”对象在哪里?
  • 您创建了一个全新的 500x600 RGB 图像。然后你把它写到文件中。为什么您希望图像不是默认的全黑像素?
  • @Arkadiy,谢谢你意识到我的错误。

标签: java image io


【解决方案1】:

所以我的问题是我忘记分配bufim = ImageIO.read(incommingFileDirectory);,以便bufim 可以拥有我想要的Image。

【讨论】:

    猜你喜欢
    • 2012-10-12
    • 2011-06-16
    • 1970-01-01
    • 2015-04-08
    • 1970-01-01
    • 1970-01-01
    • 2013-10-14
    • 2011-09-25
    • 1970-01-01
    相关资源
    最近更新 更多