Difference between revisions of "Lua:Class:Picture"
Jump to navigation
Jump to search
AntumDeluge (talk | contribs) (→Examples: Better variable name) |
AntumDeluge (talk | contribs) (Update inheritence, description, & methods) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
− | Picture '''class''': ('''Inheritence''':) | + | Picture '''class''': ('''Inheritence''': ''[[Object]]'') |
− | <span style="color:red; font-weight:bold; font-style:italic;">WARNING: This page | + | <span style="color:red; font-weight:bold; font-style:italic;">WARNING: This page may be unfinished.</span> |
+ | |||
+ | == Description == | ||
+ | |||
+ | Container for the Graphic class. | ||
== Creation == | == Creation == | ||
− | ; createPicture() : Picture | + | ; createPicture() : ''Picture'' |
− | : Returns | + | : Returns an empty picture object. |
== Properties == | == Properties == | ||
Line 34: | Line 38: | ||
: | : | ||
− | ; loadFromStream | + | ; loadFromStream(''stream''<nowiki>[</nowiki>, ''originalextension''<nowiki>]</nowiki>) |
− | : | + | : Loads a picture from a stream. Note that the stream position must be set to the start of the picture. |
− | ; assign | + | ; assign(''sourcepicture'') |
: | : | ||
− | ; getGraphic | + | ; getGraphic() |
: | : | ||
− | ; getPNG | + | ; getPNG() |
: | : | ||
− | ; getBitmap | + | ; getBitmap() |
: | : | ||
− | ; getJpeg | + | ; getJpeg() |
: | : | ||
Line 62: | Line 66: | ||
pic.loadFromFile("icon.png") | pic.loadFromFile("icon.png") | ||
form.Icon = pic.getBitmap() | form.Icon = pic.getBitmap() | ||
+ | </pre> | ||
+ | |||
+ | <pre> | ||
+ | -- create menu bar for main interface | ||
+ | local menu = createMainMenu(form) | ||
+ | local menu_file = createMenuItem(menu) | ||
+ | menu_file.setCaption("File") | ||
+ | local mi_open = createMenuItem(menu_file) | ||
+ | mi_open.setCaption("Open") | ||
+ | |||
+ | -- add icon to "Open" menu item | ||
+ | local ico_open = createPicture() | ||
+ | ico_open.loadFromFile("data/bitmap/menu/open.png") | ||
+ | mi_open.Bitmap = ico_open.getBitmap() | ||
</pre> | </pre> | ||
Latest revision as of 14:41, 14 February 2019
Picture class: (Inheritence: Object)
WARNING: This page may be unfinished.
Contents
Description[edit]
Container for the Graphic class.
Creation[edit]
- createPicture() : Picture
- Returns an empty picture object.
Properties[edit]
- Graphic
- PNG
- Bitmap
- Jpeg
- Icon
Methods[edit]
- loadFromFile(filename)
- Loads an image from a local file.
- saveToFile(filename)
- loadFromStream(stream[, originalextension])
- Loads a picture from a stream. Note that the stream position must be set to the start of the picture.
- assign(sourcepicture)
- getGraphic()
- getPNG()
- getBitmap()
- getJpeg()
Examples[edit]
-- main interface local form = createForm() -- add icon to Form title bar local pic = createPicture() pic.loadFromFile("icon.png") form.Icon = pic.getBitmap()
-- create menu bar for main interface local menu = createMainMenu(form) local menu_file = createMenuItem(menu) menu_file.setCaption("File") local mi_open = createMenuItem(menu_file) mi_open.setCaption("Open") -- add icon to "Open" menu item local ico_open = createPicture() ico_open.loadFromFile("data/bitmap/menu/open.png") mi_open.Bitmap = ico_open.getBitmap()