/* Copyright (C) 2011, Stephane Bisaro, aka iri License : you can do what you want with this source code This code is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. */ /* This example shows some common bitmap's manipulations. Doc : http://www.scolring.org/files/doc_html/bitmap.html Scol type : ObjBitmap To create an empty bitmap : _CRbitmap To load a bitmap file : _LDbitmap (bmp) To load a bitmap file : _LDjpeg (jpg) To load a bitmap file : _LDtga (tga) Note : png file give an AlphaBitmap object, not an ObjBitmap To destroy a bitmap : _DSbitmap If any, you can work on several bitmaps and copy all in a last bitmap (by example). You can display a bitmap on some graphics components (window, container, etc). See others examples on the wiki : http://redmine.scolring.org/projects/scol/wiki/Examples */ fun transform (bmp)= // retrieve the size of the bitmap let _GETbitmapSize bmp -> [width height] in // load the Scol logo let _LDbitmap _channel _checkpack "logo.bmp" -> logo in // create a font-reference from Arial. With 1800, the string will displayed upside down let _CRfont _channel 24 1800 FF_WEIGHT "Arial" -> font in ( // draw a blue rectangle inside our bitmap. The border has a width of 4 pixels _DRAWrectangle bmp 25 25 width-50 height-50 DRAW_SOLID 4 0xdd4444 DRAW_INVISIBLE 0; // copy the logo at the top left corner of the rectangle with a transparency color (here, white) _CPbitmap24 bmp 10 10 logo 0 0 64 64 0xFFFFFF; // draw a red circle at the center of the bitmap _DRAWcircle bmp width/2 height/2 200 DRAW_SOLID 2 0x4444dd DRAW_INVISIBLE 0; // draw a gradent inside a second rectangle _DRAWgradient bmp (width/2)-100 (height/2)-100 200 200 0x00FF00 0x006600 90; // Write a string at the center of the bitmap _DRAWtext bmp font width/2 height/2 TD_CENTER|TD_BASELINE 0xDddDdd "Hello wolrd !"; // copy the logo at the bottom right corner of the rectangle without a transparency color _CPbitmap24 bmp width-74 height-74 logo 0 0 64 64 nil; // process a gaussian blur on a second logo _BLURbitmap bmp width-74 height-74 64 64 10 5; // destroy the font, no longer needed _DSfont font; 0 );; fun main ()= _showconsole; // create an empty bitmap with a given size (500 x 500 pixels) let _CRbitmap _channel 500 500 -> bmp in ( // paint the bitmap in white _FILLbitmap bmp 0xFFFFFF; // call the function to transform our bitmap transform bmp; // save the result in a jpg file _SAVEjpeg bmp _getmodifypack "tutorials/bitmap/transformation.jpg" 85; // end _DSbitmap bmp; // don't forget to destroy the bitmap at the end _fooS "Done !"; 0 );;