public static Bitmap getScaledBitmapImage(String imagename,int wd,int ht)
{
EncodedImage image = EncodedImage.getEncodedImageResource(imagename);
if(image.getWidth()==wd &&
image.getHeight()==ht)
return image.getBitmap();
int currentWidthFixed32 = Fixed32.toFP(image.getWidth());
int currentHeightFixed32 = Fixed32.toFP(image.getHeight());
int width = wd;
if(width == -1)
width=image.getWidth();
int height = ht;
if(height == -1)
height=image.getHeight();
int requiredWidthFixed32 = Fixed32.toFP(width);
int requiredHeightFixed32 = Fixed32.toFP(height);
int scaleXFixed32 = Fixed32.div(currentWidthFixed32,
requiredWidthFixed32);
int scaleYFixed32 = Fixed32.div(currentHeightFixed32,
requiredHeightFixed32);
image =
image.scaleImage32(scaleXFixed32, scaleYFixed32);
return image.getBitmap();
}
No comments:
Post a Comment