【发布时间】:2012-05-03 15:06:51
【问题描述】:
我目前使用这样的代码来为不同的屏幕尺寸重新调整位图:
A.back = GPATools.ResizeTransparentBitmap(A.back, 150, 37,
Bitmap.FILTER_LANCZOS, Bitmap.SCALE_TO_FIT);
但是,每次我加载应用程序时,都需要花费一些时间来重新调整它的大小,所以有人告诉我为此使用以下代码:
class PersistableBitmap implements Persistable {
int width;
int height;
int[] argbData;
public PersistableBitmap(Bitmap image){
width = image.getWidth();
height = image.getHeight();
argbData =new int[width * height];
image.getARGB(argbData,0, width,0,0, width, height);
}
public Bitmap getBitmapImage(){
Bitmap image =new Bitmap(width, height);
image.setARGB(argbData,0, width,0,0, width, height);
return image;
}
我的问题是,我不知道如何同时实现这两者!请大家帮忙,非常感谢!
【问题讨论】:
-
至少在 sn-p 中添加一些空格!
-
我假设您的位图非常大,并且您已经进行了相关测试以证明调整大小比从持久性加载它消耗更多时间。如果没有,我建议您将预缩放的图像包含在项目资源中,或者甚至将位图缓存在运行时存储中。
-
空白?无论如何,我有很多图像,它们并不大,但数量很大。有人还建议它可能会阻塞主用户界面并将其放在另一个线程中,但我不确定该怎么做。
-
将
classPersistableBitmapimplementsPersistable更改为class PersistableBitmap implements Persistable,并修复其他问题。 -
这只是一个复制和粘贴错误 Rupak。我想知道如何实现这两种不同的编码
标签: java blackberry bitmap resize