Difference between revisions of "Media"
(remove language stuff) |
m |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
=== Description === | === Description === | ||
− | * Get image from Camera, gallery or file system | + | '''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''' | ||
+ | |||
+ | * Get/save files from file system (desktop only) | ||
+ | * Get image from Camera, gallery or file system (mobile and desktop) | ||
* Resize image | * Resize image | ||
* Make copy of an image | * Make copy of an image | ||
* Take screenshots | * Take screenshots | ||
* Play videos (for cutscenes) | * Play videos (for cutscenes) | ||
− | * Manipulate pictures (getting/setting pixels) | + | * Manipulate pictures (getting/setting pixels, flood fill) |
* And much more... | * And much more... | ||
+ | |||
+ | <syntaxhighlight lang="lua"> | ||
+ | require "media" | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ===='''[[Media_Plugin|Here is an extensive example]]'''==== | ||
+ | |||
+ | === '''Notes''' === | ||
+ | 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 === | === Example === | ||
− | + | '''Saving a picture on your phone or on your PC''' | |
− | < | + | <syntaxhighlight lang="lua"> |
require "media" | require "media" | ||
Line 35: | Line 53: | ||
mybmprt:setPosition(64, 64) | mybmprt:setPosition(64, 64) | ||
stage:addChild(mybmprt) | stage:addChild(mybmprt) | ||
− | </ | + | </syntaxhighlight> |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
{|- | {|- | ||
Line 48: | Line 59: | ||
=== Methods === | === Methods === | ||
[[mediamanager:deleteFile]] ''deletes file at provided path''<br/><!--GIDEROSMTD:mediamanager:deleteFile(path) deletes file at provided path--> | [[mediamanager:deleteFile]] ''deletes file at provided path''<br/><!--GIDEROSMTD:mediamanager:deleteFile(path) deletes file at provided path--> | ||
+ | [[mediamanager:getFile]] ''selects file from file system''<br/><!--GIDEROSMTD:mediamanager:getFile(extensions, initialPath) selects file from file system--> | ||
[[mediamanager:getPicture]] ''selects picture from gallery''<br/><!--GIDEROSMTD:mediamanager:getPicture() selects picture from gallery--> | [[mediamanager:getPicture]] ''selects picture from gallery''<br/><!--GIDEROSMTD:mediamanager:getPicture() selects picture from gallery--> | ||
[[mediamanager:isCameraAvailable]] ''returns true if you can get picture from camera''<br/><!--GIDEROSMTD:mediamanager:isCameraAvailable() returns true if you can get picture from camera--> | [[mediamanager:isCameraAvailable]] ''returns true if you can get picture from camera''<br/><!--GIDEROSMTD:mediamanager:isCameraAvailable() returns true if you can get picture from camera--> | ||
[[mediamanager:playVideo]] ''plays video file in given path (bool force to watch till the end, or quit playing on tap)''<br/><!--GIDEROSMTD:mediamanager:playVideo(path, force) plays video file in given path (bool force to watch till the end, or quit playing on tap)--> | [[mediamanager:playVideo]] ''plays video file in given path (bool force to watch till the end, or quit playing on tap)''<br/><!--GIDEROSMTD:mediamanager:playVideo(path, force) plays video file in given path (bool force to watch till the end, or quit playing on tap)--> | ||
[[mediamanager:postPicture]] ''adds picture from given path to gallery (or opens save file dialog on pc)''<br/><!--GIDEROSMTD:mediamanager:postPicture(path) adds picture from given path to gallery (or opens save file dialog on pc)--> | [[mediamanager:postPicture]] ''adds picture from given path to gallery (or opens save file dialog on pc)''<br/><!--GIDEROSMTD:mediamanager:postPicture(path) adds picture from given path to gallery (or opens save file dialog on pc)--> | ||
+ | [[mediamanager:saveFile]] ''saves file to file system''<br/><!--GIDEROSMTD:mediamanager:saveFile(path, initialPath) saves file to file system--> | ||
[[mediamanager:takePicture]] ''allows user to provide picture input from camera''<br/><!--GIDEROSMTD:mediamanager:takePicture() allows user to provide picture input from camera--> | [[mediamanager:takePicture]] ''allows user to provide picture input from camera''<br/><!--GIDEROSMTD:mediamanager:takePicture() allows user to provide picture input from camera--> | ||
[[mediamanager:takeScreenshot]] ''captures a screenshot of the app''<br/><!--GIDEROSMTD:mediamanager:takeScreenshot() captures a screenshot of the app--> | [[mediamanager:takeScreenshot]] ''captures a screenshot of the app''<br/><!--GIDEROSMTD:mediamanager:takeScreenshot() captures a screenshot of the app--> |
Latest revision as of 23:31, 16 October 2024
Supported platforms:
Available since: Gideros 2016.1
Description
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
- 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...
require "media"
Here is an extensive example
Notes
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
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)
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 |