Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

drawBitmap with different rendering outputs (Nexus 7 versus other devices)

In my application, I use drawBitmap() to display a low res bitmap while I'm zooming it out. I tested it on several devices (Galaxy Tab, Kindle Fire, Moto Xoom and Nexus 7). In all of them I get the same rendering quality, except in Nexus 7. You can see on the attached screen shots the difference. The outer region is the one I'm using drawBitmap, something like this:

mSrcRectF.set(src_x1, src_y1, src_x2, src_y2);
mDesRectF.set(view_x1, view_y1, view_x2, view_y2);
mMatrix.setRectToRect(mSrcRectF, mDesRectF, Matrix.ScaleToFit.CENTER);
canvas.drawBitmap(bmp, mMatrix, mPagePaint);

If I try using the other variant drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) without the matrix I get the same results.

I believe this issue/difference may be related to the hardware acceleration. If I turn it off (in manifest file), I get the same results for all devices. If I turn it on, the rendering improves for all of them except Nexus, which still shows a more 'pixelated' bitmap. I have read that some routines are not supported in HA, but even so, I can't understand what is happening in this case. In a recent post of Romain Guy in his blog he comments:

Note that alpha bitmaps only work with shaders when invoking the “simple” version of drawBitmap(). The variants that take a Matrix or a source and destination rectangle are not supported with hardware acceleration at the moment.

Can someone shed some light on this?

Nexus 7: Nexus 7 screen shot

Xoom (or Galaxy Tab, Kindle Fire): Xoom screen shot

like image 364
Ander Avatar asked Jan 07 '13 23:01

Ander


1 Answers

You may be able to selectively turn off hardware acceleration for your Canvas following the instructions in this Stack Overflow article

It's not an ideal solution, but it could allow the rest of your app to get the benefits of hardware acceleration until all options to drawBitmap() are support with hardware acceleration.

like image 106
Scott Leslie Avatar answered Oct 22 '22 16:10

Scott Leslie