Image deduplication doesn't work properly

0 favourites
  • 7 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • Problem Description

    Image deduplication doesn't work properly

    Attach a Capx

    Attached

    Description of Capx

    There are 5 sprite objects:

    The Number 1 has the image #1

    The Number 2 has the image #2

    The Number 3 has the image #3

    The Number 4 has the image #4

    The Number 5 has all the images (#1, 2, 3 and 4)

    Steps to Reproduce Bug

    • Step 1 Export project
    • Step 2 Open the "images" folder
    • Step 3 Check the exported images

    Observed Result

    There are duplicated images

    Expected Result

    I expect that Construct 2 removes the duplicated images

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Internet Explorer: (YES)

    Operating System and Service Pack

    Windows 8.1 Update 1 (64-bits)

    Construct 2 Version ID

    R185 (64-bits)

  • I can reproduce it here, at first i thought that the pictures are not pixel-perfect identical, so i saved 4 pictures from capx above to my desktop, started a new project, created 4 sprites (0, 2, 3 ,4) and 1 sprite with 4 images(5), load pictures from my desktop there (to be sure that sprite5 and others have identical images) and i have the same result after export, but i can reproduce it only if i "Import frames - From Files" to sprite5, if i create 4 empty frames in sprite5 and then "Load an image from a file" for each frame, everythings is exported right! This sounds like i lost my mind so heres the .capx

    Here i import frames to sprite5 and the bug appears

    [attachment=1:1estfoy2][/attachment:1estfoy2]

    Here i "Load an image from a file(folder icon in the editor and open the picture)" and everything exports fine

    [attachment=0:1estfoy2][/attachment:1estfoy2]

  • Sisyphus Yep. You are right, pretty weird ah!

  • I'm only 90% sure how this works. Image de-pulication only occurs with the frames in a single Sprite type and all of it's instances. C2 doesn't sadly doesn't use an Image Atlas. Instead all Sprite frames belong to that Sprite. If you have duplicate image frames in different sprites such as

    WeaponSpriteA has image Handle

    WeaponSpriteB has image Handle

    then no de-duplicaition will occur.

    However if you have

    WeaponSpriteAB has ImageFrames or Animations, 0-Handle, 1-Handle

    Then de-duplication will occur as having all the same images in the same Sprite.

    Since your saying you have 5 Sprite Objects(ie not instances, but full on separate objects) then yes. There is no de-duplication by design/limitation in the overall c2 architecture.

    I would personally feel better if C2 used an ImageAtlas and the Sprite/Frames/Animations referenced the atlas. Then there would be a solid de-duplication across all sprites. In the mean time. You will often hear me saying. Batch your sprite images into less sprite objects based on type and/or layers.

  • However if you have

    WeaponSpriteAB has ImageFrames or Animations, 0-Handle, 1-Handle

    Then de-duplication will occur as having all the same images in the same Sprite.

    Since your saying you have 5 Sprite Objects(ie not instances, but full on separate objects) then yes. There is no de-duplication by design/limitation in the overall c2 architecture.

    I'm not sure it's something with deduplication, see my post above, deduplication works as it's described in manual, but only if "Import Frames - From Files" is not used.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I checked in the debugger and the images have different hashes. Therefore they must have at least one tiny difference anywhere in the image. Image deduplication does work between different sprite objects, and I verified this works by replacing the first two images with an all-blue and all-red opaque rectangle, and it correctly deduplicates on export. So it is working. The question is how the images end up different.

    I would guess that happens due to alpha premultiplication somehow. Premultiplying then unpremultiplying is a lossy operation, but I don't know how that could happen. I checked and if you use "Import frames - from files" and choose a .png file, it simply copies the file to the project without touching it, so it should remain identical. Hmm...

  • I checked in the debugger and the images have different hashes. Therefore they must have at least one tiny difference anywhere in the image. Image deduplication does work between different sprite objects, and I verified this works by replacing the first two images with an all-blue and all-red opaque rectangle, and it correctly deduplicates on export. So it is working. The question is how the images end up different.

    I would guess that happens due to alpha premultiplication somehow. Premultiplying then unpremultiplying is a lossy operation, but I don't know how that could happen. I checked and if you use "Import frames - from files" and choose a .png file, it simply copies the file to the project without touching it, so it should remain identical. Hmm...

    Yeah, at first i tried it with the rectangles, and i can't reproduce. But if i try circles like the ones in the bug description, the import frames bug appears.

    Maybe the problem is in "Load an image from a file" ?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)