[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    Bitmap(3X) manual page Table of Contents

Name

Bitmap - bit mapped data

Synopsis

#include <ivplus/bitmap.h>

Description

Bitmap is a two dimensional array of boolean values. Bitmaps can be used in Painter operations and to define window manager icons for top-level interactors. Bitmaps can be constructed from data contained in a file, from data supplied by the application or from a font character. Geometric transformations and painting operations are performed relative to the bitmap’s origin. Bitmap is derived from Resource and has an initial reference count of 1.

Class Hierarchy

Bitmap -> Resource

Constructor

Bitmap (const void* data, unsigned int width, unsigned int height, int x = -1, int y = -1)

Create a bitmap from the data specified. The data format is the same as that of a bitmap(1) file. The width and height are the size of the bitmap in pixels and the bitmap’s origin is located at <x, y>.

Bitmap (const Font*, long character, float scale = 1.0)

Creates a bitmap using the character of the given Font. The width and height reflect the actual size of the character in pixels and may not be equal to the width and height of the character as returned by the Font operations. The bitmap’s origin is set to the character’s origin.

Bitmap(const Bitmap&)

Creates a copy of the given bitmap.

Public Operations

int Bottom() const

Returns the location of the bottom edge of the bitmap.

void FlipHorizontal()

Flips the bitmap about its vertical axis. The origin of the bitmap is left unchanged.

void FlipVertical()

Flips the bitmap about its horizontal axis. The origin of the bitmap is left unchanged.

unsigned int Height() const

Returns the height in pixels of the bitmap.

void Invert()

Toggles each bit in the bitmap. Bits set to true will be toggled to false and bits set to false will be toggled to true creating the inverse effect. The origin of the bitmap is left unchanged.

int Left() const

Returns the location of the left edge of the bitmap.

static Bitmap* open(const char* filename)

Creates a bitmap from the given filename. The file format must be that produced by the X bitmap program. The bitmap’s origin will be the hot spot specified by the file or the lower left corner if the file does not define a hot spot.

boolean Peek(int x, int y) const

Returns whether the bit at <x, y> is set to true or false. If the x and y coordinates are not within the bounds of the bitmap, then Peek() returns false.

void Poke(boolean, int x, int y)

Sets the bit at <x, y> to true or false.

int Right() const

Returns the location of the right edge of the bitmap.

void Rotate(float angle)

Moves the data, in a counter-clockwise direction angle degrees around the bitmap’s center.

void Rotate90()

Moves the data in a counter-clockwise direction 90 degrees around the bitmap’s center. The origin of the bitmap is left unchanged.

void Rotate180()

Moves the data in a counter-clockwise direction 180 degrees around the bitmap’s center. The origin of the bitmap is left unchanged.

void Rotate270()

Moves the data in a counter-clockwise direction 270 degrees around the bitmap center. The origin of the bitmap is unchanged.

void Scale(float sx, float sy)

Enlarges or reduces the data in the bitmap by a factor of sx (x-dimension) and sy (y-dimension).

int Top() const

Returns the location of the top edge of the bitmap.

void Transform(const Transformer*)

Moves the data in the bitmap using the specified transformer.

unsigned int Width() const

Returns the width in pixels of the bitmap.

virtual int Write(const char* filename)

Writes the contents of the bitmap to the specified file. Returns zero if successful, otherwise returns a non-zero error code. See XWriteBitmapFile(3X) for a description of the error codes.

Protected Operations

None.

X Resources

None.

Examples


//                          Bitmap Example
#include <ivplus/box.h>
#include <ivplus/bitmap.h>
#include <ivplus/frame.h>
#include <ivplus/message.h>
#include <ivplus/world.h>
int main(int argc, char **argv)
{
   // Create the world to get the connection with the display.
   World* world = new World("MyApp", argc, argv);
  
   // using "/usr/lib/X11/bitmaps/HPlogo.bm"
   const int HPlogo_width=46;
   const int HPlogo_height=34;
   static char HPlogo_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xff, 0x79, 0xfe, 0xff, 0xc1,
   0xf8, 0xff, 0x39, 0xfe, 0xff, 0xc7, 0xfc, 0xff, 0x3d, 0xfc, 0xff, 0xcf,
   0xfc, 0xff, 0x3c, 0xe0, 0xff, 0xcf, 0xfe, 0x7f, 0x1c, 0x80, 0xff, 0xdf,
   0xfe, 0x3f, 0x1c, 0x00, 0xff, 0xdf, 0xfe, 0x1f, 0x1e, 0x00, 0xfe, 0xdf,
   0xfe, 0x0f, 0x1e, 0x00, 0xfc, 0xdf, 0xfe, 0x07, 0x0e, 0x00, 0xf8, 0xdf,
   0xfe, 0x07, 0x0f, 0x00, 0xf8, 0xdf, 0xfe, 0x03, 0x7f, 0xfc, 0xf1, 0xdf,
   0xfe, 0x03, 0xff, 0xfc, 0xf3, 0xdf, 0xfe, 0x03, 0xff, 0xfc, 0xf3, 0xdf,
   0xfe, 0x81, 0xf7, 0xde, 0xe3, 0xdf, 0xfe, 0x81, 0x77, 0xde, 0xe1, 0xdf,
   0xfe, 0x81, 0x73, 0xce, 0xe1, 0xdf, 0xfe, 0xc1, 0x7b, 0xee, 0xe1, 0xdf,
   0xfe, 0xc1, 0x7b, 0xef, 0xe1, 0xdf, 0xfe, 0xc1, 0x3b, 0xe7, 0xe0, 0xdf,
   0xfe, 0xc3, 0x39, 0xff, 0xf0, 0xdf, 0xfe, 0xe3, 0xbd, 0xff, 0xf0, 0xdf,
   0xfe, 0xe3, 0xbd, 0x7f, 0xf0, 0xdf, 0xfe, 0x07, 0x80, 0x03, 0xf8, 0xdf,
   0xfe, 0x07, 0x80, 0x03, 0xf8, 0xdf, 0xfe, 0x0f, 0xc0, 0x03, 0xfc, 0xdf,
   0xfe, 0x1f, 0xc0, 0x03, 0xfe, 0xdf, 0xfe, 0x3f, 0xc0, 0x01, 0xff, 0xdf,
   0xfe, 0x7f, 0xc0, 0x81, 0xff, 0xdf, 0xfc, 0xff, 0xe1, 0xe1, 0xff, 0xcf,
   0xfc, 0xff, 0xe7, 0xfc, 0xff, 0xcf, 0xf8, 0xff, 0xe7, 0xfc, 0xff, 0xc7,
   0xe0, 0xff, 0xf3, 0xfc, 0xff, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0
   };
   // Create a bitmap using the above bits.
   Bitmap* hplogo = new Bitmap(HPlogo_bits, HPlogo_width, HPlogo_height);
   // Invert the bitmap (i.e. toggle each bit in the bitmap).
   hplogo->Invert();
   // Enlarge the bitmap by a factor of 2 in y & 1.5 times in x direction.
   hplogo->Scale(2.0, 1.5);
   // Create a message using this bitmap.
   Message* msg = new Message(hplogo);
  
   // Map the window.
   world->InsertApplication(new Frame(msg, 1, BevelOut));
   // Enter the event loop.
   world->Run();
   return 0;
}

Files


bitmap.h

See Also

Font(3X) , Painter(3X) , Resource(3X) , Transformer(3X) , XWriteBitmapFile(3X) .


Table of Contents