java中如何画位图?

qq_pride 2005-11-24 12:02:14
有一个2维数组,里面存放的是像素信息,不知道java中有没有类可以根据2维数组创建位图?
...全文
273 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hjpwhp 2005-11-30
  • 打赏
  • 举报
回复
可以的 我正在弄这方面的问题 你可以通过文件读取 把数据读入内存图形源中 MemoryImageSource 然后把设置 rgb值 就上你数组中的像素值。然后
Memoryimagesource = new MemoryImageSource(width,height,model,pix,0,width);
image=createImage(memoryimagesource);
把图象显示出来
最后把参考如何保存为位图文件的方式
即 你要了解位图文件的头文件格式和信息
BMPFileHeader和BMPInfoHeader
最后
BMPCodec.createBMPEncoder(new FileOutputStream("C:\\house\\test.bmp")).encode(image);
就可以了
pdvv 2005-11-24
  • 打赏
  • 举报
回复
ImageIcon

public ImageIcon(byte[] imageData)

Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF or JPEG. Normally this array is created by reading an image using Class.getResourceAsStream(), but the byte array may also be statically stored in a class. If the resulting image has a "comment" property that is a string, then the string is used as the description of this icon.
lindenrty 2005-11-24
  • 打赏
  • 举报
回复
javax.imageio 中有圖片io操作類
嘗試下是否能把你的數據作爲數據流傳進某個操作類中
qq_pride 2005-11-24
  • 打赏
  • 举报
回复
java好像不支持bmp吧

62,629

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧