Bug? Drawbitmap (with source) adding weird lines

Discussion in 'iOS Bugs & Wishlist' started by sorex, Feb 13, 2018.

  1. sorex

    sorex Expert Licensed 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?
     

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    I recommend you to use XUI library instead of this code.

    You will need to use another canvas for this. Copy the relevant region to the second canvas and then draw it back.
     
  3. sorex

    sorex Expert Licensed User

    is XUI something that is available already for B4A & B4i hosted builder?
     
  4. sorex

    sorex Expert Licensed User

    ok, found it. I'll try to figure it out how to use this.
     
  5. sorex

    sorex Expert Licensed 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.
     

    Attached Files:

  6. Erel

    Erel Administrator Staff Member Licensed User

    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.
     
  7. sorex

    sorex Expert Licensed User

    I know, it's just a test not a production code ;)
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    I'm seeing a black screen with a small white box when I run your code.

    Not sure what it supposed to demonstrate...
     
  9. sorex

    sorex Expert Licensed 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.
     
  10. sorex

    sorex Expert Licensed 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
     

    Attached Files:

  11. Erel

    Erel Administrator Staff Member Licensed User

    Example of code that draws a part of the current bitmap on the same bitmap:
    Code:
    Sub Page1_Click
       
    Dim c As Canvas
       c.Initialize(Page1.RootPanel)
       c.DrawCircle(
    100dip100dip100dipColors.Red, True0)
       c.Refresh
       
    Dim r As Rect
       r.Initialize(
    200dip200dip,300dip300dip)
       
    Dim b As Bitmap = c.CreateBitmap.Crop(00100dip100dip)
       c.DrawBitmap(b, r)
       c.Refresh
       c.Release
    End Sub
    For further discussion please start a new thread in the questions forum.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice