Oliver Simith
Member
Hello guys,
In an exercise, I first drew bitmapA loaded from the asset folder and then drew bitmapB created by BitmapCreator.drawFillGradient. Both images have targeted the same rectangle.
I expect the second image to be the same size and position as the first image.
But as you can see in the attached screenshot, the size of the second drawing is only 1/4 of the size of the first one. And the coordinate origin seems to be wrong.
I would like to ask, is there something I set wrong? Or is the coordinate system itself designed to be different between drawing a loaded image and drawing a created graphic?
here is the full code:
In an exercise, I first drew bitmapA loaded from the asset folder and then drew bitmapB created by BitmapCreator.drawFillGradient. Both images have targeted the same rectangle.
I expect the second image to be the same size and position as the first image.
But as you can see in the attached screenshot, the size of the second drawing is only 1/4 of the size of the first one. And the coordinate origin seems to be wrong.
I would like to ask, is there something I set wrong? Or is the coordinate system itself designed to be different between drawing a loaded image and drawing a created graphic?
here is the full code:
the code in b4J:
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
Private cvsX As B4XCanvas
Private RectX As B4XRect
Private GradientColors() As Int
Private Pane1 As B4XView
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
cvsX.Initialize(Pane1)
RectX.Initialize(100dip,100dip,300dip,300dip)
GradientColors=Array As Int(xui.Color_Blue,xui.Color_red)
'load and draw bitmapA
Private btmp As B4XBitmap=xui.LoadBitmapResize(File.DirAssets,"scene.jpg",RectX.Width,RectX.Height,False)
cvsX.DrawBitmap(btmp,RectX)
'draw bitmapB
FillGradient(GradientColors,RectX,"LEFT_RIGHT")
End Sub
Private Sub FillGradient(colors() As Int, rect As B4XRect,orientation As String)
Dim btmpCreator As BitmapCreator
btmpCreator.Initialize(rect.Width,rect.Height)
btmpCreator.FillGradient(colors,rect,orientation)
cvsX.DrawBitmap(btmpCreator.Bitmap,rect)
End Sub