Topic: 动态GIF在paint中如何显示问题 |
Print this page |
1.动态GIF在paint中如何显示问题 | Copy to clipboard |
Posted by: dawnson Posted on: 2005-11-18 10:33 自己写的一个类中需要显示动态GIF,在Applet中加入该类后,图片只显示了一帧,Applet中放大缩小时,图片会显示其他一帧,请问,这种问题如何解决。 谢谢! |
2.Re:动态GIF在paint中如何显示问题 [Re: dawnson] | Copy to clipboard |
Posted by: Duncan Posted on: 2005-11-22 11:30 dawnson wrote: 你在繪製由動態 GIF 建構而成的 Image object 時要給定正確的 ImageObserver(Component 本身就是 ImageObserver),gif Image object 會持續發出 imageUpdate notification 給 observer 通知有新的 frame,而促使元件重繪。 簡單的例子,你以一張 gif image 建構下列元件放到 applet 裡,動畫會正確運作。\n
|
3.Re:动态GIF在paint中如何显示问题 [Re: dawnson] | Copy to clipboard |
Posted by: sizhiguo Posted on: 2005-11-29 15:51 我的源代码: 你看一下 import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import javax.swing.JLabel; public class ImageLabel extends JLabel implements Runnable { /** * */ private static final long serialVersionUID = 1L; public Image images = null; Thread thread; public ImageLabel() { thread = new Thread(this); thread.start(); } public void setImage(Image buf) { this.images = buf; } public void paint(Graphics g) { super.paint; Graphics2D g2 = (Graphics2D) g; if (images != null) { g2.drawImage(images, 0, 0, getWidth(), getHeight(), 0, 0, images.getWidth(null), images .getHeight(null), null); } } public void run() { while (true) { this.repaint(); try { Thread.sleep(100); } catch (Exception e) { e.printStackTrace(); } } } public void update(Graphics g) { paint; } } 只用把这个jlable放到某个位置然后加上 Image image2 = Toolkit.getDefaultToolkit().getImage(f.getAbsolutePath()); picArea.setImage(image2); |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |