Difference between revisions of "Mediamanager:getPicture"
From GiderosMobile
(added real life example) |
|||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | |||
'''<translate>Available since</translate>:''' Gideros 2016.1<br/> | '''<translate>Available since</translate>:''' Gideros 2016.1<br/> | ||
'''<translate>Class</translate>:''' [[Special:MyLanguage/Media|Media]]<br/> | '''<translate>Class</translate>:''' [[Special:MyLanguage/Media|Media]]<br/> | ||
− | === | + | === Description === |
Allows user to select picture from gallery. | Allows user to select picture from gallery. | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 12: | Line 11: | ||
=== <translate>Return values</translate> === | === <translate>Return values</translate> === | ||
'''<translate>Returns</translate>''' (string) <translate>path to the picture</translate><br/> | '''<translate>Returns</translate>''' (string) <translate>path to the picture</translate><br/> | ||
+ | |||
+ | === Example === | ||
+ | <source lang="lua"> | ||
+ | local alertdialog = AlertDialog.new("ERROR", "TILE MUST BE 128 PIXELS\n", "OK") | ||
+ | btnloadtile:addEventListener("click", function() -- load external tile | ||
+ | local function mediareceive(e) | ||
+ | external_tile_bmp = Bitmap.new(Texture.new(e.path)) | ||
+ | local w, h = external_tile_bmp:getWidth(), external_tile_bmp:getHeight() | ||
+ | if w == h and w <= 128 then | ||
+ | g_tilesize = w | ||
+ | scenemanager:changeScene("tile", 0.5, transitions[21], easing.outBack) | ||
+ | else | ||
+ | alertdialog:show() | ||
+ | end | ||
+ | mediamanager:removeEventListener(Event.MEDIA_RECEIVE, mediareceive) | ||
+ | end | ||
+ | mediamanager:getPicture() -- opens windows/android file explorer | ||
+ | mediamanager:addEventListener(Event.MEDIA_RECEIVE, mediareceive) | ||
+ | end) | ||
+ | </source> | ||
{{Media}} | {{Media}} |
Revision as of 14:35, 16 March 2020
Available since: Gideros 2016.1
Class: Media
Description
Allows user to select picture from gallery.
(string) = mediamanager:getPicture()
Return values
Returns (string) path to the picture
Example
local alertdialog = AlertDialog.new("ERROR", "TILE MUST BE 128 PIXELS\n", "OK")
btnloadtile:addEventListener("click", function() -- load external tile
local function mediareceive(e)
external_tile_bmp = Bitmap.new(Texture.new(e.path))
local w, h = external_tile_bmp:getWidth(), external_tile_bmp:getHeight()
if w == h and w <= 128 then
g_tilesize = w
scenemanager:changeScene("tile", 0.5, transitions[21], easing.outBack)
else
alertdialog:show()
end
mediamanager:removeEventListener(Event.MEDIA_RECEIVE, mediareceive)
end
mediamanager:getPicture() -- opens windows/android file explorer
mediamanager:addEventListener(Event.MEDIA_RECEIVE, mediareceive)
end)
- X Media:copy
- X Media:crop
- X Media:drawFill
- X Media:drawImage
- X Media:drawLine
- X Media:drawText
- X Media:flipHorizontal
- X Media:flipVertical
- X Media:floodFill
- X Media:getHeight
- X Media:getPath
- X Media:getPixel
- X Media:getRotation
- X Media:getWidth
- X Media:resize
- X Media:resizeHeight
- X Media:resizeWidth
- X Media:save
- X Media:setPixel
- X Media:setRotation
- X Media:trim