Save a bitmap file. The path must be to a .bmp file.
Example: SaveBitmap(Bmp,"c:/out.bmp");
bitmap=LoadBitmap(file-path)
Load a bitmap file and return a pointer to that bitmap. The path must be to a .bmp or a .gif file.
Example: Bmp=LoadBitmap("c:/in.bmp");
Bitmaps creators
bitmap=CreateBitmap(width,height)
Create an empty non initialised bitmap.
Example: Bmp=CreateBitmap(100,100);
bitmap=CopyBitmap(bitmap)
Create a bitmap similar to another bitmap
Example: Bmp2=CopyBitmap(Bmp);
bitmap=Crop(bitmap,x,y,width,height)
Extract a part of a bitmap.
Example: Bmp2=Crop(Bmp,0,0,640,480);
bitmap=Resize(bitmap,width,height)
Create a resized version bitmap.
Example: Bmp2=Resize(Bmp,640,480);
DestroyBitmap(bitmap)
Destroy a bitmap.
Example: DestroyBitmap(Bmp);
bitmap=CaptureImage()
Capture image from the webcam. Note, when you don't use them anymore, do not forget to destroy these bitmaps.
Example: Bmp=CaptureImage();
Example:
-- Display webcam image
Wnd=OpenWindow(320,240,"Webcam");
while (1==1) do
Bmp=CaptureImage();
DisplayBitmap(Bmp,Wnd);
DestroyBitmap(Bmp);
end
Bitmaps properties
height=BmpHeight(bitmap)
Height of a bitmap.
Example: H=BmpHeight(Bmp);
width=BmpWidth(bitmap)
Width of a bitmap.
Example: W=BmpWidth(Bmp);
r,g,b,a=GetPixel(bitmap,x,y)
Return components of a given pixel of the bitmap.
Return -1 for all components if you're off bitmap.
If alpha layer isn't defined, return -1 for a component.
Example: r,g,b,a=GetPixel(Bmp,x,y);
Bitmaps modifiers
Tint(bitmap,r,g,b)
Turn bitmap into a colored one by Applying the following formula: red=red*r/256 green=green*g/256 blue=blue*b/256
r,g,b are [0..255]
Example: Tint(Bmp,255,0,0);
Grey(bitmap,hue,sat)
Turn bitmap into a monochrome one.
hue,sat are [0..255]
Example: Grey(Bmp,0,0); (will turn the bitmap into a black and white one)
Dynamic(bitmap,black-level,white-level)
Change the dynamic of the image. Each pixel will go trhough the formula p=(p-black)/(white-black)*256
Example: Dynamic(Bmp,50,200); (will make a more nervous image)
Example: Dynamic(Bmp,-50,300); (will cool things down)
Example: Dynamic(Bmp,255,0); (will make a negative image)
Example: Dynamic(Bmp,126,127); (will make all greys under 127 black and all greys above 127 white)
Negate(bitmap,what)
Negate one (or more) component of the image.
"H": if the 'what' string contains H, hue will be negated.
"S": if the 'what' string contains S, saturation will be negated.
"V": if the 'what' string contains V, value will be negated.
"R": if the 'what' string contains R, red will be negated.
"G": if the 'what' string contains G, green will be negated.
"B": if the 'what' string contains B, blue will be negated.
Example: Negate(Bmp,"rgb");
Blur(bitmap)
Blur the bitmap.
Example: Blur(Bmp);
Retinex(bitmap,filter-bank,weight)
Apply a retinex filter to the image.
Filter-bank can be:
0:UNIFORM
1:LOW
2:HIGH
3:SHARP
4:FLAIR
Known bug: memory leak when using Retinex
Example: Retinex(Bmp,2,2.0);
Blit(source-bitmap,x,y,w,h,dest-bitmap,xx,yy)
Copy the content of a rectangle from one bitmap to another (it can be the same bitmap as well, but then to obtain a significant result you need to blit to another position).
Example: Blit(Bmp,0,0,BmpWidth(Bmp),BmpHeight(Bmp)/2,Bmp2,0,0); -- copy the lower half of Bmp into Bmp2
Mask handling
ShowMask(bitmap)
Copy the alpha layer (if there is one) as shades of grey into the bitmap.
Example: ShowMask(Bmp);
BlurMask(bitmap)
Blur the alpha layer (if there is one) of the bitmap.
Example: BlurMask(Bmp);
ErodeMask(bitmap)
Erode the alpha layer (if there is one) of the bitmap.
Example: ErodeMask(Bmp);
DilateMask(bitmap)
Dilate the alpha layer (if there is one) of the bitmap.
Example: DilateMask(Bmp);
AddColourToMask(bitmap,r,g,b)
Add all rgb pixels as transparent pixels in the alpha layer.
Allows alternative name AddColorToMask()
Example: AddColourToMask(Bmp,0,0,255);
AutoContour(bitmap,r,g,b,tolerance)
Add all pixels close to rgb as transparent pixels in the alpha layer.
Example: AutoContour(Bmp,0,0,255,4);
Bitmaps fonts
TextAlign(x)
Select a horizontal text alignment directive.
0: align left
-0.5: align center
-1: align right
x: add x times the width of the string to the position where the text should be displayed
Example: TextAlign(0);
TextVAlign(x)
Select a vertical text alignment directive.
0: align top
-0.5: align middle
-1: align bottom
x: add x times the height of the string to the position where the text should be displayed
Example: TextVAlign(-0.5);
TextUseInk()
Display text using the standard ink directive.
Example: TextUseInk();
TextUseTexture(bitmap)
Display text using a texture bitmap instead of a plain color.
Example: TextUseTexture(bitmap);
TextFont(font-bitmap)
Use the font 'font-bitmap' to display subsequent text.
Insert the bitmap 'bitmap-to-insert' at position x,y into the bitmap 'dest-bitmap' using a mask bitmap 'opacity-bitmap'.
black pixels in the opacity bitmap will make the corresponding bitmap in 'bitmap-to-insert' transparent, white pixels will make the corresponding pixel in 'bitmap-to-insert' fully opaque.
Example: Mix(Bmp,20,20,Bmp2,BmpMask);
Insert(dest-bitmap,x,y,bitmap-to-insert)
Insert the bitmap 'bitmap-to-insert' at position x,y into the bitmap 'dest-bitmap'.
Example: Insert(Bmp,20,20,Bmp2);
Stain(dest-bitmap,x,y,bitmap-to-insert)
Insert the bitmap 'bitmap-to-insert' at position x,y into the bitmap 'dest-bitmap'. The effect will be as if the 'bitmap-to-insert' was printed on a transparency and glued above the original bitmap.
Example: Stain(Bmp,20,20,Bmp2);
Bleach(dest-bitmap,x,y,bitmap-to-insert)
Insert the bitmap 'bitmap-to-insert' at position x,y into the bitmap 'dest-bitmap'. The effect will be as if the 'bitmap-to-insert' was used as a source of light.
Example: Bleach(Bmp,20,20,Bmp2);
Draw primitives
Point(bitmap,x,y)
Draw a point at coordinates x,y (0,0 is lower left corner)
Example: Point(Bmp,10,10);
Line(bitmap,x,y,xx,yy)
Draw a line from coordinates x,y to coordinates xx,yy (0,0 is lower left corner)
Example: Line(Bmp,5,10,500,100);
Circle(bitmap,x,y,r)
Draw a outline circle centered on coordinates x,y with a radius of r (0,0 is lower left corner)
Example: Circle(Bmp,50,50,10);
CircleFill(bitmap,x,y,r)
Draw a filled circle centered on coordinates x,y with a radius of r (0,0 is lower left corner)
Draw a outline rectangle, with lower left corner at coordinates x,y and a width of w and a height of h (0,0 is lower left corner)
Negative w and/or h are allowed
Allows alternative name Rectangle()
Example: Rect(Bmp,50,50,10,10);
RectFill(bitmap,x,y,w,h)
Draw a filled rectangle, with lower left corner at coordinates x,y and a width of w and a height of h (0,0 is lower left corner)
Negative w and/or h are allowed
Allows alternative name RectangleFill()
Example: RectFill(Bmp,50,50,10,10);
Triangle(bitmap,x,y,xx,yy,xxx,yyy)
Draw a outline triangle, going from x,y to xx,yy and then xxx,yyy and back to x,y (0,0 is lower left corner)
Example: Triangle(Bmp,50,50,10,10,100,30);
TriangleFill(bitmap,x,y,xx,yy,xxx,yyy)
Draw a filled triangle, going from x,y to xx,yy and then xxx,yyy and back to x,y (0,0 is lower left corner)
Example: TriangleFill(Bmp,50,50,10,10,100,30);
Interaction with user
Alert(string)
Display an alert box, halt execution until the user have clicked on OK.
Example: Alert("hello world !\nsecond line");
window=OpenWindow(width,height,title_string)
Open a window.
Example: Window=OpenWindow(640,480,"Balls");
window=DisplayBitmap(bitmap,window)
Display the bitmap 'bitmap' in the window 'window'. In future version, will create a new window
if needed (ie if a window doesn't already display that bitmap). This explain why this function
returns a window handle.
Example: Window=DisplayBitmap(Bmp,Window);
x,y,b=Mouse(window)
Returns the last mouse position for window 'window'. x and y are the position coordinates.
b is the current mouse button state, sum of
1 left mouse button
2 middle mouse button
4 right mouse button
8 CTRL key
16 SHIFT key
Example: x,y,b=Mouse(Window);
vx,vy=MouseSpeed(window)
Returns mouse speed for window 'window'. Speed is the average speed for the last 5 positions of the mouse.
Example: vx,vy=MouseSpeed(Window);
Color arythmetic
H,S,V=RgbToHsv(R,G,B)
Convert R,G,B color (with R=[0..255], G=[0..255], B=[0..255]) to H,S,V color (H=[0..255], S=[0..255], V=[0..255]).
If case of grey shade, H is assumed to be 0;
Example: h,s,v=RgbToHsv(255,23,45);
R,G,B=HsvToRgb(H,S,V)
Convert H,S,V color (H=[0..255], S=[0..255], V=[0..255]) to R,G,B color (with R=[0..255], G=[0..255], B=[0..255]).
Example: r,g,b=HsvToRgb(155,23,45);
R,G,B=BlendRgb(R1,G1,B1,R2,G2,B2,coef)
Blend (R1,G1,B1) with (R2,G2,B2). If coef=0, pure (R1,G1,B1) is returned. If coef=1, pure (R2,G2,B2) is returned.
Set the color that will be used in subsequent line,rect,... operations
Example: Ink(0,0,0)
Paper(r,g,b)
Set the background color that will be used in subsequent operations
Example: Paper(255,255,255)
Opacity(a)
Set the transparency that will be used in subsequent line,rect,... operations
Example: Opacity(0) (transparent, don't draw)
Example: Opacity(255) (opaque)
Opacity(a,type)
Set the transparency that will be used in subsequent line,rect,... operations.
type can be "MIX" for mix, "BLEACH" for bleach or "STAIN" for stain. If the type isn't given
(or not M,B or S), it stay unchanged. The default begining type is "MIX".
You can give the first letter only (m,s or b) either upper of lower case.
Same color used with mix, bleach and stain transparencies:
Example: Opacity(0,"M") (transparent, don't draw)
Example: Opacity(255,"M") (opaque)
Thickness(w)
Set the width of the pen that will be used in subsequent line,rect,... operations
Example: Thickness(1) (normal, 1 pixel)
Example: Thickness(10) (thick, 10 pixel)
Example: Thickness(0) (don't draw)
Influence of modifiers
Ink
Paper
Thickness
Opacity
Opacity type
Transform
Point
YES
NO
YES
YES
YES
YES
Line
YES
NO
YES
YES
YES
YES
Triangle
YES
NO
YES
YES
YES
YES
TriangleFill
YES
NO
NO
YES
YES
YES
Rect
YES
NO
YES
YES
YES
Position and size, but stay rectangular
RectFill
YES
NO
NO
YES
YES
Position and size, but stay rectangular
Circle
YES
NO
YES
YES
YES
Position and size, but stay circular
CircleFill
YES
NO
NO
YES
YES
Position and size, but stay circular
Poly
YES
NO
YES
YES
YES
YES
PolyFill
YES
NO
NO
YES
YES
YES
Bleach
NO
NO
NO
YES
NO:bleach
NO
Stain
NO
NO
NO
YES
NO:stain
NO
Insert
NO
NO
NO
YES
NO:mix
NO
Lua
Lua beeing the scripting component of Lew, all the Lua language constructions
and commands are obviously availables. You can get a documentation of the Lua
language here: http://www.lua.org.