mrossen Active Member Licensed User Longtime User Nov 14, 2014 #1 Hi I use this snip of code in my B4A app, B4X: Canvas1.Initialize(ImageViewPinCard) 'this canvas will draw on the activity background Canvas1.DrawText(Device, 14dip, 50dip, Typeface.DEFAULT, 10, Colors.Black, "LEFT") Canvas1.DrawText("S/N: " & SN, 14dip, 60dip, Typeface.DEFAULT, 6, Colors.black, "LEFT") Canvas1.DrawText("PIN Code: " & PinCode, 14dip, 70dip, Typeface.DEFAULT_BOLD, 7, Colors.Black, "LEFT") Bitmap1.Initialize3(Canvas1.Bitmap) I would like to use it in B4i but it seems not to have "Bitmap1.Initialize3) Another problen is "Typeface.DEFAULT" is not accepted, Anyone with come experince on this ? Mogens
Hi I use this snip of code in my B4A app, B4X: Canvas1.Initialize(ImageViewPinCard) 'this canvas will draw on the activity background Canvas1.DrawText(Device, 14dip, 50dip, Typeface.DEFAULT, 10, Colors.Black, "LEFT") Canvas1.DrawText("S/N: " & SN, 14dip, 60dip, Typeface.DEFAULT, 6, Colors.black, "LEFT") Canvas1.DrawText("PIN Code: " & PinCode, 14dip, 70dip, Typeface.DEFAULT_BOLD, 7, Colors.Black, "LEFT") Bitmap1.Initialize3(Canvas1.Bitmap) I would like to use it in B4i but it seems not to have "Bitmap1.Initialize3) Another problen is "Typeface.DEFAULT" is not accepted, Anyone with come experince on this ? Mogens
klaus Expert Licensed User Longtime User Nov 14, 2014 #2 It seems that it is not possible to initialize a canvas directly to a bitmap but only to views. You could use an ImageView instead. The DrawText routine is a bit different in B4i. The line below B4X: Canvas1.DrawText(Device, 14dip, 50dip, Typeface.DEFAULT, 10, Colors.Black, "LEFT") must be B4X: Canvas1.DrawText(Device, 14dip, 50dip, Font.CreateNew(10), Colors.Black, "LEFT") Font.CreateNew creates a Font object based on the default font and 10 is the size. And replace B4X: Bitmap1.Initialize3(Canvas1.Bitmap) by B4X: Bitmap1 = Canvas1.CreateBitmap) Last edited: Nov 14, 2014 Upvote 0
It seems that it is not possible to initialize a canvas directly to a bitmap but only to views. You could use an ImageView instead. The DrawText routine is a bit different in B4i. The line below B4X: Canvas1.DrawText(Device, 14dip, 50dip, Typeface.DEFAULT, 10, Colors.Black, "LEFT") must be B4X: Canvas1.DrawText(Device, 14dip, 50dip, Font.CreateNew(10), Colors.Black, "LEFT") Font.CreateNew creates a Font object based on the default font and 10 is the size. And replace B4X: Bitmap1.Initialize3(Canvas1.Bitmap) by B4X: Bitmap1 = Canvas1.CreateBitmap)