Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Media Class - FloodFill Algorithm — Gideros Forum

Media Class - FloodFill Algorithm

drewfgdrewfg Member
edited February 2014 in General questions
I was thinking of the possibility of using the Media class (getPixel & setPixel) that is currently in the Labs with a floodfill algorithm. This would be used for a coloring book app. Do you think the performance would sufferer, especially when you get to the large high res tablets? Any thoughts?

Comments

  • I can try implementing it natively, just let me postpone it, till more bugs or featured requested in the lib.

    But in relatity, when LuaJIT will come, it pretty much won't matter if it is run in Lua or natively
  • @ar2rsawseen That would be awesome. Nice work on the media class so far. I will put in another plug for saving RenderTarget to an image file. :)
  • @ar2rsawseen,
    I had not seen the list of functionality included in Media Plugin. Just ran the same to check it, here's a couple to things

    1. It's amazing
    2. (this is device and OS specific) but when you take a image and then select use, it is a while before it responds, and it seems like the app has crashed/hung. I've faced that with another app of mine earlier.
    3. The media:save() where does it save, can this be altered (I can have a peek, but if this was specified, it would help)
    4. The Images snapped are usually 90 degrees, dunno why but it has happened with a previous app of mine.
    5. Take Picture (without the resize flag) is generally always just BLACK, I guess that could have something to do with the device being Low or out of memory, after all even on the iPhone4, the images are about 2-3 MB
    6. Take Screenshot is also pitch black, so there is something that is not working, either out of memory or some code issue.
    7. As the lag between the tap and the functionality of the button pressed in the demo, if anyone is interested, they can add these few lines to make it a bit more understandable/manageable.

    just after the function createText and before the --here we will store Bitmap isntance, add the following lines
     function alert(theMessage)
      local aD = AlertDialog.new( "YOUR APP NAME", theMessage or "Alert Message", "OK" )
      aD:show()
     end
    Now you can simply add
     alert("Done")
    at the end of each function, so that you are aware what finished and when.

    You can also add it to the checkCamera function as
    	local msg = "The camera is "
    	if mediamanager:isCameraAvailable() then
    		msg = msg .. " Available"
    	else
    		msg = msg .. " Unavailable"
    	end
    	alert(msg)
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • .. Played with the set Pixel and... it's a bit too slow to be implemented for flood fill. It might be easier and faster to create a CGGraphicContext (for iOS) and work on that.

    That brings us back to the old (unanswered) question, can we convert UIImage or such into a Gideros Image? Or is the only way to manipulate an image, save it as a png and then load the png into Gideros?

    The problem being loading an image is generally expected to be from the resources directory only :(
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • 2) I actually don't know if I can do something with it, because the most delay seems to be happening when loading the texture into Gideros. Only thing I could to is to resizing it before hand?

    3) when you create media object you either provide path (then save saves file to this path) or dimensions, then the file name is automatically generated.
    You can get the path using media:getPath() method
    Additionally you can create a copy and save where you want it to be, using media:copy(newPath)

    4) I can actually never predict in which orientation user takes the photo in. So all photos are passed as they are. Additionally you can provide an option to rotate the photo in your app, using media:rotate(degree) method

    5) This also could be a problem that texture is so big that it can be loaded into Gideros due to hardware limitations. Ok then what I think can be done is to provide the dimensions you want to resize photo to

    6) On IOS you need to enable additional option if you want screenshots:
    If you need screenshots then change:
    [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO]
    to YES
    inside EAGLView.m method - (id)initWithFrame:(CGRect)rect

    It is not optimal nor efficient solution, but it would have to do for now, till we are working on making it more efficient :)

    Also to make it crossplatform, the api was made that it only can be loaded from saved images, and not from platform specific objects like Android Bitmap or IOS UIImage

    And why would you think that image should only be expected from Resource directory?
    Bitmap also accepts global paths

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • @ar2rsawseen,
    as I said in point #1. it's amazing, I dug deeper into the plug-in source to have a look

    and some of the questions were answered there, specially in respect to the UIimage -> Save -> Load as Bitmap Texture in Gideros, because that's how it is being done and you have confirmed that too. I am not sure about how much time we can save (optimize) by avoiding that save/load and pass as Gideros CImage (equivalent) directly.

    Delay and rotation (I was providing you details, that it is common) it happens and you cannot do much about it, so if that is an issue, it is a feature with iOS.

    the only problem with Video playback is the orientation, but this is wonderful for in-game videos and for continuity between levels and start/end of the game, intro, etc.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
Sign In or Register to comment.