0

Hello guys I have a problem in resizing the image in my java program here is the code:

import java.awt.*;
import java.applet.*;

public class sampleCaseStudy extends Applet {

    private Image MyImage;

    public void init()  {

        MyImage = getImage(getDocumentBase(), "manginasalmo.jpg");
       MyImage.getScaledInstance(700, 100, Image.SCALE_DEFAULT);
    }

    public void paint(Graphics g) {
        g.drawImage(MyImage, 0, 0, this);
    }
 }

the image displays but it doesnt change its size at all. Please help me with this

2
Contributors
1
Reply
8
Views
4 Years
Discussion Span
Last Post by bguild
0

The method getScaledInstance is much like almost all methods that start with get because the important part of calling it is the object that it returns. If you ignore the return value, the point of calling it is lost. The image you want isn't MyImage, it is the image returned from getScaledInstance.

Calling getScaledInstance doesn't change the size of the original image, it creates a new image with the requested size, or in other words, a scaled instance of the original image.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.