Hallo,
ich möchte gerne ein Bild runterskalieren dass es aus dem Bildschirm nach innen verschwindet. Ich habe es bis jetzt nur geschafft, dass das bild von innen vom bildschirm kommt und eben raufskaliert wird bis es in voller Größe angezeigt wird. Weiß jemand wie ich die run-Methode bzw. die Berechnungen von x,y, w und h ändern muss um genau den umgekehrten Fall zu erreichen, also dass das Bild nach innen verschwindet?
danke im voraus
mfg
ich möchte gerne ein Bild runterskalieren dass es aus dem Bildschirm nach innen verschwindet. Ich habe es bis jetzt nur geschafft, dass das bild von innen vom bildschirm kommt und eben raufskaliert wird bis es in voller Größe angezeigt wird. Weiß jemand wie ich die run-Methode bzw. die Berechnungen von x,y, w und h ändern muss um genau den umgekehrten Fall zu erreichen, also dass das Bild nach innen verschwindet?
Code:
public class ImagePane extends JLabel implements Runnable
{
public void paintComponent( Graphics g )
{
super.paintComponent( g ); // should always call this method
if( theOldImage != null )
{
g.drawImage( theOldImage, 0, 0, width, height, null );
}
if( theNewImage != null )
{
g.drawImage( theNewImage, x, y, w, h, null );
}
}
private Image theOldImage;
private Image theNewImage;
private int x = 0;
private int y = 0;
private int w = 0;
private int h = 0;
private int width = 0;
private int height = 0;
// Need this method in order to load an image for display
public void setImage( Image i )
{
theOldImage = theNewImage;
theNewImage = i;
}
public void changeImage()
{
Thread t = new Thread( this );
t.start();
}
//expand outwards
public void run()
{
Dimension d = this.getSize();
width = d.width;
height = d.height;
x = width/2;
y = height/2;
w = 0;
h = 0;
double wInc = width/200;
double hInc = height/200;
do
{
x = (int)(x - wInc);
y = (int)(y - hInc);
w = (int)(w + 2*wInc);
h = (int)(h + 2*hInc);
this.repaint();
Thread.yield();
} while( x > 0 );
}
}
danke im voraus
mfg