1 Introduction
For information about LUA programming, visit www.lua.org. This book is not intended to explain how develop LUA application, but only how to concern LIP software native function extensions.
LIP source code are under GPL license.
LIP uses FreeImage ( http://freeimage.sourceforge.net/) and Free- Type ( http://sourceforge.net/projects/freetype).
Due to particular reference frame provided by FreeImage the coordinate (0,0) of image are placed in bottom-left corner.
2 API
2.1 System Call
Return the number of argument passed to script string argv(number n) return the n-th param.
2.2 Image Library
Image is an object (user data with metatables), image is image library.
2.3 Image library methods
number image.getfiletype(filename)
Orders FreeImage to analyze the bitmap signature. The function then returns one of the predefined FREE IMAGE FORMAT constants or a bitmap identification number registered by a plugin. Because not all formats can be identified by their header, filename extension are used to determinate the file format.
number image.getfiletypebyext(filename)
Return the predefined FREE
IMAGE FORMAT constants looking only the filename extension.
Image image.load(filename, FormatID, flag = 0)
This function decodes a bitmap, allocates memory for it and then returns it as a Image (Lua UserData/Object). A parameter defines the type of bitmap to be loaded. For example, when FIF BMP is passed, a BMP file is loaded into memory (an overview of possible FREE IMAGE FORMAT constants is available in Constants section). Optional Flag (default is 0) can be used to change some load specific behaviour.
2.3.1 Images Arithmetic Operations
Image image.add(a,b)
Sum (clamping) two images
Image image.sub(a,b)
Subtract (clamping) two images
Image image.lightest(a,b)
Return lightest pixels of two images
Image image.darkest(a,b)
Return darkest pixels of two images
Image image.avg(a,b)
Return mix of the images
Image image.blend(a,b,perc)
Mix image of the images using perc factor (0.0 .. 1.0)
2.4 Image Methods
Image:save(filename, FormatID, flag = 0)
Save image onto filename with FormatID file format (see Costants). Flag (0 used as default) can used to specify image quality.
Image:save(filename)
Save image onto filename using format returned by getfiletypebyext
number Image:width()
number Image:height()
Returns the width,height of the bitmap in pixel units.
number Image:bpp()
LUA Image Processor (122.28 KO) (Cours PDF)