知道了每个象素(pixel)的值
放在byte[] data中要生成一个JPEG的文件到硬盘
怎么做啊?这个问题有点烦啊
放在byte[] data中要生成一个JPEG的文件到硬盘
怎么做啊?这个问题有点烦啊
解决方案 »
- 一道普通的题,我觉得你会做错,不信来试试
- 谁能帮我把这个程序分一下
- java数组题
- 放弃j2ee从事j2me手游开发是否值得?
- 弄了好久就是不知道哪有问题 无效的游标状态
- 运行在两个TOMCAT的两套程序怎样通信?
- 50分打听:java有没有解析SQL的包(第三方开发的也好)??我要通过解析SQL语句来处理数据库的数据
- 初学小问题
- 请问: private Calendar t; //什么类型的数据?
- 我用批处理文件设置系统变量,为什么编译时找不到JAVAC???
- 请问哪儿可以找到ibm jdk 1.3.1 for windows啊?
- Java里面怎么格式化Double变量为保留小数点后二位小数呀
ObjectOutputStream o = new ObjectOutputStream( new FileOutputStream("free.jpeg"));
o.writeObject(Object obj);
o.close();
------------------------------------------------------------------------------
一天四个包子,我的生活!
--罗毅
.... try {
FileOutputStream fileOut = new FileOutputStream(file);
BufferedOutputStream bufOut = new BufferedOutputStream(fileOut);
JPEGImageEncoder encoderJpeg = JPEGCodec.createJPEGEncoder(bufOut);
encoderJpeg.encode(JYMO_IMAGE);
bufOut.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}
放在byte[] data中可是我这个data是纯数据的啊
放在byte[] data中可是我这个data是纯数据的啊
要不
new BufferedImage后,使用setRGB将数据写入图像
最后使用ImageIO进行输出
File f = new File("capture.jpeg");
try {
javax.imageio.ImageIO.write(offScreenImage, "jpeg", f);
}
catch (IOException ex) {
}
byte[]data = {71,73,70,56,57,97,30,1,...,-77,-128,0,0,59};
createJpg(data);void createJpg(byte[]data)throws Exception{
DataInputStream fileReader = new DataInputStream(new ByteArrayInputStream(data));
DataOutputStream out = null;
try{
byte[] chrBuffer = new byte[4096]; //缓冲
File outfile = new File("c:\\outTest.jpg");
out = new DataOutputStream(new FileOutputStream(outfile));
int tmpLen ;
while((tmpLen =fileReader.read(chrBuffer))!= -1){
out.write(chrBuffer,0,tmpLen) ;
}
} catch (Exception e){
System.out.println(e);
} finally {
fileReader.close() ;
out.flush();
out.close();
}
}
因为data本来是一个纯数据的数组啊 lEFTmOON(我喜欢的MM可以不漂亮,但应该有沟有气质……)
兄弟,能不能详细点呢?
* 按JPEG图像编码到输出流
* @param out - 输出流
* @param quality - 质量比
* @param image - 图形光栅
* @throws IOException
*/
public static void writeBufferedImageAsJPEG(OutputStream out, float quality,
BufferedImage image) throws
IOException {
if (out == null)
throw new IllegalArgumentException(Null_Out_Argument );
if (image == null) {
throw new IllegalArgumentException(Null_Image_Argument );
}
else {
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(image);
param.setQuality(quality, true);
encoder.encode(image, param);
return;
}
}
这个怎么定位?
就是怎么把每个c写入相应的位置,没有找到这个定位的函数阿!//(当然也有更快的方法,就是arraycopy到光栅数组)这个怎么实现?愿闻其详
我使用g.drawLine(x,y,x,y);
定位画(x,y);这个点的//(当然也有更快的方法,就是arraycopy到光栅数组)这个怎么实现?还是不懂