曾经遇到这个问题在网上也搜了好久,但是依然没有答案,后来在仔细看过源代码之后,这个问题我已经解决了,源代码里有这样两个方法
scalePercent(float percent)
//介绍 Scale the image to a certain percentage.
scalePercent(float percentX, float percentY)
//介绍 Scale the width and height of an image to a certain percentage.
这两个方法意思是将图片按照一定的比例调整,都没有返回值
用这两个方法可以实现图片的放大和缩小,例如:
Image png= Image.getInstance(imgName);
png.scalePercent(68.8f);
scalePercent(float percent)
//介绍 Scale the image to a certain percentage.
scalePercent(float percentX, float percentY)
//介绍 Scale the width and height of an image to a certain percentage.
这两个方法意思是将图片按照一定的比例调整,都没有返回值
用这两个方法可以实现图片的放大和缩小,例如:
Image png= Image.getInstance(imgName);
png.scalePercent(68.8f);
可以将图片的整体(长和宽)缩小至原来的68.8%
至于第二个方法,我还没有测试,大致分析一下,就是单项的调整高或者宽的比例,希望能帮助到大家。
如果有什么疑问联系QQ421015203,大家一起交流学习。