LUA Images Arithmetic Operations

Cours LUA Images Arithmetic Operations, tutoriel & guide de travaux pratiques en pdf.

Image library methods

number image.getfiletype(filename)
Orders FreeImage to analyze the bitmap signature. The function then re-turns 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.
Image image.load(filename)
Try to load image and use getfiletype to determinate the image type.
Image, height, bpp)
Create new image width specified width,height and bpp. Only bpp 8,24,32 are currently supported. Return a LUA userdata Image Object.

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)

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.
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()
Returns the size of one pixel in the bitmap in bits. For example when each pixel takes 32-bits of space in the bitmap, this function returns 32. Possible bit depths are 1, 4, 8, 16, 24, 32 for standard bitmaps and 16-, 32-, 48-, 64-, 96- and 128-bit for non standard bitmaps.
Image Image:rescale(width, height, FilterMethod)
Rescale object to width and height, using FilterMethod (see Costants).
Image Image:convert(bpp)
Change bpp of object to 8,24,32.
Image image:clone()
Makes an exact reproduction of an existing bitmap, including metadata and attached profile if any.
Image Image:crop(x0,y0,x1,y1)
Image Image:paste(x0,y0)
Image Image:rotateclassic(angle)
Image Image:blur(var)
Apply a gaussian blur on the image
Flip vertically the image
Flip horizzontally the image
Invert colors in image
Binarize image (0 under the threshold, 255 over the threshold)
Quantize the channel to n levels
Multiply any pixel value by f actor.
Add white noise to image
Change image gamma correction
Mix current image with image b using mask image m

Drawing API

Set the current drawing color
Draw a filled box using drawing color
Reset entire image using drawing color
Draw a rectangle (frame)
Draw a line
Draw a circle
Draw an ellipse
Draw a point using current color.
Image:pixel(x,y, grey)
Image:pixel(x,y, grey,alpha)
Image:pixel(x,y, r,g,b)
Image:pixel(x,y, r,g,b,alpha)
Draw a point using specified color.
(r,g,b,a) = Image:value(x,y)
Return the pixel value

Cours gratuitTélécharger le cours complet

Télécharger aussi :

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *