In Android, how to shift a bitmap?
<p>I am trying, unsuccessfully, to "shift" a bitmap.  By "shift", I mean:  if I have a 500x300 and I shift it 50 pixels to the right, the result should be a 500x300 bitmap where every pixel has been shifted 50 pixels to the left, and the 50 right most pixels are blank.  So, the new image is the same as the old one except the left side is cropped, and a blank area is appended to the right side.  The below code successfully crops the left side, but it does not produce a blank area on the right side, it just produces a narrower bitmap:</p>

<pre><code>Bitmap newBitmap = Bitmap.createBitmap(oldBitmap.getWidth(), m_CurrentBitmap.getHeight(), Config.ARGB_8888);
newBitmap = Bitmap.createBitmap(oldBitmap.getWidth(), deltaX, 0, oldBitmap.getWidth() - deltaX, oldBitmap.getHeight());
</code></pre>

<p>So then I tried creating a new Bitmap with the desired dimensions, and manually setting the pixels (with an offset).  However, this still produces a narrower Bitmap, lacking the blank area on the right side:</p>

<pre><code>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());
</code></pre>
