I am currently doing something like this
heroSprite = Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("test.png"));
Size d =heroSprite->getContentSize();
now d has a size of 190 x 127 however this is the size that I get on disk 411 x 272
My question is why is the size showing up different ?
And then I have another Sprite that has a size of 342 x 262 on disk and when I do
Size m =Sprite->getContentSize();
I get 342 x 262 the same as on disk, My question is why is the first image different on disk and different with getContentSize while the second one is the same on disk and method. I havent scaled any of those images ?
Is your test.png inside a packed texture? That would be my guess. test.png was originally 190x127 before it was packed into a larger packed.png with a size of 411x272. If not then something strange is occurring.
What do you mean by a packed texture ? I got the image from my graphics artist.
I then dumped that file into Texture Packer. The texture packer then generates the .plist file and I read the file from the plist file. Is there a way for me to check if its a packed texture ?
You can add margins around images using TexturePacker so check the image in there. If you hover over the image in the spritesheet preview it will tell you the dimensions.
When you use TexturePacker it takes a bunch of images, in your case let’s assume each is 200x100 and you have 4 images test.png, test2.png, test3.png, test4.png. It generates a packed_textures.plist and packed_textures.png. This PNG on disk is 400x200 in order to fit all 4 images. When you create a sprite with one of the frames inside that packed texture, in your case test.png it creates a sprite using the original frame image’s size, so the sprite would have a content size of 200x100.
Hope that makes sense, if not you should read up on the documentation.
@trojanfoe
@stevetranby
@i__d__k
Thank you all for your comments and suggestions. I have been struggling with this for a couple of days now and I am still not sure why I am getting this.After a little more investigation here is what I have noticed. My image.png size on macOSX tells me its 411 x 272. However when I drag that into texture packer and hover my mouse over that image in texture packer it tells me that the “original size” of the image is 190 x 127 . Why is that ? Why is it saying that my image size is smaller than its actual dimension.@stevetranby You mentioned earlier that the output image generated by Texture Packer would be >= sum of all of my images .I understand that however my question is a bit different. As I mentioned earlier why is the size of an image on disk different and when imported into texture packer I am told by texture packer (by mouse hovering) that its original size is less than whats reported by the OS (Finder in Mac)
test.png itself is a file on disk whose size is 411x272. Once this file is dropped into texture packer and hovered over its original size is displayed as 190x127. Why is that ? I haven’t even published the sprite sheets yet ?
Check your settings. You may have “Crop” enabled? Open test.png in an image editor and confirm that it’s 411x272 and if you mark a rectangle around all visible (non-transparent) pixels you will likely see a box roughly 190x127. That’s my guess. Unless you post the image and .tps file you probably aren’t going to get any better answers. TexturePacker is pretty well battle tested. It’s likely something in the settings or an oddity in the image itself.
Thanks for posting Ill have a look at the image and if I cant figure it out I will post the image and the tps file. Thanks