il codice è questo
codice:
class MemoryImagePanel extends JPanel {
private Image img;
private MemoryImageSource mis;
private int w,h;
public MemoryImagePanel(int w, int h, int[] pix, int off, int scan) {
this.w =w;
this.h = h;
setPreferredSize(new Dimension(w,h));
DirectColorModel dcm=new DirectColorModel(24, 0x00FF0000, 0x0000FF00, 0x000000FF);
mis=new MemoryImageSource(w,h,dcm,pix,off,scan);
mis.setAnimated(true);
mis.setFullBufferUpdates(true);
img=createImage(mis);
}
// Overwrite imageUpdate
public boolean imageUpdate(Image image, int i1, int j1, int k, int i2, int j2) {
return true;
}
/** Draw the image on the panel. **/
public void paintComponent (Graphics g) {
mis.newPixels(0, 0, w, h);
g.drawImage(img, 0, 0, this);
}
}
ma non funziona, o meglio lo sfarfallio e gli strappi rimangono... forse non ho capito il double buffering?