Bitmap newBitmap = Bitmap.createBitmap(oldBitmap.getWidth(), m_CurrentBitmap.getHeight(), Config.ARGB_8888);
newBitmap = Bitmap.createBitmap(oldBitmap.getWidth(), deltaX, 0, oldBitmap.getWidth() - deltaX, oldBitmap.getHeight());
因此,我尝试创建一个具有所需尺寸的新位图,并手动设置像素(带有偏移)。然而,这仍然会产生一个较窄的位图,缺少右侧的空白区域:
Bitmap newBitmap = Bitmap.createBitmap(oldBitmap.getWidth(), oldBitmap.getHeight(), Config.ARGB_8888);
int[] oldPixels = new int[(int)(oldBitmap.getWidth() - deltaX) * oldBitmap.getHeight()];
m_CurrentBitmap.getPixels(oldPixels, 0, (int) (oldBitmap.getWidth() - deltaX), (int)deltaX, 0, (int) (oldBitmap.getWidth() - deltaX), oldBitmap.getHeight());
newBitmap.setPixels(oldPixels, 0, (int) (oldBitmap.getWidth() - deltaX), 0, 0, (int) (oldBitmap.getWidth() - deltaX), oldBitmap.getHeight());