UI_BITMAP_CREATE Function
Syntax
Arguments
- name
The name of the bitmap to create.
- Width
The width in inches of the bitmap to create.
- Height
The height in inches of the bitmap to create.
Description
Create a bitmap of name, Width inches wide, Height Inches high.
Discussion
UI_BITMAP_CREATE() creates a new bitmap in cache memory. By default, this data is in Windows Bitmap (.BMP) format. Use BITMAP_TO_JPEG()or BITMAP_TO_PNG()to convert to JPEG (.JPG) or Portable Network Graphics (.PNG) file image formats. Use <FILE>.WRITEB()to write the data to a file.It is necessary to delete bitmaps with UI_BITMAP_DROP()after you are finished with them.
Example
Get the original color image, then extract the color data and the alpha channel data.
png_data = file.to_blob("c:\documents\Xbasic Reference\Images\toucan.png") rgb_data = png_to_bitmap(png_data, "R") trans_data = png_to_bitmap(png_data, "A")
Create two bitmaps from the color data and the alpha channel data.
ui_bitmap_load("rgb", rgb_data) ui_bitmap_load("trans", trans_data)
Calculate the positions of the three images.
pixsize = ui_bitmap_info_get(rgb_data, "w,h") xpix = val(word(pixsize, 1, ",") ) ypix = val(word(pixsize, 2, ",") ) xperin = ui_info(4) yperin = ui_info(5) width = xpix/xperin height = ypix/yperin
Combine the three images.
ui_bitmap_create("combine", width, height) stone_data = file.to_blob("C:\WINDOWS\Greenstone.bmp") ui_bitmap_load("Stone", stone_data) ui_bitmap_draw("combine", <<%code% bitmap("stone", 0, 0) bitmap_alpha("rgb", 0, 0, "trans") %code%)
Display the three images.
Limitations
Desktop applications only.
See Also