Hello i try to resize a image but i become a error.
Here my Code:
And here the Error
Here my Code:
B4X:
Sub ResizeImage (Image As Bitmap, Width As Int, Height As Int) As Bitmap
Dim PhotoCanvas As Canvas
Dim PhotoPanel As Panel
Dim PhotoView As ImageView
Dim NewImage As Bitmap
PhotoPanel.Initialize("")
PhotoPanel.Width = Width / 2
PhotoPanel.Height = Height / 2
PhotoView.Initialize("")
PhotoView.Bitmap = Image
PhotoPanel.AddView(PhotoView,0,0,Width / 2,Height / 2)
PhotoCanvas.Initialize(PhotoPanel)
NewImage = PhotoCanvas.CreateBitmap
Return NewImage
End Sub
And here the Error
B4X:
Application_Start
Error occurred on line: 320 (Main)
Object was not initialized (UIImage)
Stack Trace: (
CoreFoundation <redacted> + 150
libobjc.A.dylib objc_exception_throw + 38
CoreFoundation <redacted> + 0
Lulaj -[B4IObjectWrapper object] + 200
Lulaj -[B4IImageViewWrapper setBitmap:] + 112
Lulaj -[b4i_main _createlistitem:::] + 1912
Lulaj -[b4i_main _setuppage1] + 3936
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 292
Lulaj +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1786
Lulaj -[B4IShell runMethod:] + 574
Lulaj -[B4IShell raiseEventImpl:method:args::] + 1998
Lulaj -[B4IShellBI raiseEvent:event:params:] + 1442
Lulaj __33-[B4I raiseUIEvent:event:params:]_block_invoke + 74
libdispatch.dylib <redacted> + 10
libdispatch.dylib <redacted> + 22
libdispatch.dylib _dispatch_main_queue_callback_4CF + 1532
CoreFoundation <redacted> + 8
CoreFoundation <redacted> + 1590
CoreFoundation CFRunLoopRunSpecific + 516
CoreFoundation CFRunLoopRunInMode + 108
GraphicsServices GSEventRunModal + 160
UIKit UIApplicationMain + 144
Lulaj main + 108
libdyld.dylib <redacted> + 2
)
Application_Active
Line 320 is The return
and Here is my Use:
iv.Bitmap = ResizeImage(LoadBitmap(File.DirAssets, "test.png"),Width,40)