Difference between revisions of "Media"

From GiderosMobile
m (reformatting)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 +
 
<languages />
 
<languages />
 +
 
<!-- GIDEROSOBJ:Media -->
 
<!-- GIDEROSOBJ:Media -->
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
+
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]
'''<translate>Available since</translate>:''' Gideros ?<br/>
+
<br/>
 +
 
 +
'''<translate>Available since</translate>:''' Gideros ?
 +
<br/>
 +
 
 
=== <translate>Description</translate> ===
 
=== <translate>Description</translate> ===
 
<translate>
 
<translate>
* Get images from Camera or gallery/file system
+
* Get image from Camera, gallery or file system
* Resize the image or make copy of them
+
* Resize image
 +
* Make copy of an image
 
* Take screenshots  
 
* Take screenshots  
* Play videos for cutscenes
+
* Play videos (for cutscenes)
* Manipulate pictures by getting/setting pixels
+
* Manipulate pictures (getting/setting pixels)
* And much more
+
* And much more...
 
</translate>
 
</translate>
  
 
=== <translate>Notes</translate> ===
 
=== <translate>Notes</translate> ===
 
By resizing image you will actually resize the file of the image, so there is no going back to upscale it later.
 
By resizing image you will actually resize the file of the image, so there is no going back to upscale it later.
 
+
<br/>
 
getPicture method gives you copies of the image, so you won't harm the original.
 
getPicture method gives you copies of the image, so you won't harm the original.
 
+
<br/>
 
The dimensions when resizing are all actual dimensions of the image and not logical dimensions in your project.
 
The dimensions when resizing are all actual dimensions of the image and not logical dimensions in your project.
 
+
<br/>
  
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Methods</translate> ===
 
=== <translate>Methods</translate> ===
mediamanager:isCameraAvailable() -- returns true is you can get picture from camera
+
'''mediamanager:isCameraAvailable()''' -- returns true is you can get picture from camera<br/>
 +
'''mediamanager:takePicture()''' -- allow user to provide picture input from camera<br/>
 +
'''mediamanager:getPicture()''' -- allow user to select picture from gallery<br/>
 +
'''mediamanager:takeScreenshot()''' -- capture the screenshot of the app<br/>
 +
'''mediamanager:postPicture(path)''' -- add picture from given path to gallery (or open save file dialog on pc)<br/>
 +
'''mediamanager:playVideo(path, force)''' -- play video file in given path (bool force to watch till the end, or quit playing on tap)<br/>
 +
'''mediamanager:deleteFile(path)''' -- deletes file at provided path<br/>
 +
<br/>
  
mediamanager:takePicture() -- allow user to provide picture input from camera
+
'''Media.new(path)''' -- create new Media object with provided image<br/>
 +
'''Media.new(width, height)''' -- create blank Media object with provided dimensions<br/>
 +
'''Media:getPath()''' -- returns the path that was used to create object<br/>
 +
'''Media:getWidth()''' -- returns the width of the image<br/>
 +
'''Media:getHeight()''' -- returns the height of the image<br/>
 +
'''Media:getPixel(x, y)''' -- returns r, g, b, a values of pixel at x,y coordinate (RGB are in range of 0 to 255, alpha is in range of 0 to 1)<br/>
 +
'''Media:setPixel(x, y, r, g, b, a)''' -- sets r, g, b, a values to pixel at x,y coordinate (RGB are in range of 0 to 255, alpha is in range of 0 to 1)<br/>
 +
'''Media:setPixel(x, y, hex, a, blendAlpha)''' -- sets hex, a values to pixel at x,y coordinate (alpha is in range of 0 to 1)<br/>
 +
'''Media:resizeWidth(newWidth, fixed)''' -- resize image width, if fixed is true image is resized with fixed aspect ratio<br/>
 +
'''Media:resizeHeight(newHeight, fixed)''' -- resize image height, if fixed is true image is resized with fixed aspect ratio<br/>
 +
'''Media:resize(newWidth, newHeight, fixed, crop)''' -- resize image to new width and new height, if fixed is true image is resized with fixed aspect ratio and takes crop value into account (by either cropping image if true, or doing letterbox resize if false)<br/>
 +
'''Media:crop(x, y, width, height)''' -- crop with and height from x and y point from a given image<br/>
 +
'''Media:copy(destination)''' -- make a copy of the image<br/>
 +
'''Media:save()''' -- save the changes made to file<br/>
 +
'''Media:setRotation()''' -- rotate image to provided angle in degrees<br/>
 +
'''Media:getRotation()''' -- return previously set rotation<br/>
 +
'''Media:getRotation()''' -- return previously set rotation<br/>
 +
'''Media:flipHorizontal()''' -- flip image horizontally<br/>
 +
'''Media:flipVertical()''' -- flip image vertically<br/>
 +
'''Media:drawImage(x, y, media, alpha)''' -- draw another image on current one at specific x and y coordinates. You can provide either another media object or string path to image file<br/>
 +
'''Media:drawText(x, y, text, hexColor, fontSize, alpha)''' -- draw a text at provided coorindates with provided settings<br/>
 +
'''Media:drawLine(x0, y0, x1, y0, hexColor, alpha, blendAlpha)''' -- draw a line from x0,y0 to x1,y1 with provided settings<br/>
 +
'''Media:drawFill(x, y, width, height, hexColor, alpha, blendAlpha)''' -- draw filled rectangle at x,y position with width,height dimensions and with provided settings<br/>
 +
'''Media:floodFill(x, y, hexColor, alpha, tolerance, blendAlpha)''' -- fill area with provided color based on tolerance to other colors<br/>
 +
'''Media:trim(hexColor)''' -- trim image by provided background color, if color is not provided, uses top left pixel to crop<br/>
  
mediamanager:getPicture() -- allow user to select picture from gallery
+
| style="width: 50%; vertical-align:top;"|
 
 
mediamanager:takeScreenshot() -- capture the screenshot of the app
 
 
 
mediamanager:postPicture(path) -- add picture from given path to gallery (or open save file dialog on pc)
 
 
 
mediamanager:playVideo(path, force) -- play viedo file in given path (bool force to watch till the end, or quit playing on tap)
 
 
 
mediamanager:deleteFile(path) -- deletes file at provided path
 
 
 
Media.new(path) -- create new Media object with provided image
 
 
 
Media.new(width, height) -- create blank Media object with provided dimensions
 
 
 
Media:getPath() -- returns the path that was used to create object
 
 
 
Media:getWidth() -- returns the width of the image
 
 
 
Media:getHeight() -- returns the height of the image
 
 
 
Media:getPixel(x, y) -- returns r, g, b, a values of pixel at x,y coordinate (RGB are in range of 0 to 255, alpha is in range of 0 to 1)
 
 
 
Media:setPixel(x, y, r, g, b, a) -- sets r, g, b, a values to pixel at x,y coordinate (RGB are in range of 0 to 255, alpha is in range of 0 to 1)
 
 
 
Media:setPixel(x, y, hex, a, blendAlpha) -- sets hex, a values to pixel at x,y coordinate (alpha is in range of 0 to 1)
 
 
 
Media:resizeWidth(newWidth, fixed) -- resize image width, if fixed is true image is resized with fixed aspect ratio
 
 
 
Media:resizeHeight(newHeight, fixed) -- resize image height, if fixed is true image is resized with fixed aspect ratio
 
 
 
Media:resize(newWidth, newHeight, fixed, crop) -- resize image to new width and new height, if fixed is true image is resized with fixed aspect ratio and takes crop value into account (by either cropping image if true, or doing letterbox resize if false)
 
 
 
Media:crop(x, y, width, height) -- crop with and height from x and y point from a given image
 
 
 
Media:copy(destination) -- make a copy of the image
 
  
Media:save() -- save the changes made to file
 
 
Media:setRotation() -- rotate image to provided angle in degrees
 
 
Media:getRotation() -- return previously set rotation
 
 
Media:getRotation() -- return previously set rotation
 
 
Media:flipHorizontal() -- flip image horizontally
 
 
Media:flipVertical() -- flip image vertically
 
 
Media:drawImage(x, y, media, alpha) -- draw another image on current one at specific x and y coordinates. You can provide either another media object or string path to image file
 
 
Media:drawText(x, y, text, hexColor, fontSize, alpha) -- draw a text at provided coorindates with provided settings
 
 
Media:drawLine(x0, y0, x1, y0, hexColor, alpha, blendAlpha) -- draw a line from x0,y0 to x1,y1 with provided settings
 
 
Media:drawFill(x, y, width, height, hexColor, alpha, blendAlpha) -- draw filled rectangle at x,y position with width,height dimensions and with provided settings
 
 
Media:floodFill(x, y, hexColor, alpha, tolerance, blendAlpha) -- fill area with provided color based on tolerance to other colors
 
 
Media:trim(hexColor) -- trim image by provided background color, if color is not provided, uses top left pixel to crop
 
| style="width: 50%; vertical-align:top;"|
 
 
=== <translate>Events</translate> ===
 
=== <translate>Events</translate> ===
 
[[Special:MyLanguage/Event.MEDIA_RECEIVE|Event.MEDIA_RECEIVE]] ''(e.path) -- path to image''<br/><!-- Event.MEDIA_RECEIVE mediaReceive-->
 
[[Special:MyLanguage/Event.MEDIA_RECEIVE|Event.MEDIA_RECEIVE]] ''(e.path) -- path to image''<br/><!-- Event.MEDIA_RECEIVE mediaReceive-->
Line 95: Line 75:
  
 
=== <translate>Constants</translate> ===
 
=== <translate>Constants</translate> ===
 +
 
|}
 
|}

Revision as of 02:03, 3 August 2019



Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.png

Available since: Gideros ?

Description

  • Get image from Camera, gallery or file system
  • Resize image
  • Make copy of an image
  • Take screenshots
  • Play videos (for cutscenes)
  • Manipulate pictures (getting/setting pixels)
  • And much more...

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.

Methods

mediamanager:isCameraAvailable() -- returns true is you can get picture from camera
mediamanager:takePicture() -- allow user to provide picture input from camera
mediamanager:getPicture() -- allow user to select picture from gallery
mediamanager:takeScreenshot() -- capture the screenshot of the app
mediamanager:postPicture(path) -- add picture from given path to gallery (or open save file dialog on pc)
mediamanager:playVideo(path, force) -- play video file in given path (bool force to watch till the end, or quit playing on tap)
mediamanager:deleteFile(path) -- deletes file at provided path

Media.new(path) -- create new Media object with provided image
Media.new(width, height) -- create blank Media object with provided dimensions
Media:getPath() -- returns the path that was used to create object
Media:getWidth() -- returns the width of the image
Media:getHeight() -- returns the height of the image
Media:getPixel(x, y) -- returns r, g, b, a values of pixel at x,y coordinate (RGB are in range of 0 to 255, alpha is in range of 0 to 1)
Media:setPixel(x, y, r, g, b, a) -- sets r, g, b, a values to pixel at x,y coordinate (RGB are in range of 0 to 255, alpha is in range of 0 to 1)
Media:setPixel(x, y, hex, a, blendAlpha) -- sets hex, a values to pixel at x,y coordinate (alpha is in range of 0 to 1)
Media:resizeWidth(newWidth, fixed) -- resize image width, if fixed is true image is resized with fixed aspect ratio
Media:resizeHeight(newHeight, fixed) -- resize image height, if fixed is true image is resized with fixed aspect ratio
Media:resize(newWidth, newHeight, fixed, crop) -- resize image to new width and new height, if fixed is true image is resized with fixed aspect ratio and takes crop value into account (by either cropping image if true, or doing letterbox resize if false)
Media:crop(x, y, width, height) -- crop with and height from x and y point from a given image
Media:copy(destination) -- make a copy of the image
Media:save() -- save the changes made to file
Media:setRotation() -- rotate image to provided angle in degrees
Media:getRotation() -- return previously set rotation
Media:getRotation() -- return previously set rotation
Media:flipHorizontal() -- flip image horizontally
Media:flipVertical() -- flip image vertically
Media:drawImage(x, y, media, alpha) -- draw another image on current one at specific x and y coordinates. You can provide either another media object or string path to image file
Media:drawText(x, y, text, hexColor, fontSize, alpha) -- draw a text at provided coorindates with provided settings
Media:drawLine(x0, y0, x1, y0, hexColor, alpha, blendAlpha) -- draw a line from x0,y0 to x1,y1 with provided settings
Media:drawFill(x, y, width, height, hexColor, alpha, blendAlpha) -- draw filled rectangle at x,y position with width,height dimensions and with provided settings
Media:floodFill(x, y, hexColor, alpha, tolerance, blendAlpha) -- fill area with provided color based on tolerance to other colors
Media:trim(hexColor) -- trim image by provided background color, if color is not provided, uses top left pixel to crop

Events

Event.MEDIA_RECEIVE (e.path) -- path to image
Event.MEDIA_CANCEL --user canceled media input
Event.VIDEO_COMPLETE --user completed watching video

Constants