请各位高手帮我个忙:一段代码,我已经实现在applet查看器中点击按钮存储图片,但是不能在网页中点击applet中的按钮存储,请问怎样编写才能将applet的图片存到服务器或者本地。(除了数字签名这个麻烦的方法还有什么方法)public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
FrameGrabbingControl fgc=(FrameGrabbingControl)player.getControl("javax.media.control.FrameGrabbingControl");
buffer=fgc.grabFrame();
bufferToImage=new BufferToImage((VideoFormat)buffer.getFormat());
image=bufferToImage.createImage(buffer);
imagePanel=new ImagePanel();
imagePanel.setImage(image);
String path = getClass().getProtectionDomain().getCodeSource()
.getLocation().getPath()+"/a/aa.jpg";
System.out.println(path);
saveImage(image,path);
}
public static void saveImage(Image image,String path)
{
BufferedImage bi=new BufferedImage(image.getWidth(null),image.getHeight(null),BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = bi.createGraphics();
g2.drawImage(image, null, null);
FileOutputStream fos=null;
try {
fos=new FileOutputStream(path);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JPEGImageEncoder je=JPEGCodec.createJPEGEncoder(fos);
JPEGEncodeParam jp=je.getDefaultJPEGEncodeParam(bi);
jp.setQuality(1.0f, false);
je.setJPEGEncodeParam(jp);
try {
je.encode(bi);
fos.close();
} catch (ImageFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// TODO Auto-generated method stub
FrameGrabbingControl fgc=(FrameGrabbingControl)player.getControl("javax.media.control.FrameGrabbingControl");
buffer=fgc.grabFrame();
bufferToImage=new BufferToImage((VideoFormat)buffer.getFormat());
image=bufferToImage.createImage(buffer);
imagePanel=new ImagePanel();
imagePanel.setImage(image);
String path = getClass().getProtectionDomain().getCodeSource()
.getLocation().getPath()+"/a/aa.jpg";
System.out.println(path);
saveImage(image,path);
}
public static void saveImage(Image image,String path)
{
BufferedImage bi=new BufferedImage(image.getWidth(null),image.getHeight(null),BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = bi.createGraphics();
g2.drawImage(image, null, null);
FileOutputStream fos=null;
try {
fos=new FileOutputStream(path);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JPEGImageEncoder je=JPEGCodec.createJPEGEncoder(fos);
JPEGEncodeParam jp=je.getDefaultJPEGEncodeParam(bi);
jp.setQuality(1.0f, false);
je.setJPEGEncodeParam(jp);
try {
je.encode(bi);
fos.close();
} catch (ImageFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
楼主截止到2008-06-19 13:03:08的汇总数据:
注册日期:2007-6-9
上次登录:2008-6-18
发帖数:7
结贴数:4
结贴率:57.14%
楼主加油