Sub ResizeNN(SrcBmp As B4XBitmap, NewWidth As Int, NewHeight As Int) As B4XBitmap
Dim SrcWidth As Int = SrcBmp.Width
Dim SrcHeight As Int = SrcBmp.Height
Dim srcbc As BitmapCreator 'old source image
srcbc.Initialize(SrcWidth, SrcHeight)
srcbc.CopyPixelsFromBitmap(SrcBmp)
Dim newbc As BitmapCreator 'new destination image
newbc.Initialize(NewWidth, NewHeight)
Dim SrcX As Int
Dim SrcY As Int
'copy+resize from srcbc to newbc
For NewX = 0 To NewWidth - 1
For NewY = 0 To NewHeight - 1
SrcX = (NewX * 2 + 1) * SrcWidth / (NewWidth * 2) 'can be hoisted up one line since doesn't change in inner loop
SrcY = (NewY * 2 + 1) * SrcHeight / (NewHeight * 2)
newbc.SetColor(NewX, NewY, srcbc.GetColor(SrcX, SrcY)) 'copy pixel
Next
Next
Return newbc.Bitmap
End Sub