TpoM6oH
TpoM6oH

Reputation: 8585

How to make fast operations on bitmaps in android

I need to make some operations on bitmaps in android, such as chanding pixel colors, transparency, painting another bitmap on the first one with transparency, zooming, croping, applying masks and so on. Now I make it with java and it is really slow. It take about 5 seconds to compute a 600x600 pixels image on nexus 4.

What technology will be suitable for this operations?

I tried library GPUImage that uses OpenGL ES 2.0, but I faced a problem when trying to apply a mask to an image, mask size is 600x600 as the original image, so I should pass an array of 1440000 color values, and the GLSL language doesnt support such big arrays. 360000 of vec4 values is too large for it too. May be I can pass a whole image as a texture2d object, but I cant find how to do it. Cold someone please give me a tutorial?

The second option is renderscript. It is not so suitable because I want phones with android 2.3 has fast bitmap operations, but all in all improving speed on 3.0+ devices will be a good thing. The problem with it was how to pass it data of second bitmap - 360000 of float4 values or a bitmap itself. I coudnt find information about it too, so I would be thankful if someone give me an advice or tutorial.

The third option is using NDK. But I dont know will it be fast enough and again cant find good information to start with ndk in general and image processing with ndk in particular. So I again need an advice or tutorial.

So, all in all, please tell me what other ways of fast image processing are there and please give me some advices or tutorials on this 3 methods. And what is the best way to make operations on images really fast?

Upvotes: 0

Views: 442

Answers (1)

fadden
fadden

Reputation: 52353

If you find GLES suitable, divide the image into small tiles, and operate on one tile at a time. (Some drivers work this way.)

Upvotes: 2

Related Questions