Difference between revisions of "Media"
m (Text replacement - "<source" to "<syntaxhighlight") |
|||
Line 14: | Line 14: | ||
* And much more... | * And much more... | ||
− | < | + | <syntaxhighlight lang="lua"> |
require "media" | require "media" | ||
</source> | </source> | ||
Line 30: | Line 30: | ||
=== Example === | === Example === | ||
'''Saving a picture on your phone or on your PC''' | '''Saving a picture on your phone or on your PC''' | ||
− | < | + | <syntaxhighlight lang="lua"> |
require "media" | require "media" | ||
Revision as of 14:28, 13 July 2023
Supported platforms:
Available since: Gideros 2016.1
Description
- Get/save files from file system (desktop only)
- Get image from Camera, gallery or file system (mobile and desktop)
- Resize image
- Make copy of an image
- Take screenshots
- Play videos (for cutscenes)
- Manipulate pictures (getting/setting pixels, flood fill)
- And much more...
<syntaxhighlight lang="lua"> require "media" </source>
Notes
This plugin is not available for windows 32 bits The Media functions wiki pages are prefixed by X_ because media is a reserved wiki word
By resizing image you will actually resize the file of the image, so there is no going back to upscale it later.
getPicture method gives you copies of the image, so you won't harm the original.
The dimensions when resizing are all actual dimensions of the image and not logical dimensions in your project.
Example
Saving a picture on your phone or on your PC <syntaxhighlight lang="lua"> require "media"
-- draw your gfx local source = Pixel.new(0xff00ff, 1, 128, 128) -- create a render target and draw to it local rt = RenderTarget.new(source:getWidth(), source:getHeight()) rt:draw(source) -- save your render target to gideros documents folder local myfilepath = "|D|mysavedpicture2.png" rt:save(myfilepath) -- create a new media and save your gfx local media = Media.new(myfilepath) -- android saved path = internal storage/pictures !!! NEED permission write external storage !!! mediamanager:postPicture(myfilepath)
-- show your gfx on stage local mybmprt = Bitmap.new(Texture.new(myfilepath)) mybmprt:setPosition(64, 64) stage:addChild(mybmprt) </source>
Methodsmediamanager:deleteFile deletes file at provided path Media.new creates a new Media object with provided image Media:copy(destination) makes a copy of an image |
EventsEvent.MEDIA_RECEIVE (e.path) path to image Constants |