Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX::FXBitmap Class Reference

A Bitmap is a rectangular array of pixels. More...

#include <FXBitmap.h>

Inheritance diagram for FX::FXBitmap:
FX::FXDrawable FX::FXId FX::FXObject

Public Member Functions

 FXBitmap (FXApp *a, const FXuchar *pix=nullptr, FXuint opts=0, FXint w=1, FXint h=1)
 Create a bitmap. More...
 
void setOptions (FXuint opts)
 Change options.
 
FXuint getOptions () const
 To get to the option flags.
 
void setOwned (FXbool owned)
 Set pixel data ownership flag.
 
FXbool isOwned () const
 Get pixel data ownership flag.
 
virtual void setData (FXuchar *pix, FXuint opts=0)
 Populate the bitmap with new pixel data of the same size; it will assume ownership of the pixel data if image BITMAP_OWNED option is passed. More...
 
virtual void setData (FXuchar *pix, FXuint opts, FXint w, FXint h)
 Populate the bitmap with new pixel data of a new size; it will assume ownership of the pixel data if image BITMAP_OWNED option is passed. More...
 
FXuchar * getData () const
 To get to the pixel data.
 
FXbool getPixel (FXint x, FXint y) const
 Get pixel at x,y.
 
void setPixel (FXint x, FXint y, FXbool color)
 Change pixel at x,y.
 
virtual void create ()
 Create the server side pixmap, then call render() to fill it with the pixel data from the client-side buffer. More...
 
virtual void detach ()
 Detach the server side pixmap from the Bitmap. More...
 
virtual void destroy ()
 Destroy the server-side pixmap. More...
 
virtual void restore ()
 Retrieves pixels from the server-side bitmap.
 
virtual void render ()
 Render the server-side representation of the bitmap from client-side pixels.
 
virtual void release ()
 Release the client-side pixels buffer, free it if it was owned. More...
 
virtual void resize (FXint w, FXint h)
 Resize both client-side and server-side representations (if any) to the given width and height. More...
 
virtual void scale (FXint w, FXint h)
 Rescale pixels image to the specified width and height; this calls resize() to adjust the client and server side representations.
 
virtual void mirror (FXbool horizontal, FXbool vertical)
 Mirror bitmap horizontally and/or vertically.
 
virtual void rotate (FXint degrees)
 Rotate bitmap by degrees ccw.
 
virtual void crop (FXint x, FXint y, FXint w, FXint h, FXbool color=false)
 Crop bitmap to given rectangle; this calls resize() to adjust the client and server side representations. More...
 
virtual void fill (FXbool color)
 Fill bitmap with uniform value.
 
virtual void save (FXStream &store) const
 Save object to stream.
 
virtual void load (FXStream &store)
 Load object from stream.
 
virtual FXbool savePixels (FXStream &store) const
 Save pixel data only.
 
virtual FXbool loadPixels (FXStream &store)
 Load pixel data only.
 
virtual ~FXBitmap ()
 Cleanup.
 
- Public Member Functions inherited from FX::FXDrawable
FXVisualgetVisual () const
 Get the visual.
 
FXint getWidth () const
 Width of drawable.
 
FXint getHeight () const
 Height of drawable.
 
void setVisual (FXVisual *vis)
 Change visual.
 
virtual ~FXDrawable ()
 Cleanup.
 
- Public Member Functions inherited from FX::FXId
FXAppgetApp () const
 Get application.
 
FXID id () const
 Get XID handle.
 
void setUserData (FXptr ptr)
 Set user data pointer.
 
FXptr getUserData () const
 Get user data pointer.
 
virtual ~FXId ()
 Destructor.
 
- Public Member Functions inherited from FX::FXObject
const FXchar * getClassName () const
 Get class name of some object.
 
FXbool isMemberOf (const FXMetaClass *metaclass) const
 Check if object is member of metaclass.
 
virtual long tryHandle (FXObject *sender, FXSelector sel, void *ptr)
 Try handle message safely, catching certain exceptions.
 
virtual long onDefault (FXObject *, FXSelector, void *)
 Called for unhandled messages.
 
virtual ~FXObject ()
 Virtual destructor.
 

Protected Attributes

FXuchar * data
 
FXint bytewidth
 
FXuint options
 
- Protected Attributes inherited from FX::FXDrawable
FXVisualvisual
 
FXint width
 
FXint height
 
- Protected Attributes inherited from FX::FXId
FXID xid
 

Friends

class FXDC
 
class FXDCWindow
 

Additional Inherited Members

- Protected Member Functions inherited from FX::FXDrawable
 FXDrawable (FXApp *a, FXint w, FXint h)
 
- Protected Member Functions inherited from FX::FXId
 FXId (FXApp *a)
 

Detailed Description

A Bitmap is a rectangular array of pixels.

It supports two representations of these pixels: a client-side pixel buffer, and a server-side pixmap which is stored in an organization directly compatible with the screen, for fast drawing onto the device. The server-side representation is not directly accessible from the current process as it lives in the process of the X Server or GDI. The client-side pixel array is of size height x (width+7)/8 bytes, in other words 8 pixels packed into a single byte, starting at bit 0 on the left.

Constructor & Destructor Documentation

◆ FXBitmap()

FX::FXBitmap::FXBitmap ( FXApp a,
const FXuchar *  pix = nullptr,
FXuint  opts = 0,
FXint  w = 1,
FXint  h = 1 
)

Create a bitmap.

If a client-side pixel buffer has been specified, the bitmap does not own the pixel buffer unless the BITMAP_OWNED flag is set. If the BITMAP_OWNED flag is set but a NULL pixel buffer is passed, a pixel buffer will be automatically created and will be owned by the bitmap. The flags BITMAP_SHMI and BITMAP_SHMP may be specified for large bitmaps to instruct render() to use shared memory to communicate with the server.

Member Function Documentation

◆ create()

virtual void FX::FXBitmap::create ( )
virtual

Create the server side pixmap, then call render() to fill it with the pixel data from the client-side buffer.

After the server-side image has been created, the client-side pixel buffer will be deleted unless BITMAP_KEEP has been specified. If the pixel buffer is not owned, i.e. the flag BITMAP_OWNED is not set, the pixel buffer will not be deleted.

Reimplemented from FX::FXId.

◆ crop()

virtual void FX::FXBitmap::crop ( FXint  x,
FXint  y,
FXint  w,
FXint  h,
FXbool  color = false 
)
virtual

Crop bitmap to given rectangle; this calls resize() to adjust the client and server side representations.

The new bitmap may be smaller or larger than the old one; blank areas are filled with color. There must be at least one pixel of overlap between the old and the new bitmap.

◆ destroy()

virtual void FX::FXBitmap::destroy ( )
virtual

Destroy the server-side pixmap.

The client-side pixel buffer is not affected.

Reimplemented from FX::FXId.

◆ detach()

virtual void FX::FXBitmap::detach ( )
virtual

Detach the server side pixmap from the Bitmap.

Afterwards, the Bitmap is left as if it never had a server-side resources.

Reimplemented from FX::FXId.

◆ release()

virtual void FX::FXBitmap::release ( )
virtual

Release the client-side pixels buffer, free it if it was owned.

If it is not owned, the image just forgets about the buffer.

◆ resize()

virtual void FX::FXBitmap::resize ( FXint  w,
FXint  h 
)
virtual

Resize both client-side and server-side representations (if any) to the given width and height.

The new representations typically contain garbage after this operation and need to be re-filled.

Reimplemented from FX::FXDrawable.

◆ setData() [1/2]

virtual void FX::FXBitmap::setData ( FXuchar *  pix,
FXuint  opts = 0 
)
virtual

Populate the bitmap with new pixel data of the same size; it will assume ownership of the pixel data if image BITMAP_OWNED option is passed.

The server-side representation of the image, if it exists, is not updated. This can be done by calling render().

◆ setData() [2/2]

virtual void FX::FXBitmap::setData ( FXuchar *  pix,
FXuint  opts,
FXint  w,
FXint  h 
)
virtual

Populate the bitmap with new pixel data of a new size; it will assume ownership of the pixel data if image BITMAP_OWNED option is passed.

The size of the server- side representation of the image, if it exists, is adjusted but the contents are not updated yet. This can be done by calling render().


The documentation for this class was generated from the following file:

Copyright © 1997-2022 Jeroen van der Zijp