Pyro higlevel API
Public Types | Public Member Functions | Friends | List of all members
os::Bitmap Class Reference

Container for bitmap-image data. More...

Public Types

enum  {
  ACCEPT_VIEWS = 0x0001,
  SHARE_FRAMEBUFFER = 0x0002,
  NO_ALPHA_CHANNEL = 0x0004
}
 

Public Member Functions

 Bitmap (int nWidth, int nHeight, color_space eColorSpc, uint32 nFlags=SHARE_FRAMEBUFFER)
 Bitmap constructor. More...
 
 Bitmap (int hHandle)
 Create a bitmap from a handle. More...
 
virtual ~Bitmap ()
 
bool IsValid (void) const
 
int GetHandle (void) const
 Returns the appserver handle. More...
 
color_space GetColorSpace () const
 Returns the colorspace of the bitmap. More...
 
Rect GetBounds (void) const
 Returns the bounds of the bitmap. More...
 
int GetBytesPerRow () const
 Returns the numer of bytes in one bitmap row. More...
 
virtual void AddChild (View *pcView)
 Adds a view to the bitmap. More...
 
virtual bool RemoveChild (View *pcView)
 Removes a view from the bitmap. More...
 
ViewFindView (const char *pzName) const
 Returns the view with the given name. More...
 
void Sync (void)
 Flush rendering operations and wait until they have been finished. More...
 
void Flush (void)
 Flush rendering operations. More...
 
uint8 * LockRaster (void)
 Get a pointer to the raw raster data. More...
 
void UnlockRaster ()
 

Friends

class View
 
class Window
 
class Sprite
 
class Desktop
 

Detailed Description

Description:
The Bitmap class make it possible to render bitmap graphics into view's and to make view's render into an offscreen buffer to implement things like double-buffering.

The bitmap class have two different ways to communicate with the application server. If the SHARE_FRAMEBUFFER flag is set the bitmaps raster memory is created in a memory-area shared between the application and the appserver. This makes it possible for the appserver to blit graphics written directly to the bitmaps raster buffer by the application into views on the screen (or inside other bitmaps). If the ACCEPT_VIEWS flag is set the bitmap will accept views to be added much like a os::Window object. All rendering performed by the views will then go into the bitmap's offscreen buffer rather than the screen. The rendered image can then be read out by the application (requiers the SHARE_FRAMEBUFFER flag to be set aswell) or it can be blited into other views. The NO_ALPHA_CHANNEL flag disables the alpha channel for 32 bit bitmaps. This can improve performance if you render to this bitmap.

Note
In most cases, the SHARE_FRAMEBUFFER flag should be used.
See Also
View, Window
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Member Enumeration Documentation

anonymous enum
Enumerator
ACCEPT_VIEWS 
SHARE_FRAMEBUFFER 
NO_ALPHA_CHANNEL 

Constructor & Destructor Documentation

Bitmap::Bitmap ( int  nWidth,
int  nHeight,
color_space  eColorSpc,
uint32  nFlags = SHARE_FRAMEBUFFER 
)
Description:
This is the constructor used to create a standard bitmap.
Parameters
nWidth- Width of the bitmap.
nHeight- Height of the bitmap.
eColorSpc- ColorSpace of the bitmap
nFlags- See description of the class.
Note:
An exception will be thrown if the bitmap could not be created.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References ACCEPT_VIEWS, os::Application::GetInstance(), SHARE_FRAMEBUFFER, os::Looper::Unlock(), and Window.

Bitmap::Bitmap ( int  hHandle)
Description:
This constructor will create a handle from the appserver bitmap handle. This is only useful in special cases, e.g. to share bitmaps between two applications.
Parameters
hHandle- The appserver handle of the bitmap.
Note:
An exception will be thrown if the bitmap could not be created.
Author
Arno Klenke (arno_.nosp@m.klen.nosp@m.ke@ya.nosp@m.hoo..nosp@m.de)

References os::Application::GetInstance(), and SHARE_FRAMEBUFFER.

Bitmap::~Bitmap ( )
virtual

Member Function Documentation

void Bitmap::AddChild ( View pcView)
virtual
Description:
This method adds a view to the bitmap. This is only valid if the bitmap has been created with the ACCEPT_VIEWS flag.
Parameters
pcView- The view.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Window::AddChild().

Referenced by os::IconDirectoryView::DragSelection(), os::Slider::FrameSized(), os::BitmapImage::GetView(), os::BitmapImage::Private::SetBitmap(), os::Slider::Slider(), and os::TextEdit::UpdateBackBuffer().

View * Bitmap::FindView ( const char *  pzName) const
Description:
This method returns the (previously added) view with the given name. This is only valid if the bitmap has been created with the ACCEPT_VIEWS flag.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Window::FindView().

void Bitmap::Flush ( void  )
Description:
This method flushes all pending rendering commands of the views added to this bitmap. This is only valid if the bitmap has been created with the ACCEPT_VIEWS flag.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Window::Flush().

Referenced by os::BitmapImage::Flush().

Rect Bitmap::GetBounds ( void  ) const
int Bitmap::GetBytesPerRow ( ) const
color_space Bitmap::GetColorSpace ( ) const
Description:
Returns the colorspace of the bitmap.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Referenced by os::BitmapImage::Private::AssertBitmapFlags(), and os::BitmapImage::GetColorSpace().

int Bitmap::GetHandle ( void  ) const
Description:
Returns the appserver handle. This method is only useful if you want to share a bitmap with another application.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
bool os::Bitmap::IsValid ( void  ) const
uint8* os::Bitmap::LockRaster ( void  )
inline
Description:
This method gets a void* pointer to the raw raster data. The size of the raster data in bytes can be calculated by GetBytesPerLine()*(GetBounds().Height()+1). Since the raster data is allocated by the appserver, this method is only valid if the bitmap was created with the flag SHARE_FRAMEBUFFER.
Note
Remember to call UnlockRaster() when finished accessing the raster.
Return values
Returnsa pointer to the raster data, or NULL if the bitmap was not created with the SHARE_FRAMEBUFFER flag.
See Also
UnlockRaster()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Referenced by os::BitmapImage::AlphaToOverlay(), os::BitmapImage::Private::AssertBitmapFlags(), os::CheckMenu::CheckMenu(), os::CheckRow::CheckRow(), os::BitmapImage::ColorizeFilter(), os::DropdownMenu::DropdownMenu(), os::get_std_bitmap(), os::BitmapImage::GlowFilter(), os::BitmapImage::GrayFilter(), os::BitmapImage::HighlightFilter(), os::BitmapImage::Load(), os::BitmapImage::operator=(), os::BitmapImage::operator[](), os::RadioButton::RadioButton(), os::RadioMenuItem::RadioMenuItem(), os::BitmapImage::Save(), Scale(), os::BitmapImage::SetBitmapData(), os::Spinner::Spinner(), and os::TreeViewCheckNode::TreeViewCheckNode().

bool Bitmap::RemoveChild ( View pcView)
virtual
Description:
This method removes a view from the bitmap. This is only valid if the bitmap has been created with the ACCEPT_VIEWS flag.
Parameters
pcView- The view.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Window::RemoveChild().

Referenced by os::Slider::FrameSized(), os::BitmapImage::Private::SetBitmap(), os::TextEdit::UpdateBackBuffer(), and os::TextEdit::~TextEdit().

void Bitmap::Sync ( void  )
Description:
This method works like Flush() but waits until all operations have been finished. This is only valid if the bitmap has been created with the ACCEPT_VIEWS flag.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Window::Sync().

Referenced by os::IconDirectoryView::DragSelection(), os::Slider::FrameSized(), and os::BitmapImage::Sync().

void os::Bitmap::UnlockRaster ( )
inline

Friends And Related Function Documentation

friend class Desktop
friend
friend class Sprite
friend
friend class View
friend
friend class Window
friend

Referenced by Bitmap().