Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    freeImage/drawQuad corruption issues

    Bug Reporting (FUZE 4 Nintendo Switch)
    1
    1
    92
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      Nisse5 F last edited by Nisse5

      It seems like freeImage() of no longer used images can result in corruption, at least in combo with drawQuad(). I have not been able to figure out exactly why.

      This code creates a corrupted image, if the duplication is done twice. It seems like "img1" needs to be present when img3 is created, which seems very odd to me.

      w = 200
      h = 100
      
      function makeResizedImageCopy(oldimg, oldheight, newheight)
         newimg = createImage(w, newheight, image_rgba)
         setDrawTarget(newimg)
         topleft = {0, 0}
         topright = {w, 0}
         bottomright = {w, newheight}
         bottomleft = {0, newheight}
         drawQuad(oldimg, {0, 0, w, oldheight}, [topleft, toplight, bottomright, bottomleft], white)
         setDrawTarget(framebuffer)
         freeImage(oldimg)  // This is the problematic row!
      return newimg
      
      // Create a yellow square
      img1 = CreateImage(w, h, image_rgba)
      setDrawTarget(img1)
      clear(yellow)
      setDrawTarget(framebuffer)
      
      // Shrink copies in 2 steps
      img2 = makeResizedImageCopy(img1, 100, 80)
      img3 = makeResizedImageCopy(img2, 80, 60)
      
      // Display the last (corrupted) image
      loop
         clear()
         drawImage(img3, 10, 10)
         update()
      repeat
      

      If I remove freeImage() from the function and do something like this, it'll work:

      // Shrink copies in 2 steps
      img2 = makeResizedImageCopy(img1, 100, 80)
      img3 = makeResizedImageCopy(img2, 80, 60)
      freeImage(img1)
      freeImage(img2)
      

      If I remove freeImage() from the function but do like this, it'll NOT work:

      // Shrink copies in 2 steps
      img2 = makeResizedImageCopy(img1, 100, 80)
      freeImage(img1)
      img3 = makeResizedImageCopy(img2, 80, 60)
      freeImage(img2)
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post