Author Topic: Correct image size from Atlas?  (Read 2665 times)

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Correct image size from Atlas?
« on: July 06, 2012, 01:23:30 AM »
Is there any way I can get the true image size when I add a sprite to an atlas. This has been bugging me for a while.

Ok, let's say I have a 256x256 of a guy's face. I have several faces.

Naturally the background is transparent. When I add these images to the atlas, none transparent lines of image will be omitted. eg, a 256x256 image may become something like 140x256.

Unfortunately then when I try to use the image that has been pre set in the atlas, the aspect ratio is the wrong shape :(
It will either be squished or in some cases be too big.

Any way to simply get around this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Correct image size from Atlas?
« Reply #1 on: July 06, 2012, 08:20:17 AM »
Call MakePixelPerfect() on the sprite after changing it (doesn't it do it automatically when you change the sprite anyway?)

Make sure you're using a regular UISprite, not a sliced sprite.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Correct image size from Atlas?
« Reply #2 on: July 09, 2012, 03:30:22 AM »
Yes, for some odd reason in some cases my sprites aren't being automatically, sometimes they are. But now that I think about it, they are sliced sprites when in reality they shouldn't be. This is probably what the problem could be. Thanks a lot for the tip.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Correct image size from Atlas?
« Reply #3 on: July 09, 2012, 03:36:38 AM »
Bizarrely it was the UISprites that were being weird, the Sliced UISprites were ok. Luckily, the MakePixelPerfect() trick worked. Many thanks for that :)

Now I can take out all my resizing kludge code.