Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How to use the bitmap utilities

The following example code shows how to the use the pixel manipulation functions in TBitmapUtil — here they are used to create a bitmap which is a rotated version of an existing bitmap.

/* create a new bitmap (iBitmap4), with the same size as an existing bitmap (iBitmap1), but with the height and width swapped */
iBitmap4 = new (ELeave) CFbsBitmap();
TSize inSize = iBitmap1->SizeInPixels();
User::LeaveIfError(iBitmap4->Create(TSize(inSize.iHeight,inSize.iWidth), iBitmap1->DisplayMode());

// create the bitmap utils
TBitmapUtil bitmap1Util(iBitmap1);
TBitmapUtil bitmap4Util(iBitmap4);

// Begin manipulation with bitmap1Util, setting initial pixel to 0,0
bitmap1Util.Begin(TPoint(0,0));
// Begin manipulation with bitmap4Util, setting initial pixel to 0,0
bitmap4Util.Begin(TPoint(0,0),bitmap1Util);

// set the bits of iBitmap4 as iBitmap1, rotated through 90 degrees
TInt xPos;
for (TInt yPos=0;yPos<inSize.iHeight;yPos++)
 {
 bitmap1Util.SetPos(TPoint(0,yPos));
 bitmap4Util.SetPos(TPoint(yPos,0));
 for (xPos=0;xPos<inSize.iWidth;xPos++)
  {
  bitmap4Util.SetPixel(bitmap1Util);
  bitmap1Util.IncXPos();
  bitmap4Util.IncYPos();
  }
 }

// each Begin() must have a corresponding End()
bitmap1Util.End();
bitmap4Util.End();


Notes