0
ビットマップの配列を特定の割合の画面にリサイズしています(すべてのデバイスで同じように見えます)。いくつかのビットマップは、サイズが+ 256kbのスプライト(爆発など)です。ビットマップが範囲外のエラー
明らかに、ビットマップが2回変換されると、VMのメモリが不足しています。ビットマップはアンドロイドアプリケーションの先頭でのみ変換されますが、まだエラーが発生しています。
誰でも教えてください。このコードをビットマップとして返す、より良い、より速く、より効果的な方法がありますか?
好奇心から逃れたのは、参照渡しのビットマップ値ですか? (オブジェクト・パラメーターは、同じオブジェクトに対して同じ行のメモリーを使用しますか?)。
は、とにかくここにあるzのコードです:
public Bitmap ResizeBitmap(Bitmap bitmap, float s_percentage, int frames, int viewport_width, int viewport_height)
{
float percentage = s_percentage/100.0f;
float scale = viewport_width/100 * percentage;
if(viewport_width < viewport_height)
{
scale = viewport_height/100 * percentage;
}
int newWidth = (int) (bitmap.getWidth() * scale);
int newHeight = (int) (bitmap.getHeight() * scale);
if(newWidth <= 0 || newHeight <= 0)
{
// Extra check, for invalid width/height
Log.e("Function List, Resize Bitmap", "invalid dimension ("+newWidth+"x"+newHeight+")");
return bitmap;
}
//Round up to closet factor of total frames
int rW = (newWidth/frames)+1;
newWidth = rW*frames;
Bitmap newBitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, false);
return newBitmap;
}