Ok.. newImage() again...

I am currently writing code to change the background of my playfield with an user selected image.

For this I let the user select an image from the library and to save it and retain it’s state I write that image into the documents folder like this: “userid_back.jpg” …

Because I thought it is cool to save time rendering stuff I also overlay that image with data before I save it!

The thought was to pick an image… render stuff… save it… free the picked one… load the save one into the stage.

Next time the application starts it finds the image and loads it instead of the default backgrounds.

Problem: The name of this image… and a newly selected… overlayed… saved image is the same.

I have to create temp names to save/load … then rename it to the (standard) name used at load time.

I consider this a bug… reading again the same filename with different content in the filesystem should load the new image!

If you absolutely need to be “smart” caching stuff. Make it controllable! Let us free them… let us refresh them.

And! Check file modification dates if you cache anything loaded from the filesystem! [import]uid: 6928 topic_id: 1313 reply_id: 301313[/import]

Why not save a preference which is the name of the image you want to load? It’d be much faster. [import]uid: 54 topic_id: 1313 reply_id: 3582[/import]

@Eric

I do save the image name I use in my preferences. But that only works for the images which are local to the application (come with it… or are copied to its document folder like I do in what my OP explains).

It is not about that something is slow. The Save/Load Cycle is needed so that the resulting image does not need any more overlay to be rendered every frame.

Think of a chessboard with alpha shaded fields… lines… text labels… now the user can load ANY image as background. I can easily load it… render the stuff… save a snapshot … load it… ditch all the rendering and have a new “board” as image.
Besides of this… having a workaround for a bad implementation does not satisfy me and should not satisfy you.

I actually was thinking for some time what causes my image not changing after the initial one until I realized that the newImage caching by “name” was the culprit (of course).

Sure I could write the newly loaded image under changing names into the documents folder. For some strange reason I thing calling it “user_background.jpg” is just better than “user_r3random442234.jpg” … dunno … just how I think stuff should be.

P.S.: I would love to be able to “prerender” stuff without saving… and I would love to be able to save it loseless… [import]uid: 6928 topic_id: 1313 reply_id: 3584[/import]