请告诉我为什么我得到这个错误?
java.lang.IllegalArgumentException: x + width must be <= bitmap.width()
错误指的是下面一行。编辑后保存图像时出现错误:
surfaceView = new PhotoEditor(this, bitmap, arrowArrayList);
setContentView(surfaceView);
java代码:
relativeLayoutPhoto = findViewById(R.id.relativeLayoutPhoto);
SharedPreferences sharedPreferences;
int width;
int height;
float ratioToMedium;
sharedPreferences = this.getSharedPreferences(SHARED_PREFERENCES_DISPLAY, Context.MODE_PRIVATE);
width = sharedPreferences.getInt(WIDTH_KEY, 0);
height = sharedPreferences.getInt(HEIGHT_KEY, 0);
ratioToMedium = sharedPreferences.getFloat(RATIO_TO_MEDIUM_KEY, 0);
Bitmap b = Bitmap.createScaledBitmap(bitmap, width, (int) (height - toolBarHeight * ratioToMedium),false);
Drawable drawable = new BitmapDrawable(getResources(), b);
relativeLayoutPhoto.setBackground(drawable);
relativeLayoutPhoto.setOnDragListener(this);
你能写你的位图吗宽度和高度以及这个方法中每个参数的值?
Bitmap b = Bitmap.createScaledBitmap(bitmap, width, (int) (height - toolBarHeight * ratioToMedium),false);