Ola
In B4A, adding an image to the CSBuilder is easy peasy as this example below.
In b4i, there is no .Image call for the CSBuilder, but this code found here, seems to do the trick.
I understand that perhaps this line...
Resizes the image, so in my case, I have to pass 70 and 65 as above? Thanks
#Converting_From_B4A_2_B4I
In B4A, adding an image to the CSBuilder is easy peasy as this example below.
B4X:
eachD.Image(LoadBitmap(File.DirAssets, "sos.png"), 70dip, 65dip, False).Append(CRLF)
In b4i, there is no .Image call for the CSBuilder, but this code found here, seems to do the trick.
B4X:
Sub AppendImage(cs As CSBuilder, bmp As Bitmap)
Dim attachment As NativeObject
attachment = attachment.Initialize("NSTextAttachment").RunMethod("new", Null)
attachment.SetField("image", bmp)
Dim nme As NativeObject = Me
'set bounds
nme.RunMethod("SetBounds::", Array(attachment, attachment.MakeRect(0, 0, 50, 100)))
Dim attributedString As NativeObject
attributedString = attributedString.Initialize("NSAttributedString") _
.RunMethod("attributedStringWithAttachment:", Array(attachment))
Dim no As NativeObject = cs
no.RunMethod("appendAttributedString:", Array(attributedString))
End Sub
#if OBJC
-(void)SetBounds:(NSTextAttachment*) attachment :(NSData*)data {
attachment.bounds = *(CGRect*)data.bytes;
}
#End If
I understand that perhaps this line...
B4X:
nme.RunMethod("SetBounds::", Array(attachment, attachment.MakeRect(0, 0, 50, 100)))
Resizes the image, so in my case, I have to pass 70 and 65 as above? Thanks
#Converting_From_B4A_2_B4I