If I use Canvas.DrawBitmap it seems to produce a mottled (herring bone) background on the resized image. If I load the bitmap directly to the panel (or imageview) the image background is quite sharp, even though the Views they are the same size as the bitmap.
Why doesn't DrawBitmap produce a sharp background? Is there a better way to resize a bitmap? I'd appreciate it if someone can shed some light onto what I'm doing wrong. Here is my code:
TIA
Widget
Why doesn't DrawBitmap produce a sharp background? Is there a better way to resize a bitmap? I'd appreciate it if someone can shed some light onto what I'm doing wrong. Here is my code:
B4X:
Sub ResizeBitmap(aBitmap As Bitmap, aWantWid As Int, aWantHt As Int, aKeepAspectRatio As Boolean) As Bitmap
If aBitmap.Width <= aWantWid AND aBitmap.Height <= aWantHt Then
Else
If aKeepAspectRatio Then
If aBitmap.Width / aWantWid > aBitmap.Height / aWantHt Then
If aBitmap.Width < aWantWid Then aWantWid = aBitmap.Width
aWantHt = aBitmap.Height * aWantWid/aBitmap.Width
Else
If aBitmap.Height < aWantHt Then aWantHt = aBitmap.Height
aWantWid = aBitmap.Width * aWantHt/aBitmap.Height
End If
End If
End If
Dim bmpNew As Bitmap
bmpNew.InitializeMutable(aWantWid, aWantHt)
Dim cnv As Canvas
cnv.Initialize2(bmpNew)
Dim destRect As Rect
destRect.Initialize(0, 0, aWantWid, aWantHt)
cnv.DrawBitmap(aBitmap, Null, destRect)
Return bmpNew
End Sub
TIA
Widget