Hi there,
I am trying to capture a part of an image displayed with an Imageview and then convert that part
as a new image in an other ImageView.
The dimensions of the image's section that I need to capture are 512 Wide and 384 Height
at the starting location 100,279
I have tried to accomplish it as follows but with no success.
Any help or ideas will be greatly appreciated.
I am trying to capture a part of an image displayed with an Imageview and then convert that part
as a new image in an other ImageView.
The dimensions of the image's section that I need to capture are 512 Wide and 384 Height
at the starting location 100,279
I have tried to accomplish it as follows but with no success.
Any help or ideas will be greatly appreciated.
B4X:
Sub create_outer_hatch
Dim btc As ByteConverter
Dim pix(513*385) As Int
Dim imgbuff As Image = IV_CoverImage.GetImage
Dim IVouterhatch_img1 As ImageView
Dim x1, x2, y1, y2, idx As Int
x1 = 100
y1 = 279
x2 = x1 + 512
y2= y1 + 384
idx = -1
For x = x1 To x2
For y = y1 To y2
idx = idx + 1
pix(idx) = imgbuff.GetPixel(x, y)
Next
Next
IVouterhatch_img1.Initialize("")
IVouterhatch_img1.SetImage(BytesToImage(btc.IntsToBytes(pix)))
MainForm.RootPane.AddNode(IVouterhatch_img1,0,0,512,384)
End Sub
Public Sub BytesToImage(bytes() As Byte) As Image
Dim In As InputStream
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
Dim bmp As Image
bmp.Initialize2(In)
Return bmp
End Sub