image sets

Ok I am late to the game about using Image Sets. Using them allows me to not worry about the @1x, @2x, @3x versions and which one to use. Now I have many apps that have static images in a database (SQLite, PostgreSQL, etc) that I display in real time. Currently I have a PNG (I like PNGs over other formats) that is hex encoded to a string an put in a field in the database. When I go to display the image I create a new image from the decoded hex string as I display it.

Now how would I do it with Image Sets? They seem to be like some sort of container of the actual images but I am not sure. Can I treat them as a PNG image or do I have to do something special?

Thanks!
sb

Interesting question, not sure how to do this.

If you only have one size picture then you don’t really need to worry about it.

If you have multiple size pictures (of the same aspect ratio), you can combine them into an image by using the new Picture constructor. Then you use this new Picture (of type Image) and the appropriate size will be chosen based on what best matches the screen scaling.

More information is in the HiDPI Support topic.

@Paul Lefebvre lets say I want to have the @1x, @2x, & @3x to support the various HiPPI, how to do store that image set in a database?

Part of it depends on how you store it in the database. Store the X1,2,3 images in the database like you always do. Either add that to the name or add a scale factor field. Then use the Picture Constructor that Paul linked to above to pass the array of pictures.

As 3 separate pictures - hex encoded

To recreate an “image” - which is just a special kind of picture that contains many pictures - you pull each image out into an array and then use this constructor
http://documentation.xojo.com/index.php/Picture.Constructor(width_as_Integer,_height_as_Integer,_bitmaps()_As_Picture)