Android Question Change bitmap size

Discussion in 'Android Questions' started by Carles Escudé, Jul 3, 2015.

  1. Carles Escudé

    Carles Escudé Member Licensed User

    Hello!

    I have a source bitmap sized 300x200 and I want to load it in another bitmap sized 150x100

    Ofcourse I want to resize it. Not cutted

    How can I do it?

    Thanks
     
  2. Carles Escudé

    Carles Escudé Member Licensed User

    Don't know if there is a better solution, but I did it! :)

    Code:
    Sub changeImageSize(bmp As Bitmap, destWidth As Int, destHeight As Int) As Bitmap
        
    Private imv As ImageView
        
    Private cvs As Canvas
        
    Dim pnl As Panel
        pnl.Initialize(
    "pnl")
        imv.Initialize(
    "imv")
        pnl.AddView(imv,
    0,0,bmp.Width,bmp.Height)
        cvs.Initialize(imv)   
       
        
    Dim rSrc As Rect
        
    Dim rDest As Rect
       
        rSrc.Initialize(
    00, bmp.Width, bmp.Height)
        rDest.Initialize(
    00, destWidth*2, destHeight/2)
        cvs.DrawBitmap(bmp, rSrc, rDest)
       
        imv.Invalidate   
       
        
    Return imv.Bitmap
    End Sub
     
  3. sorex

    sorex Expert Licensed User

    it depends. if you use an imageview of 150x100 and use the fill gravity it will resize it for you from 300x200 to 150x100
     
  4. Carles Escudé

    Carles Escudé Member Licensed User

    No. I do not load it in a image view. I am loading it in a xnGridCol.

    I have tried to set the gravity of the column to "Fill" but it don't change anyting.

    Thanks;)
     
Loading...