简体   繁体   English

更快绘制比例位图

[英]Faster drawing of scaled bitmaps

I draw map tiles in a custom SurfaceView. 我在自定义的SurfaceView中绘制地图图块。 One map tile is 256x256. 一个地图图块是256x256。 The map is multitouch zoomable. 地图是多点触控缩放的。 When the zoom is 1:1, the map tile bitmaps need not to be scaled and I have about 60 FPS on Nexus One with Android 2.3.3. 当缩放比例为1:1时,无需缩放地图图块位图,在装有Android 2.3.3的Nexus One上,我的FPS约为60 FPS。 When the zoom is different, bitmaps are drawn scaled and I have about 35 FPS. 当缩放比例不同时,将按比例绘制位图,我的帧速约为35 FPS。 How can I increase the FPS? 如何增加FPS? I draw bitmaps with Canvas.drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint). 我用Canvas.drawBitmap(位图位图,Rect src,Rect dst,Paint paint)绘制位图。 My paint is set to scale bitmaps smoothly. 我的绘画设置为平滑缩放位图。

This sounds like something for a game. 这听起来像是游戏的东西。 I've never done any game development on Android, so this should be taken with several grains of salt, but... 我从未在Android上进行任何游戏开发,因此应该花点时间,但是...

Maybe you could generate pre-scaled versions of your tiles in advance, for different zoom levels, and thus minimize the need for scaling during the actual game (or whatever you're building)? 也许您可以预先针对不同的缩放级别生成图块的预缩放版本,从而在实际游戏(或正在构建的任何内容)中将缩放比例的需求降到最低? So you accept the drop in FPS during the actual zoom operation, but as soon as the user is done zooming, you select (or generate) the appropriate tile set and goes back to drawing un-scaled content. 因此,您可以在实际的缩放操作期间接受FPS的下降,但是一旦用户完成缩放,就可以选择(或生成)适当的图块集,然后返回绘制未缩放的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM