This site requires JavaScript, please enable it in your browser!
Greenfoot back
rachpaguia@gmail.com
rachpaguia@gmail.com wrote ...

2017/3/12

RESIZE IMAGE

Hi! I tried out this code and my image still doesn't wanna be smaller! what can i do? GreenfootImage image = getImage(); image.scale(image.getWidth() - 150, image.getHeight() - 150); setImage(image);
danpost danpost

2017/3/12

#
After the first line above, insert the following and run the program. Report back result:
1
System.out.println("Width: "+image.getWidth()+"\nHeight: "+image.getHeight());
If you do not get any output on your terminal window, then show where you placed the given code (show the entire method -- or class, which would be more informative).
Timon Timon

2017/3/12

#
You musn´t write -150 you must say a smaller note than Image is. e.g. your Image is 100 you write: Image.scale(Image.getWidht() 50,image.getHeight() 50); now you have the half of your Image(from 100x100 to 50x50)
Super_Hippo Super_Hippo

2017/3/12

#
@Timon: This would never compile. If you want it to resize to 50x50 (no matter what it was before), it is just
1
image.scale(50, 50);
If you want your image to be 150 less in width and height, it is in fact
1
image.scale(image.getWidth()-150, image.getHeight()-150);
You can also half the width and height by using
1
image.scale(image.getWidth()/2, image.getHeight()/2);
But there is no way ever that you just write two numbers with a space in between in your code.
Nosson1459 Nosson1459

2017/3/12

#
rachpaguia@gmail.com wrote...
1
2
3
GreenfootImage image = getImage();
image.scale(image.getWidth() - 150, image.getHeight() - 150);
setImage(image);
This code should work as is that's why...
danpost wrote...
After the first line above, insert the following and run the program. Report back result:
1
System.out.println("Width: "+image.getWidth()+"\nHeight: "+image.getHeight());
If you do not get any output on your terminal window, then show where you placed the given code (show the entire method -- or class, which would be more informative).
Hi, sorry I got a bit confused with the many replies (still thankful though)! I tried this and nothing has changed GreenfootImage image = getImage(); System.out.println("Width: "+image.getWidth()+"\nHeight: "+image.getHeight()); image.scale(50, 50); setImage(image);
danpost danpost

2017/3/13

#
You probably do not have a call to the method that the given code resides in. Show the entire class that the given code is in. Use code tags (see 'Posting code? read this!' below the reply box.
I FINALLY DID IT!!! THANK YOU ALL SO MUCH FOR YOUR HELP
You need to login to post a reply.