我可以在创建位图时使用重用的位图。这是我目前的代码。它显示内存错误。任何帮助或建议将不胜感激。
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
progress++;
float scale =(float) progress/5;
int width = textureBitmap.getWidth();
int height = textureBitmap.getHeight();
float scaleWidth = ((float) width*scale) / width;
float scaleHeight = ((float) height*scale) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
//BitmapFactory.Options options = new BitmapFactory.Options();
//options.inBitmap=croppedBitmap;
resizedBitmap = Bitmap.createBitmap(textureBitmap, 0, 0, width, height, matrix, false);
if(scaleWidth >=1 && scaleHeight >= 1)
{
croppedBitmap = Bitmap.createBitmap(resizedBitmap,0,0,width,height);
if (resizedBitmap!= croppedBitmap)
resizedBitmap.recycle();
}
else
croppedBitmap = resizedBitmap;
try {
if (clicked == 0)
renderer.changeTopTexture(croppedBitmap);
if (clicked == 1)
renderer.changeHandTexture(croppedBitmap);
if (clicked == 2)
renderer.changeNeckTexture(croppedBitmap);
}
catch (ATexture.TextureException e) {
Log.d("DEBUG", "TEXTURE ERROR");
}
}
我们要做的是在搜索栏更改时缩放模型的纹理。任何其他想法也欢迎。