11-15-2009 09:45 AM
i found the code but same does not work it does nothing images set as original width height
byte[] dataArray = data.getBytes();
bitmap = EncodedImage.createEncodedImage(dataArray, 0,
dataArray.length);
System.err.println( bitmap.getLength()+" "+bitmap.getWidth());
bitmap = resizeImage( bitmap, 150,150);
System.err.println( bitmap.getLength()+" "+bitmap.getWidth());
setImage(bitmap);
private static EncodedImage resizeImage(EncodedImage image, int width, int height) {
if (image == null) {
return image;
}
//return if image does not need a resizing
if (image.getWidth() <= width && image.getHeight() <= height) {
return image;
}
double scaleHeight, scaleWidth;
if (image.getWidth() > width && image.getHeight() > height) { //actual image is bigger than scale size
if (image.getWidth() > image.getHeight()) { //actual image width is more that height then scale with width
scaleWidth = width;
scaleHeight = (double)width / image.getWidth() * image.getHeight();
} else { //scale with height
scaleHeight = height;
scaleWidth = (double)height / image.getHeight() * image.getWidth();
}
} else if (width < image.getWidth()) { //scale with scale width or height
scaleWidth = width;
scaleHeight = (double)width / image.getWidth() * image.getHeight();
} else {
scaleHeight = height;
scaleWidth = (double)height / image.getHeight() * image.getWidth();
}
int w = Fixed32.div(Fixed32.toFP(image.getWidth()), Fixed32.toFP((int)scaleWidth));
int h = Fixed32.div(Fixed32.toFP(image.getHeight()), Fixed32.toFP((int)scaleHeight));
return image.scaleImage32(w, h);
}tks in advance
r.soler
11-18-2009 01:53 PM
I haven't tried your code, but I know this one does work.
01-27-2011 11:49 PM
http://sanjeewamalalgoda.blogspot.com/2011/01/how-
This will help you to solve your problem
01-28-2011 12:24 AM
?
@sanjeewa190: I don't believe that has anything to do with this post.
01-28-2011 01:11 AM
http://sanjeewamalalgoda.blogspot.com/2010/12/zoom
This post shows resizing image to given factor and later post about encoded image