iOS Question Mass extraction of a bitmap's pixels

JackKirk

Well-Known Member
Licensed User
Longtime User
In B4A I can do a mass extraction of a bitmap's pixels by:
B4X:
Dim pixels(bmp.Width * bmp.Height) As Int
Dim jo = bmp As JavaObject
jo.RunMethod("getPixels", Array As Object(pixels, 0, bmp.Width, 0, 0, bmp.Width, bmp.Height))

Which seems to be incredibly efficient.

In B4I I have been looking all over the forums for the last 6 hours, experimented with iRandomAccessFile etc - all to no avail - the only thing I have been able to find is JanPRO's Objective C pixel-by-pixel solution:

https://www.b4x.com/android/forum/threads/getpixelcolor.56922/#post-400769

which is as slow as a wet week if you do the obvious and put it inside a double set of For/Next.

Is there any efficient way to do this?

Thanks in anticipation...
 

JackKirk

Well-Known Member
Licensed User
Longtime User
Thanks Erel,

I can now convert the bitmap to bytes and am then using ByteConverter.IntsFromBytes from the iRandomAccessFile library to extract pixels en mass, but this seems slow compared to the B4A solution in my first post - is there a faster way to extract Int from Byte?

Regards...
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Erel,

I want to extract the pixels from the bitmap so I can analyse their colors.

Is there an alternate way to do this?

Regards...
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Erel,

OK, I did that and it is faster by a factor of about 2.

In LLCamera, is there anyway to get the preview data as YUV?

I don't mean take the supplied bitmap and reconstruct - I mean get the original YUV.

Thanks...
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…