Bug? Drawbitmap (with source) adding weird lines

sorex

Expert
Licensed User
Longtime User
Hello,

A while ago we got a method to have similar results as the drawbitmap method of B4A with source and destination selection. (https://www.b4x.com/android/forum/threads/drawbitmap-no-source-rectangle.47082/#post-291351)

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?
 

Attachments

  • maplines.zip
    9.5 KB · Views: 371

sorex

Expert
Licensed User
Longtime User
is XUI something that is available already for B4A & B4i hosted builder?
 

sorex

Expert
Licensed User
Longtime User
ok, found it. I'll try to figure it out how to use this.
 

sorex

Expert
Licensed User
Longtime User
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.
 

Attachments

  • createmap.zip
    28.9 KB · Views: 361

sorex

Expert
Licensed User
Longtime User
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.
 

sorex

Expert
Licensed User
Longtime User
it gets even more bizar.

when I pre-crop the tiles by code and then create imageviews where the bitmaps are assigned to the red line is also there.

Is the cropping also canvas based?

display.png
 

Attachments

  • precut.zip
    12.9 KB · Views: 322

Erel

B4X founder
Staff member
Licensed User
Longtime User
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.
 
Top