From Dabo Wiki
Jump to: navigation, search


dabo.ui.strToBmp(val, scale=None, width=None, height=None)


This can be either a path, or the name of a built-in graphic. If an adjusted size is desired, you can either pass a scale value (where 1.00 is full size, 0.5 scales it to 50% in both Height and Width), or you can pass specific height and width values. The final image will be a bitmap resized to those specs.


A bitmap of the specified image, or None if an invalid image was specified.


This is the heart of the simplification of image handling. It allows you to simply specify a file path for something like the Picture property of an dImage control, rather than having to manually read in the file and convert it from its native format to a display bitmap.


  • val - This is a string representing the image to be displayed. It can be either a file path, or the name of a built-in graphic, or a standard Dabo icon.
  • scale - A value by which the original image will be scaled. A value of 1 returns the image at its original size; a value of 2.5 returns the image enlarged by 2500%; a value of 0.6 returns the image reduced to 60% of its original size.
  • width, height - Rather than pass a percentage to scale the entire image, you can pass an absolute value for either the width or height (or both). The returned image will be resized to match the sizes you pass. If you pass, say, just a height value, the width will remain unchanged, and the height will be modified to the specified value.