Android Image.WritePixels()

Monkey Targets Forums/Android/Android Image.WritePixels()

HokaMonstret(Posted 2013) [#1]
Hi!

I'm new to Monkey and have found that Image.WritePixels() is terribly slow on android. I want to recreate some old Amiga stuff I did back in the day. Is there any good info on how Monkey gets translated to android or how to integrate native code. Manipulating the pixelsarrays is fast. It runs at 60 fps as long as I don't call WritePixels(). What I can tell most drawing is handled by 3d hardware. Am I wrong?


Gerry Quinn(Posted 2013) [#2]
I don't know really. I would have imagined that WritePixels() would be no slower than loading an image. If anything I would have thought that ReadPixels() might be slow because data is going 'the wrong way'.


AdamRedwoods(Posted 2013) [#3]
how are you using WritePixel? you could try to write bulk pixels once every 10 frames or something. Behind the scenes it looks like Android is rebinding the texture, so you probably don't want to do this every frame.


HokaMonstret(Posted 2013) [#4]
I'm calling it every frame since I'm applying a scroll and blur operation on the argb data. This seems to be a bottleneck on android:( The pixelarray is displaywidth+32, height 38.


HokaMonstret(Posted 2013) [#5]
Is there a new android Bitmap Object being created each frame and the old one garbagecollected perhaps??


AdamRedwoods(Posted 2013) [#6]
its opengl, so android is binding and uploading the data per frame.

Also, looking at mojo, looks like each texture Bind() call mojo is padding non-powers of two textures, and on top of that converts the image to the proper RGB format and pre-multiplies, which probably isn't needed after the first time could be done on our side.

So i'd say mojo may need a little tweaking, you may want to mention this to Mr.Sibly and see if he can throw something in there that doesn't re-do that byte shifting if we're using WritePixel() for RGBA8888.

In the meantime, make sure your image is powers-of-two size (32x64 should work) and use GetImage() to clip it.


HokaMonstret(Posted 2013) [#7]
I think opengl uses 16bit textures. Where do you find this mojostuff?