Android Question getPixels from a bitmap

birnesoft

Active Member
Licensed User
Longtime User
I want to get the RGB values from a bitmap.

getPixel is to slow

how can I call the method

getPixels (int[] pixels, int offset, int stride, int x, int y, int width, int height)


tx Björn
 

klaus

Expert
Licensed User
Longtime User
With this routine:
B4X:
Dim p() As Int
'
p = getPixels(bmpTest1, 0, 0, 10, 10, 200, 200)
'
'
Sub getPixels(bmp As Bitmap, offset As Int, stride As Int, x As Int, y As Int, width As Int, height As Int) As Int()
    Dim jo = bmp As JavaObject
    Dim pixels(width * height) As Int
    jo.RunMethod("getPixels", Array As Object(pixels, offset, width, x, y, width, height))
    Return pixels
End Sub
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
With this routine:
B4X:
Dim p() As Int
'
p = getPixels(bmpTest1, 0, 0, 10, 10, 200, 200)
'
'
Sub getPixels(bmp As Bitmap, offset As Int, stride As Int, x As Int, y As Int, width As Int, height As Int) As Int()
    Dim jo = bmp As JavaObject
    Dim pixels(width * height) As Int
    jo.RunMethod("getPixels", Array As Object(pixels, offset, width, x, y, width, height))
    Return pixels
End Sub


Slacker Klaus: put it in the Snippets.

( :) Thank you, great Klaus)
 
Upvote 0
Top