【问题标题】:Reuse Bitmap in CreateBitmap在 CreateBitmap 中重用位图
【发布时间】:2015-09-09 13:22:59
【问题描述】:

我可以在创建位图时使用重复使用的位图吗?这是我当前的代码。它显示内存错误。任何帮助或建议将不胜感激。

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");
            }

        }

我试图做的是在搜索栏变化时缩放模型的纹理。也欢迎任何替代想法。

【问题讨论】:

  • 为什么我的问题被降级???
  • 我相信这是一个很好的问题!但是你发布了很多不相关的代码

标签: android opengl-es bitmap textures


【解决方案1】:
猜你喜欢
  • 2014-05-03
  • 2015-08-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-13
  • 2013-11-21
  • 2017-06-13
相关资源
最近更新 更多