如何得到当前的Image

freelauncher 2003-08-18 08:52:01
在public void paint(Graphics g)中我们可以用drawImage在屏幕上画画,
但时如何才能将当前屏幕的内容保存为一个Image变量呢?
...全文
42 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
MrYoucheng 2003-08-20
  • 打赏
  • 举报
回复
setClip
public void setClip(int x,
int y,
int width,
int height)Sets the current clip to the rectangle specified by the given coordinates. Rendering operations have no effect outside of the clipping area.
Parameters:
x - the x coordinate of the new clip rectangle
y - the y coordinate of the new clip rectangle
width - the width of the new clip rectangle
height - the height of the new clip rectangle
See Also:
clipRect(int, int, int, int)
liuyushen 2003-08-20
  • 打赏
  • 举报
回复
lsy110(毛毛) 写的不是J2ME,是J2SE
lsy110 2003-08-20
  • 打赏
  • 举报
回复
response.setContentType("image/jpeg;charset=GB2312");


JPEGImageEncoder encoder = null;
OutputStream os=null;
try
{

// use this statement to create a file to save the jpg.
FileOutputStream os=new FileOutputStream("e:/x01.jpg");
encoder = JPEGCodec.createJPEGEncoder(os);
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.drawLine(30,30,90,90);
encoder.encode(image);
os.flush();
os.close();

}
catch(Exception e)
{
out.println(e);
}

會保存當前圖像到指定的文件...
showming 2003-08-19
  • 打赏
  • 举报
回复
getImage();
shiqi80 2003-08-19
  • 打赏
  • 举报
回复
需要用 Image createImage(Image source) 将可变图象转换为不变图象
因为drawImage 画的是可变图象,要应用这个图象一般要转换为不变图象,参数source 是可变图象。你试试吧,书上应该有这样的例子

13,100

社区成员

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

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