User Guide

Ruby Component
drawBitmapSection bitmap, source, position [, alpha, rotation, origin]
The 'bitmap' parameter is the bitmap you want to display. In the case of drawBitmapSection the 'source' parameter is a 4 element array
representing the rectangular section of the bitmap that you want to display. The rectangle array is defined by [x,y,w,h] where x,y define the
top-left and w,h define the size of the section in pixels.
The 'position' parameter can either be a two element array representing the top-left corner of where you want the bitmap to be displayed or it
can be a 4 element array representing the rectangle that you want to draw the bitmap into. The rectangle array is defined by [x,y,w,h] where
x,y define the top-left and w,h define the size in grid squares.
If you supply a point for the position then the bitmap draws at full size. If you supply a rectangle the bitmap (or section of bitmap) will be
stretched or reduced in size so as to fit exactly in the rectangle.
The 'alpha' parameter is optional. This is defines the transparency level for the drawn bitmap. It is an integer value in the range 0-255 with
255 being fully opaque and 0 being fully transparent. If you omit this parameter a value of 255 is assumed.
The 'rotation' parameter is also optional and allows you to rotate the bitmap through an angle, clockwise in degree. The origin of the rotation
is assumed to be the centre point of the bitmap unless you supply an 'origin' parameter, in which case this point is used instead. The origin
parameter is a two element array [x,y] where x and y are the coordinates of the rotation origin in grid squares.
The 'bitmap' parameter is an instance of the Bitmap class. There are four methods of this class for determining the bitmap size:
width
height
widthPixels
heightPixels
The width and height methods give you the size of the bitmap in grid squares at the current default zoom level. The widthPixels and
heightPixels methods give you the exact size of the bitmap in pixels.
Here's an example of a bitmap being drawn into a rectangle scaled down 12 times:
Bitmap Rendering Options
If you are drawing a bitmap into a rectangle that is a different size then you can choose how to render that bitmap by setting the interpolation
mode. This is done using the following View method:
setInterpolationMode mode
This takes either an integer (0-7) or one of the following strings:
"low","high","bilinear","bicubic","nearest","hqbilinear","hqbicubic"
You can also find out the current interpolation mode by using the following method. This will return one of the 8 strings shown above:
125 of 212