M Mscal Member Licensed User Mar 15, 2017 #1 hi, I use a drawer as canvas,a layout1 as panel,bitmap1 as bitmap,rect1 as rect the main code is rect1.Initialize(0,0,100,100) drawer.DrawBitmap(bitmap1,Null,rect1) rect1.Initialize(0,100,100,200) drawer.DrawBitmap(bitmap1,Null,rect1) when running it,i can only see the second image,please help me how can i draw 2 pictures in one panel
hi, I use a drawer as canvas,a layout1 as panel,bitmap1 as bitmap,rect1 as rect the main code is rect1.Initialize(0,0,100,100) drawer.DrawBitmap(bitmap1,Null,rect1) rect1.Initialize(0,100,100,200) drawer.DrawBitmap(bitmap1,Null,rect1) when running it,i can only see the second image,please help me how can i draw 2 pictures in one panel
Erel B4X founder Staff member Licensed User Longtime User Mar 15, 2017 #2 Please use [code]code here...[/code] tags when posting code. 1. You should use dip units. 2. Are you calling drawer.Invalidate? Upvote 0
Please use [code]code here...[/code] tags when posting code. 1. You should use dip units. 2. Are you calling drawer.Invalidate?
S sorex Expert Licensed User Longtime User Mar 15, 2017 #3 did you invalidate your drawer? in some cases it won't show all changes unless you do that. also re-dim a new rect1 for the second drawing might help Upvote 0
did you invalidate your drawer? in some cases it won't show all changes unless you do that. also re-dim a new rect1 for the second drawing might help
R ronell Well-Known Member Licensed User Longtime User Mar 15, 2017 #4 B4X: Dim drawer As Canvas Dim panel1 As Panel Dim bitmap1 As Bitmap Dim bitmap2 As Bitmap Dim rect1 As Rect Dim rect2 As Rect B4X: bitmap1.Initialize(File.DirAssets,"pic1.jpg") bitmap2.Initialize(File.DirAssets,"pic2.jpg") drawer.Initialize(panel1) rect1.Initialize(0,0,panel1.Width/2,panel1.Height/2) drawer.DrawBitmap(bitmap1,Null,rect1) rect2.Initialize(20dip,10dip,100dip,100dip) drawer.DrawBitmap(bitmap2,Null,rect2) Upvote 0
B4X: Dim drawer As Canvas Dim panel1 As Panel Dim bitmap1 As Bitmap Dim bitmap2 As Bitmap Dim rect1 As Rect Dim rect2 As Rect B4X: bitmap1.Initialize(File.DirAssets,"pic1.jpg") bitmap2.Initialize(File.DirAssets,"pic2.jpg") drawer.Initialize(panel1) rect1.Initialize(0,0,panel1.Width/2,panel1.Height/2) drawer.DrawBitmap(bitmap1,Null,rect1) rect2.Initialize(20dip,10dip,100dip,100dip) drawer.DrawBitmap(bitmap2,Null,rect2)
klaus Expert Licensed User Longtime User Mar 15, 2017 #5 Be aware of the Height/Width ratios of the bitmap and the destination rectangle. If they are different the image will be distorted. The Invalidate method refers to the Panel not the Canvas. Panel1.Invalidate and not drawer.Invalidate. Upvote 0
Be aware of the Height/Width ratios of the bitmap and the destination rectangle. If they are different the image will be distorted. The Invalidate method refers to the Panel not the Canvas. Panel1.Invalidate and not drawer.Invalidate.