Common AlphaBitmap manipulations in Scol¶
An AlphaBitmap Scol object is a bitmap with an alpha channel. This alpha can be nil.
It can be created from a bitmap object or it can be loaded from a PNG resource file.
All functions of this API are described here.
Create an AlphaBitmap¶
The ObjBitmap8 object¶
This is 8-bits bitmap object insteaf of the 24-bits for the ObjBitmap. Lonely, it is rarely used but it can be an alpha channel.
This API is near than the ObjBitmap API, see Common bitmap manipulations in Scol.
We can create it from a resource file (8-bits BMP file, _LDbitmap8) or from ex-nihilo (_CRbitmap8). Like ObjBitmap, don't forget to destroy them when you no longer needed (_DSbitmap8).
AlphaBitmap¶
The AlphaBitmap type is an opaque Scol type.
Use the Scol function _CRalphaBitmap or _LDalphaBitmap to create a such object.
AlphaBitmap _CRalphaBitmap <channel> <bitmap_object> <bitmap8_object> <background_color> <transparency_color>
The <bitmap_object> is in 24-bits (RVB), <bitmap8_object> is in 8-bits and it is the alpha channel.
See _CRalphaBitmap
AlphaBitmap _LDalphaBitmap <channel> <reference_reading_png_file>
Destruction¶
When a such object is no longer needed, you should quickly destroy it with _DSalphaBitmap.
How to load a graphic resource file in Scol ?¶
Two near ways enough near if you want to have an ObjBitmap or an AlphaBitmap.
This function is helpful and you should get in your common library.
/* Load a graphic resource file pfile : P : the reading-reference file channel : channel to loading return the object to create fun [P Chn] ObjBitmap fun [P Chn] AlphaBitmap */ fun loadRscFile2ObjBitmap (pFile, channel)= if pFile == nil then nil else let _LDbitmap channel pFile -> bmp in if bmp == nil then let _LDjpeg channel pFile -> jpeg in if jpeg == nil then let _LDtga channel pFile -> tga in if tga == nil then let _GETalphaBitmaps _LDalphaBitmap channel pFile -> [png _] in png else tga else jpeg else bmp;; fun loadRscFile2AlphaBitmap (pFile, channel)= if pFile == nil then nil else let _LDbitmap channel pFile -> bmp in if bmp == nil then let _LDjpeg channel pFile -> jpeg in if jpeg == nil then let _LDtga channel pFile -> tga in if tga == nil then _LDalphaBitmap channel pFile else _CRalphaBitmap channel tga nil nil nil else _CRalphaBitmap channel jpeg nil nil nil else _CRalphaBitmap channel bmp nil nil nil;;
Updated by iri about 12 years ago · 2 revisions