Skip to end of metadata
Go to start of metadata

Displays a TGA image stored on the SD card.

Image is a sub-class of Widget.

See also: How to create a TGA file

Constructor

mgf.createImage( filename [, xOffset ] [, yOffset ] )

ParameterTypeDescription
filename StringThe filename of the image
xOffset NumberThe x offset value
yOffset NumberThe y offset value
Contructor example
-- Create an image with filename: screvle1.tga placed in map tga
image1 = mgf.createImage( "tga/screvlel.tga" )

-- Create a second image with an x offset of 40 and y offset of 10
image2 = mgf.createImage( "tga/screvle.tga", 40, 10 )

Fields

FieldTypeDescriptionRead/Write
imageStringThe filename of the imageWrite Only
xOffsetNumberThe x offset valueWrite Only
yOffsetNumberThe y offset valueWrite Only

Examples

Example: image with offset
screvle = mgf.createImage( "tga/screvlel.tga" )
image1 = mgf.createImage( "tga/screvle.tga" )
image2 = mgf.createImage( "tga/screvle.tga", 40, 0 )	-- 40 pixels of the leftside will be cut off.
image3 = mgf.createImage( "tga/screvle.tga", 0, 0 )		
image4 = mgf.createImage( "tga/screvle.tga", 0, 10 )	-- 40 pixels of the top will be cut off.
panel = mgf.createPanel()
 
panel:addWidget( screvle, 38, 10, 164, 25 )				-- Display Screvle logo (screvlel.tga)
panel:addWidget( image1, 0, 75, 240, 34 )				-- Display original  (screvle.tga)
-- Offset and image file can still be changed:
--image1.image = "tga/screvlel.tga"  
--image1.xoffset = 40
--image1.yoffset = 10
 
panel:addWidget( image2, 40, 125, 200, 34 )				-- Cut off the left side: xoffset = 40
														-- Note: the width of the image is now 40px smaller
panel:addWidget( image3, 0, 175, 200, 34 )				-- Cut off the right side: when adding to the panel, make it 40px smaller
panel:addWidget( image4, 0, 225, 240, 14 )				-- Cut of the top ( yoffset = 10 ) and bottom ( remove 10px from height )
 
mgf.setWidget( panel )

Make sure added screvle.tga and screvlel.tga to the tga folder on the SD card.

screvle.tgascrevlel.tga

Image offset

The x/y offset will cut off a part (left-side & top-side) of the image, also adjusting the original height and width of the image. 

Cutting off the right-side & bottom-side of the image can be done by providing a smaller width & height than the original image when adding the image to the panel.

panel:addWidget( image, x_position, y_position, smaller_width, smaller_height ) 

 

  • No labels