BlackBerry - How to Resize and Save Image?

Do I need to scale an image to small and store that image on my Blackberry device (as a small image)?

+2


a source to share


2 answers


scaling an image is easy enough if the image is packed or even captured over a network or file system.

public EncodedImage scaleImage(EncodedImage source, int requiredWidth, int requiredHeight) {  
  int currentWidthFixed32 = Fixed32.toFP(source.getWidth());  
  int requiredWidthFixed32 = Fixed32.toFP(requiredWidth);  
  int scaleXFixed32 = Fixed32.div(currentWidthFixed32, requiredWidthFixed32);  
  int currentHeightFixed32 = Fixed32.toFP(source.getHeight());  
  int requiredHeightFixed32 = Fixed32.toFP(requiredHeight);  
  int scaleYFixed32 = Fixed32.div(currentHeightFixed32, requiredHeightFixed32);  
  return source.scaleImage32(scaleXFixed32, scaleYFixed32);  
}  

      



returns a copy of the image, scaled to fit the width and height you need.

+3


a source


0


a source







All Articles