Blackberry - how to resize image?

后端 未结 8 1987
栀梦
栀梦 2020-11-30 05:11

I wanted to know if we can resize an image. Suppose if we want to draw an image of 200x200 actual size with a size of 100 x 100 size on our blackberry screen.

Thanks

相关标签:
8条回答
  • 2020-11-30 05:38
    in this there is two bitmap.temp is holding the old bitmap.In this method you just pass
    bitmap ,width,height.it return new bitmap of your choice.
    
      Bitmap ImgResizer(Bitmap bitmap , int width , int height){
        Bitmap temp=new Bitmap(width,height);
        Bitmap resized_Bitmap = bitmap;
        temp.createAlpha(Bitmap.HOURGLASS);
        resized_Bitmap.scaleInto(temp , Bitmap.FILTER_LANCZOS);
        return temp;
    }
    
    0 讨论(0)
  • 2020-11-30 05:40

    Keep in mind that the default image scaling done by BlackBerry is quite primitive and generally doesn't look very good. If you are building for 5.0 there is a new API to do much better image scaling using filters such as bilinear or Lanczos.

    0 讨论(0)
  • 2020-11-30 05:43

    Just an alternative:
    BlackBerry - draw image on the screen
    BlackBerry - image 3D transform

    0 讨论(0)
  • Here is the function or you can say method to resize image, use it as you want :

    int olddWidth;
    int olddHeight;
    int dispplayWidth;
    int dispplayHeight;
    
    EncodedImage ei2 = EncodedImage.getEncodedImageResource("add2.png");
    olddWidth = ei2.getWidth();
    olddHeight = ei2.getHeight();
    dispplayWidth = 40;\\here pass the width u want in pixels
    dispplayHeight = 80;\\here pass the height u want in pixels again
    
    int numeerator = net.rim.device.api.math.Fixed32.toFP(olddWidth);
    int denoominator = net.rim.device.api.math.Fixed32.toFP(dispplayWidth);
    int widtthScale = net.rim.device.api.math.Fixed32.div(numeerator, denoominator);
    numeerator = net.rim.device.api.math.Fixed32.toFP(olddHeight);
    denoominator = net.rim.device.api.math.Fixed32.toFP(dispplayHeight);
    int heighhtScale = net.rim.device.api.math.Fixed32.div(numeerator, denoominator);
    EncodedImage newEi2 = ei2.scaleImage32(widtthScale, heighhtScale); 
    Bitmap _add =newEi2.getBitmap();
    
    0 讨论(0)
  • 2020-11-30 05:48

    For BlackBerry JDE 5.0 or later, you can use the scaleInto API.

    0 讨论(0)
  • 2020-11-30 05:52

    I'm not a Blackberry programmer, but I believe some of these links will help you out:

    Image Resizing Article
    Resizing a Bitmap on the Blackberry
    Blackberry Image Scaling Question

    0 讨论(0)
提交回复
热议问题