This method seems to work fine to copy part of an image into another image just holding that data.
When using it to copy several parts of an image to the same destination bitmap it seems to have some strange line bugs.
The result is some weird lines near the tile edges.
When I pull a screenshot it looks blurred too.
I tried disabling anti-aliasing on both source and destination imageviews but it doesn't seem to do much.
the logs shows some info indicating that everything appears to be correctly calculated and no extra scaling happends and creates extra blur.
Kind of hard to create single screen bitmap tile based screens if something like this doesn't work.
How can this be solved or is there some other (objC) method that works easier than this shifted clip method?
I managed to make it xui based so that equal code runs on android and IOS.
on android it's 100% correct on IOS are the gaps.
I figured out where it goes wrong.
whenever you use canvas drawbitmap it's applying blurring that I can't seem to turn off with the antialias disabling code in the source.
this blur still grabs a pixel outside of the actual tile that's why you get these strange lines.
removing the gutter seems like a solution as long as the tile colors are near equal.
leaving the gutter will make the last pixels blend with a transparent one.
attached is proof that it still fails it you place a white and red tile in the tile map and display twice the white tile.
you'll see a fine red line coming from the second tile.
worst case I'll need to split up the tile image and load it into seperate imageview and take a snapshot of that panel,
not sure if that's possible and if it is if it applies again some blur if it gets scaled to screensize.
1. Don't invalidate the canvas inside the loop. It will be more efficient to invalidate it once when done.
2. You are never removing the previous ImageView. Each time the page is resized you are adding another one.
in the middle of the white box you'll see a fine red vertical line which is actually the first pixel of the second tile in the tilemap image that the anitalias/blur of drawbitmap seems to include.
Example of code that draws a part of the current bitmap on the same bitmap:
B4X:
Sub Page1_Click
Dim c As Canvas
c.Initialize(Page1.RootPanel)
c.DrawCircle(100dip, 100dip, 100dip, Colors.Red, True, 0)
c.Refresh
Dim r As Rect
r.Initialize(200dip, 200dip,300dip, 300dip)
Dim b As Bitmap = c.CreateBitmap.Crop(0, 0, 100dip, 100dip)
c.DrawBitmap(b, r)
c.Refresh
c.Release
End Sub
For further discussion please start a new thread in the questions forum.