About Store Forum Documentation Contact



Post Reply 
ImageAtlas correct usage
Author Message
Scoring Offline
Member

Post: #1
ImageAtlas correct usage
Hello,

I'm unsure how to get images from ImageAtlas correctly.

I have an atlas:
ImageAtlas* icons = ImageAtlases(my UID...);

Str sIcon = S + "goal_" + TextInt(data.goalid);
ImagePtr icon = &icons.images(icons.getPart(sIcon).image_index);

goalid is 1 and I get sIcon as "goal_1" which is a valid entry in atlas.

For icon, I get the entire Atlas back, not the goal_1 entry I expected.. (Not only for screen, if I export it to for example png, it also contains the entire atlas like thumbnails.)

I tried with findPart method, but it gives back null for goal_1.

Thanks

hm it is weird.
if I use findPartI, Im getting the correct index (5 actually), but I cant access the image...
I expected it is in images container (mems<image>) but my atlas.images.elms shows 1...
(This post was last modified: 06-30-2014 07:59 PM by Scoring.)
06-30-2014 07:06 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: ImageAtlas correct usage
The purpose of the Image Atlas is to combine multiple images into one image.

Esenthel RTS uses Image Atlas, maybe you'd like to check it out.

http://www.esenthel.com/?id=doc#Image_Atlas
07-01-2014 01:19 AM
Find all posts by this user Quote this message in a reply
Scoring Offline
Member

Post: #3
RE: ImageAtlas correct usage
Yeah I get what it is, I would like know how to use smile
I'm just expecting a short yes/no answer, did I access to atlas correctly?
The documentation doesn't say anything about usage. (parts, findpart, getpart, etc)
I hope I must not buy an RTS source to figure out how to use a simple UI element...

MyAtlas.images(x) should give back the xth image from atlas which I get from getPartI ?

   

so the index=5 I have seems correct.
but atlas.images(5) gives back an empty image with 0 width and 0 height...
images.elms should show 15, shouldnt?
(This post was last modified: 07-02-2014 02:01 PM by Scoring.)
07-02-2014 01:59 PM
Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #4
RE: ImageAtlas correct usage
No, maybe you have 1 or 2 images in the atlas. All those images(elements) you see are combined in to a few images.
(This post was last modified: 07-02-2014 04:07 PM by cmontiel.)
07-02-2014 04:04 PM
Find all posts by this user Quote this message in a reply
Scoring Offline
Member

Post: #5
RE: ImageAtlas correct usage
so I cant get back individual items from atlas?
ok, then I try without atlas...
07-02-2014 07:01 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: ImageAtlas correct usage
Hi,

Did you read the headers?

I think they're pretty self-explanatory:
Code:
struct ImageAtlas // Image Atlas, set of multiple images packed into as few textures as possible
{
   struct Part // single image stored in one of the textures
   {
      Byte  image_index  ; // index of the image in 'images' in which the part is located
      Rect  tex_rect     ; // UV texture coordinates of the part (after trimming)
      Vec2  center_offset; // offset which you can apply for drawing assuming that the anchor point was located in the center of the original image, it's equal to "Vec2(trim_pos.x-original_size.x/2, -trim_pos.y+original_size.y/2)" (in pixels)
      VecI2 original_size, // size of the image (in pixels, without trimming)
            trimmed_size , // size of the image (in pixels, after   trimming)
            trim_pos     ; // position in the original image where the trim has started (in pixels)
      Str   name         ; // name of the part
   };

   Mems<Image> images;
   Mems<Part > parts

you use "Byte image_index ; // index of the image in 'images' in which the part is located" to access the correct Image from 'images' and then 'Rect tex_rect' gives you texture UV coordinates for desired part in that image.
07-03-2014 01:11 AM
Find all posts by this user Quote this message in a reply
Scoring Offline
Member

Post: #7
RE: ImageAtlas correct usage
Seems it is not self-explanatory for everyone smile
I think it is just not that I searched.
I just needed a simple way to access images by name (and not by UID or FID) assembled in a string and didnt want play with UVs for a simple UI.
Thanks anyway.
07-03-2014 09:14 AM
Find all posts by this user Quote this message in a reply
Scoring Offline
Member

Post: #8
RE: ImageAtlas correct usage
OK l I cant figure out how to use the given Rect.
I would need a pointer to the Image part... I use it in a List as column as datatype ImagePtr.

Should I crop the Atlas image?

I found a method called drawPart but Im not sure how to apply to List...

Also, I would be happy if I just can grab an image which name stored in a Str.

I made a folder called GoalImages and I have some image assets under it:

GoalImages
--goal_1
--goal_2

But neither worked from the following :(
sIcon is "goal_1"

Images(sIcon, "GoalImages")
Images.requirePtr(sIcon, "GoalImages")

Both show image not found goal_1 additional path GoalImages message.
07-07-2014 04:29 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
RE: ImageAtlas correct usage
Hi,

The list always takes the entire image, and not a part, so unless you extend the List class for custom drawing codes (source could be helpful) then you may need to use Images instead of ImageAtlas for that.

Please see the doc for accessing assets:
http://www.esenthel.com/?id=doc#Accessing_Assets
http://www.esenthel.com/?id=doc#Project_Files

You cannot use a name, you need to use the ID.
07-08-2014 12:01 AM
Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #10
RE: ImageAtlas correct usage
Atlas is not for what you want to do.
(This post was last modified: 07-08-2014 12:14 AM by cmontiel.)
07-08-2014 12:12 AM
Find all posts by this user Quote this message in a reply
Scoring Offline
Member

Post: #11
RE: ImageAtlas correct usage
(07-08-2014 12:01 AM)Esenthel Wrote:  You cannot use a name, you need to use the ID.

Thats bad. I get the image name from an external database.
There is no conversion method between asset name and its UID?
like GetUID("asset name") ?
07-08-2014 01:08 PM
Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #12
RE: ImageAtlas correct usage
? I tried to reply but looks like my answer was modified.
07-08-2014 02:26 PM
Find all posts by this user Quote this message in a reply
Scoring Offline
Member

Post: #13
RE: ImageAtlas correct usage
Well I updated my SQL database to hold the FileIDs so now works, though I would have prefer a simpler solution like creating ID from asset name.

My only wish remained having an option to set a row background image in List smile

Hmm and seems imageSize has no effect in List... I tried with various settings and in order, but the image in column has always the same size, probably synced with text height.

   
(This post was last modified: 07-08-2014 04:03 PM by Scoring.)
07-08-2014 03:46 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #14
RE: ImageAtlas correct usage
(07-08-2014 02:26 PM)cmontiel Wrote:  ? I tried to reply but looks like my answer was modified.
Most of your replies didn't apply to this situation smile so I've removed them to avoid confusion. We're using latest Esenthel version
07-08-2014 10:39 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #15
RE: ImageAtlas correct usage
The image size works only if the list is in list rects draw mode. You can easily draw images below the entire list by extending the virtual draw method and drawing images there manually before the list
07-08-2014 10:41 PM
Find all posts by this user Quote this message in a reply
Post Reply