Reputation: 7947
I have a 640x480 RGB_565 format bitmap which I need to draw on a higher resolution display as fast as possible. It is not critical that the bitmap fills the entire screen so long as it fills most of it.
So, one idea I had was to draw a double sized bitmap 1280x960 so that each pixel in the original neatly maps to 4 pixels on screen. This, in theory, should be much faster than scaling to some awkward fraction. But I'm not sure exactly how to take advantage of this.
Would any of the possible canvas.drawBitmap
functions notice the simple x2 calculation and do things faster? Should I perhaps make a double sized bitmap first and then draw the bigger bitmap without scaling? What would be the fastest way?
Upvotes: 2
Views: 232
Reputation: 3508
Mick, From what I understood - this is my answer to help you.
I have had a similar problem too. After reading some posts on Bitmap operations - I understood doing any pixel-by-pixel operations on a Bitmap is really slow on android.
For your problem, bitmap can be scaled using inbuilt functions (which generally work faster than pixel by pixel operations). This is the way to use the inbuilt functions :
bitmapProcessed = Bitmap.createScaledBitmap(originalBitmap, NewWidth, NewHeight, true);
In your case,
NewWidth = 2 * originalBitmap.getWidth();
NewHeight = 2 * originalBitmap.getHeight();
The image that results from this, is generally not very good. If you want to make it more clear, to match the higher resolution display - I would suggest doing a bicubic interpolation.
I hope this helps.
Upvotes: 1