You could also "embed" your images in the app to help protect resources, I make a point of always embedding the images in my PC apps as I think it looks better when you can just distribute a single .exe without having to have lot's of messy data files hanging around.
WhiteTree Games - Home, home on the web, where the bits and bytes they do play! #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
I'm planning to add an Image class to: - load png/jpg files - get/set pixels on it - create a Texture object from an Image object
So that the code
local image = Image.new("image.png")local texture = Texture.new(image)
will be (almost) same as
local texture = Texture.new("image.png")
On the other hand, I'm still thinking about whether Image class should load @2x or @half image files automatically. Most probably, it will also accept an additional parameter to control this behavior.
And then we'll have Bitmap, Image and Texture classes to confuse people more
I made these suggestions about PNGs because I'm working on a project that needs to create textures loading pngs from memory and render sprites (and its children) as png memory streams (to save/send). Just a new method in sprite class and a modification in the Texture class constructor to accept also the pngs directly as a string.
local png_stream = sprite:getPng()(...)local texture = Texture.new(png_stream)(...)
BTW, instead of adding Image class, did you consider using RGBA arrays? just two new functions:
-- Get a RGBA array from a PNG streamlocal rgba = pngToRgba(png)(...)-- read/write directly any pixel, for example: rgba.red[x] = 123; etc-- Get a PNG stream from a RGBA arraylocal png = rgbaToPng(rgba)(...)-- now you can save it, send it, make a texture...
I think Gideros would be really good managing graphics with these additions.
Bitmap, Texture is confusing already. Bitmap, Texture, and Image classes would certainly be confusing. What would be the difference between a Texture and Image?
If I understand the differences correctly I'd name them ImageSprite, ImageTexture, and ImageBuffer. It's kinda late to change the API that much though I think.
@Javi I understand now. For this, you need to wait for render to texture and I'm not sure when we'll support saving as png files.
@Magnusviri agree. Image and Texture are mostly similar. The main difference is the data of Image is stored at CPU memory but the data of Texture is stored at GPU memory. And it's easy/fast to modify the contents of an Image but finally you need to create a Texture to display it.
Comments
Likes: atilim
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
- load png/jpg files
- get/set pixels on it
- create a Texture object from an Image object
So that the code
And then we'll have Bitmap, Image and Texture classes to confuse people more
I made these suggestions about PNGs because I'm working on a project that needs to create textures loading pngs from memory and render sprites (and its children) as png memory streams (to save/send).
Just a new method in sprite class and a modification in the Texture class constructor to accept also the pngs directly as a string.
If I understand the differences correctly I'd name them ImageSprite, ImageTexture, and ImageBuffer. It's kinda late to change the API that much though I think.
My apps: http://www.yummyyellow.com
@Magnusviri agree. Image and Texture are mostly similar. The main difference is the data of Image is stored at CPU memory but the data of Texture is stored at GPU memory. And it's easy/fast to modify the contents of an Image but finally you need to create a Texture to display it.
My apps: http://www.yummyyellow.com
But I can not post the link.
stackoverflow.com/questions/17912415/gideros-image-dinamic-load-and-delete-from-memory