Android Question How to create a bitmap from a region of a Image?

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
I did not understand canvas well.

How to create a bitmap from region of points (x1, y1, x2, y2)

Thank you.
 

eurojam

Well-Known Member
Licensed User
Longtime User
Hi,
this code fraqment takes to images an shows for example 30&% from one image and 70% from the other. The value comes from a slider:

B4X:
   v = is1.GetValue/100 'Value from slider

    f1=bitmap1.Width/bitmap1.Height
    f2=bitmap1.Width/bitmap2.Height
    w = 100%x
    h1 = w/f1
    h2 = w/f2
    DestRect1.Initialize( 0, 0, w*v,h1 )
    SrcRect1.Initialize(0,0,bitmap1.Width*v,bitmap1.Height)

    DestRect2.Initialize(w*v, 0,w,h2 )
    SrcRect2.Initialize(bitmap2.Width*v, 0 ,bitmap2.Width,bitmap2.Height)   
   
    canvas1.DrawBitmap(  bitmap1, SrcRect1, DestRect1) 'draws the bitmap to the destination rectangle.
    canvas1.DrawBitmap(  bitmap2, SrcRect2, DestRect2) 'draws the bitmap to the destination rectangle.
    Activity.Invalidate

Screenshot_2014-11-16-12-15-37.jpg
 
Upvote 0
Top