sprite-sheet-packer icon indicating copy to clipboard operation
sprite-sheet-packer copied to clipboard

Infinite loop on small images

Open roed opened this issue 5 years ago • 11 comments

Mac user here. It seems that when I use images smaller than 10px (10px width, 9px height, png), the application hangs and seems to go in an infinite loop. It says: Optimizing atlas in the bottom right corner. I have to force quit it to stop it. When I use an image of 10x10px, it's fine. I searched in the source code, but I am having a hard time to find out why it does that. There is a for and while loop after that statement that displays the message:

bool SpriteAtlas::packWithRect(const QVector<PackContent>& content) {

roed avatar Jun 18 '19 16:06 roed

Hi, please send me examples of files which cause this mistake, and the file of the project with settings

amakaseev avatar Jun 19 '19 12:06 amakaseev

spider

json of the project file:

{
    "algorithm": "Rect",
    "dataFormat": "pixijs",
    "destPath": "../../assets",
    "encryptionKey": "",
    "epsilon": 15,
    "heuristicMask": false,
    "imageFormat": "*.png",
    "jpgQuality": 80,
    "pixelFormat": "ARGB8888",
    "pngOptLevel": 7,
    "pngOptMode": "None",
    "premultiplied": true,
    "prependSmartFolderName": true,
    "rotateSprites": false,
    "scalingVariants": [
        {
            "forceSquared": false,
            "maxTextureSize": 2048,
            "name": "",
            "pow2": false,
            "scale": 1
        }
    ],
    "spriteBorder": 0,
    "spriteSheetName": "spritesheet",
    "srcList": [
    ],
    "textureBorder": 0,
    "trimMode": "Rect",
    "trimSpriteNames": true,
    "trimThreshold": 0,
    "webpQuality": 80
}

roed avatar Jun 21 '19 09:06 roed

I used this sprites: 11 22 33

and sprite sheet worked correctly

amakaseev avatar Jun 21 '19 09:06 amakaseev

did you also try the sprite I provided?

roed avatar Jun 21 '19 10:06 roed

i found mistake int step = (w + h) / 20;

incorrect calculate steps try fix this: int step = max( (w + h) / 20, 1);

amakaseev avatar Jun 21 '19 10:06 amakaseev

ah, so It would resolve to 0, hanging somewhere without doing any steps?

roed avatar Jun 21 '19 10:06 roed

yes, see last commit Thanks for the help :)

amakaseev avatar Jun 21 '19 10:06 amakaseev

Nice. Btw, the latest release is from 2017, will you create a new release soon?

roed avatar Jun 21 '19 10:06 roed

Oh I did not do it so long ago:)

amakaseev avatar Jun 21 '19 10:06 amakaseev

37 commits behind master ;)

roed avatar Jun 21 '19 10:06 roed

crashed when i choose a smaller size of the sprite sheet

jjhesk avatar Aug 11 '19 10:08 jjhesk