if(nWidth == nOriginWidth && nHeight == nOriginHeight)
return bmpSrc;
//Prepare a drawing bitmap and graphic object
Bitmap bmpOrigin = new Bitmap(nOriginWidth, nOriginHeight);
Graphics graph = Graphics.create(bmpOrigin);
//Create a line of transparent pixels for later use
int[] aEmptyLine = new int[nWidth];
for(int x = 0; x < nWidth; x++)
aEmptyLine[x] = 0x00000000;
//Create two scaled bitmaps
Bitmap[] bmpScaled = new Bitmap[2];
for(int i = 0; i < 2; i++)
{
//Draw the bitmap on a white background first, then on a black background
graph.setColor((i == 0) ? Color.WHITE : Color.BLACK);
graph.fillRect(0, 0, nOriginWidth, nOriginHeight);
graph.drawBitmap(0, 0, nOriginWidth, nOriginHeight, bmpSrc, 0, 0);
//Create a new bitmap with the desired size
bmpScaled[i] = new Bitmap(nWidth, nHeight);
if(nAspectRatio == Bitmap.SCALE_TO_FIT)
{