This site requires JavaScript, please enable it in your browser!
Greenfoot back
Omniscience
Omniscience wrote ...

2012/2/7

Scaling .png files

Omniscience Omniscience

2012/2/7

#
I've been playing around with the method scale to give the illusion that some trees in the scenery (.png files) were getting closer to the driver. However, the method seems to only enlarge the centre of the tree, whilst the peripherals of the shape just stretch around the central bulge in the tree. The problem has occurred through all images that I have used whilst using scale and I'm pretty sure that the code I've written is syntactically correct. If needs be, I will post the code that implements this method. Any help in rectifying this error would be great!
danpost danpost

2012/2/7

#
Do not re-scale a scaled image. Recall the original image and scale it to the new settings.
Omniscience Omniscience

2012/2/7

#
I used an image from the Greenfoot picture gallery: "tree", which I then shrunk down whilst awaiting to be scaled, to fit the perspective (the tree is in the distance). If I can't shrink it down and then scale up again, what do you advise I do? (code or pseudo code illustration would be great!) oh, and by the way, thanks for the reply! : )
danpost danpost

2012/2/7

#
I can think of two options, off hand. 1) Go back to the gallery and download the image (without shrinking it); use that as your saved image in your project (which can be scaled appropriately for when you add it to the world). 2) If you have a snipping tool (a program to capture an area of your screens display), you can then save the initial image (as you want it to be) as the default in your images directory of your project.
davmac davmac

2012/2/7

#
If I can't shrink it down and then scale up again, what do you advise I do? (code or pseudo code illustration would be great!)
Scale it down from the original size instead! So, when the tree first appears in the distance, take the original image (large) and scale it right down. Then, as the tree gets closer, take the original image again (not the scaled one) and scale it to the desired size. And so on.
danpost danpost

2012/2/8

#
Do not get the image with the actor's 'getImage()' method. Instead, use the GreenfootImage constructor that uses the filename of the image.
Omniscience Omniscience

2012/2/13

#
Thanks danpost and davmac! You guys really helped me out with my coursework! Look forward to hearing from you again!
You need to login to post a reply.