import java.awt.*; import java.awt.image.*; public class CPuzzleElement extends Canvas { private Merkmale.... public CPuzzleElement(Image _img) { Initialisierung ... makeImages(); ArrayPointer auf null setzen (Speicher freigeben)... } protected void grab(Image img, int pix[]) // Image in Array umwandeln { PixelGrabber grabber = new PixelGrabber(img, 0, 0,m_width, m_height, pix, 0, m_width); try { grabber.grabPixels(); } catch (InterruptedException e) { System.err.println("Error: "+e); } } protected Image doImage(int[] pix) // Array in Image umwandeln { return createImage(new MemoryImageSource(m_width, m_height,pix, 0, m_width)); } protected void makeImages() { grab(m_Element[0], m_OldImageArray); int k = 0; for(int i = 0; i < m_width; i++) { for(int j = m_height-1; j > -1; j--) { m_NewImageArray1[k] = m_OldImageArray[j*m_width +i]; m_NewImageArray2[(m_height-j-1)*m_width + (m_width-i-1)] = m_OldImageArray[j*m_width +i]; m_NewImageArray3[(m_width*m_height-1)-k++] = m_OldImageArray[j*m_width +i]; } } m_Element[1] = doImage(m_NewImageArray1); m_Element[2] = doImage(m_NewImageArray2); m_Element[3] = doImage(m_NewImageArray3); } public Image getElement(int i) { return m_Element[i]; } }