ubit
Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes | Friends | List of all members
ubit::UIma Class Reference

Image. More...

#include <uima.hpp>

Inheritance diagram for ubit::UIma:
ubit::UData ubit::UNode ubit::UObject ubit::UPix

Public Member Functions

 UIma (int width, int height)
 creates an empty image.
 
 UIma (const char *filename=null, bool load_now=false)
 creates a new image from an image file. More...
 
 UIma (const UStr &filename, bool load_now=false)
 creates a new image from an image file. More...
 
 UIma (const char **xpm_data, bool load_now=false)
 creates a new image from XPM data (beware that XPM data is NOT duplicated!). More...
 
 UIma (const char **xpm_data, UConst)
 
UImaoperator= (const UIma &ima2)
 copies the content of ima2 to this image. More...
 
void resize (int width, int height)
 resizes the image data to the specified size. More...
 
void resize (int max_width, int max_height, bool preserve_ratio, bool dont_magnify)
 resizes this image data according to the specified constraints. More...
 
bool rescale (float scale)
 rescales this image.
 
bool rescale (float xscale, float yscale)
 rescales this image.
 
virtual int read (const UStr &filename, int max_width=0, int max_height=0)
 loads an image file. More...
 
virtual int read (const char *filename, int max_width=0, int max_height=0)
 loads an image file. More...
 
virtual int loadFromData (const char **xpm_data)
 loads XPM data. More...
 
virtual int loadNow ()
 loads the image file that was specified by set() or by the constructor. More...
 
bool isLoaded () const
 returns true if the image has been loaded. More...
 
virtual void set (const UStr &filename)
 
virtual void set (const char *filename)
 
virtual void set (const char **xpm_data)
 specifies the file name. More...
 
int getWidth () const
 returns the image width (0 if the image is not loaded).
 
int getHeight () const
 returns the image height (0 if the image is not loaded).
 
int getBpp () const
 returns the number of bits per pixel (0 if the image is not loaded).
 
int getTransparency () const
 0 (opaque), 1(bitmask) or >1(alpha channel).
 
int getStatus () const
 returns the loading status of this image (see UFilestat)
 
virtual bool isPix () const
 returns true if this UIma is in fact a UPix (that derives from UIma).
 
virtual void update ()
 update parents' views.
 
int realize (int max_w=0, int max_h=0, UDisp *disp=null, bool force_reload=true) const
 [impl] allocates physical resources and loads the image in memory. More...
 
bool isRealized () const
 [impl] returns true if the image has been sucesfully loaded and initialized.
 
std::list< UHardIma * > & getNatImas () const
 [impl] returns internal implementation.
 
virtual void setImpl (const char *fname)
 
virtual void setImpl (const char **xpm_data)
 
virtual void setImpl (int width, int height)
 
virtual void cleanCache ()
 
virtual void getSize (UUpdateContext &, UDimension &) const
 
virtual void paint (UGraph &, UUpdateContext &, const URect &) const
 
UHardImagetOrCreateIma (UDisp *, float xyscale) const
 
UHardImafindImaInCache (UDisp *, float xyscale) const
 
UHardImaaddImaInCache (UDisp *, float xyscale) const
 
- Public Member Functions inherited from ubit::UData
 UABSTRACT_CLASS (UData)
 
 UData (UConst)
 
virtual int getDisplayType () const
 
virtual UDatatoData ()
 dynamic cast: returns this object if it derives from UData and null otherwise.
 
virtual const UDatatoData () const
 dynamic cast: returns this object if it derives from UData and null otherwise.
 
virtual UDataonChange (UCall &)
 adds a callback that is fired when the value is modified. More...
 
virtual void changed (bool update=true)
 [impl] called when object's content is changed. More...
 
- Public Member Functions inherited from ubit::UNode
virtual int getNodeType () const
 returns the XML node type.
 
virtual const UStrgetNodeName () const
 return the XML node name.
 
virtual UStr getNodeValue () const
 return the XML node value.
 
virtual int isDisplayable () const
 
virtual UNodetoNode ()
 dynamic cast: returns this object if it derives from UNode and null otherwise.
 
virtual const UNodetoNode () const
 dynamic cast: returns this object if it derives from UNode and null otherwise.
 
virtual bool isChildOf (const UElem &parent, bool indirect=true) const
 returns true if this object a child of 'parent'. More...
 
UParentIter pbegin () const
 returns an iterator to the beginning of the list of direct parents. More...
 
UParentIter pend () const
 returns an iterator to the end of the parent list ( More...
 
virtual UParentsparents () const
 returns the list of direct parents ( More...
 
virtual UElemgetParent (int pos=0) const
 returns the Nth direct parent. More...
 
virtual bool hasSceneGraphParent () const
 
template<class CC >
CC * findParent () const
 < this object has at least one parent in the scene graph. More...
 
virtual int getBoxParents (std::vector< UBox *> &parvect) const
 retrieves direct and indirect parents that are boxes.
 
virtual UBoxgetParent (const UView *) const
 returns the direct or indirect parent that contains this view. More...
 
virtual UViewgetParentView (const UView *) const
 returns the direct or indirect parent's view that contains this view. More...
 
virtual UBoxgetParent (const UInputEvent &) const
 
virtual UViewgetParentView (const UInputEvent &) const
 
virtual void removeFromParents (bool update_parents=true)
 [impl] removes this object from all direct parents. More...
 
virtual bool fire (UEvent &) const
 fires callback functions that match this event.
 
virtual UNoderemoveAllAttrs (bool autodel=true)
 removes all attributes (if any, redefined by subclasses).
 
bool isAutoUpdate () const
 return current update policy: see setAutoUpdate().
 
UNodesetAutoUpdate (bool state=true)
 changes the update policy of this object when its is modified. More...
 
void fireParents (const UCond &c, UNode *n) const
 
void updateAutoParents (const UUpdate &m)
 
virtual void addChangeCall (UCall &)
 
virtual UElemgetSubGroup () const
 
void _addAttr (const UChild &attribute)
 [impl] to be removed @.
 
UChildIter _abegin () const
 [impl] to be removed @.
 
UChildIter _aend () const
 [impl] to be removed @.
 
- Public Member Functions inherited from ubit::UObject
 UObject (const UObject &)
 
UObjectoperator= (const UObject &)
 
virtual const UClassgetClass () const
 instance method that returns the metaclass of this object. More...
 
const UStrgetClassName () const
 returns getClass().getName().
 
virtual void error (const char *function_name, const char *format,...) const
 prints out an error message. More...
 
virtual void warning (const char *function_name, const char *format,...) const
 prints out a warning message: More...
 
bool isDeletable () const
 checks if this object can be destroyed by 'delete'. More...
 
bool isConst () const
 checks whether the content of this object can be modified ( More...
 
UObjectsetConst ()
 specifies that the content of this object cannot be modified. More...
 
bool isAutoUpdate () const
 return current update policy: More...
 
UObjectsetAutoUpdate (bool state=true)
 changes the update policy of this object when its is modified. More...
 
bool isIgnoringChangeCallbacks () const
 return true if change callbacks are fired.
 
UObjectignoreChangeCallbacks (bool state)
 change callbacks are not fired if argument is true.
 
virtual UAttrtoAttr ()
 dynamic cast: returns this object if it derives from UAttr and null otherwise.
 
virtual const UAttrtoAttr () const
 dynamic cast: returns this object if it derives from UAttr and null otherwise.
 
virtual UElemtoElem ()
 dynamic cast: returns this object if it derives from UElem and null otherwise.
 
virtual const UElemtoElem () const
 dynamic cast: returns this object if it derives from UElem and null otherwise.
 
virtual UStrtoStr ()
 dynamic cast: returns this object if it derives from UStr and null otherwise.
 
virtual const UStrtoStr () const
 dynamic cast: returns this object if it derives from UStr and null otherwise.
 
virtual UCalltoCall ()
 dynamic cast: returns this object if it derives from UCall and null otherwise.
 
virtual const UCalltoCall () const
 dynamic cast: returns this object if it derives from UCall and null otherwise.
 
virtual UBoxtoBox ()
 dynamic cast: returns this object if it derives from UBox and null otherwise.
 
virtual const UBoxtoBox () const
 dynamic cast: returns this object if it derives from UBox and null otherwise.
 
virtual UWintoWin ()
 dynamic cast: returns this object if it derives from UWin and null otherwise.
 
virtual const UWintoWin () const
 dynamic cast: returns this object if it derives from UWin and null otherwise.
 
virtual UMenutoMenu ()
 dynamic cast: returns this object if it derives from UMenu and null otherwise.
 
virtual const UMenutoMenu () const
 dynamic cast: returns this object if it derives from UMenu and null otherwise.
 
State getState () const
 returns the current object state.
 
void setState (State s)
 changes the object state.
 
PtrCount getPtrCount () const
 [impl] returns the number of uptr<> smart pointers that are pointing to this object.
 
bool checkConst () const
 [impl] produces an error if this object is logically constant ( More...
 
bool isDestructed () const
 [impl] this object has been destructed (but memory has not been freed yet).
 
bool isDestructing () const
 [impl] this object is being destructed (one of its destructors has been called).
 
void * operator new (size_t)
 < [impl] returns true if there is at least one scene graph parent (redefined by UNode). More...
 
void operator delete (void *)
 delete operator is forbidden on instances that derive from UObject.
 
void addPtr () const
 [Impl] a uptr is added to this object.
 
void removePtr () const
 [Impl] a uptr is removed from this object.
 

Static Public Member Functions

static void getFullPath (UStr &fullpath, const char *filename)
 gets the full image pathname. More...
 
- Static Public Member Functions inherited from ubit::UObject
static const char * getVersion ()
 returns the version of the Ubit package.
 
static const UClassClass ()
 class method that returns the metaclass of this class. More...
 
static UStylecreateStyle ()
 

Protected Types

enum  Mode { EMPTY, CREATE, READ_FROM_FILE, READ_FROM_DATA }
 

Protected Attributes

std::list< UHardIma * > natimas
 
char * name
 
const char ** data
 
signed char stat
 
char mode
 
bool show_unknown_ima
 
- Protected Attributes inherited from ubit::UNode
UParents _parents
 
UChildren _attributes
 
- Protected Attributes inherited from ubit::UObject
PtrCount ptr_count
 
Modes omodes
 
State ostate
 

Friends

class UBox
 
class UHardIma
 
class UPix
 

Additional Inherited Members

- Public Types inherited from ubit::UNode
enum  NodeType {
  ELEMENT_NODE = 1, ATTRIBUTE_NODE = 2, TEXT_NODE = 3, CDATA_SECTION_NODE = 4,
  ENTITY_REFERENCE_NODE = 5, ENTITY_NODE = 6, PROCESSING_INSTRUCTION_NODE = 7, COMMENT_NODE = 8,
  DOCUMENT_NODE = 9, DOCUMENT_TYPE_NODE = 10, DOCUMENT_FRAGMENT_NODE = 11, NOTATION_NODE = 12
}
 redefines Class() and getClass() methods ( More...
 
enum  DisplayType {
  WINLIST =-1, UNDISPLAYBLE =0, ATTRIBUTE, DATA,
  INLINE, BLOCK, BORDER, HARDWIN,
  SOFTWIN
}
 Ubit display types.
 
- Public Types inherited from ubit::UObject
typedef unsigned char State
 
typedef short PtrCount
 
- Static Public Attributes inherited from ubit::UObject
static UConst UCONST
 UCONST can be given as an argument to some constructors to make the object constant. More...
 
- Protected Member Functions inherited from ubit::UNode
 UNode ()
 constructor, can anly be called by subclasses because UNode is abstract.
 
virtual ~UNode ()
 destructor, note that children are recursively destroyed except if pointed elsewhere ( More...
 
virtual void addingTo (UChild &, UElem &parent)
 called when this object is added to a parent.
 
virtual void removingFrom (UChild &, UElem &parent)
 called when this object is removed from a parent (SEE DETAILS IF YOU REDEFINE THIS METHOD). More...
 
virtual void destructs ()
 unlinks the object from its parents and destroys its children.
 

Detailed Description

Image.

Depending on the constructor, one can create: an empty image, an image that is loaded from a JPEG, GIF or XPM file (see below) or an image that uses XPM data compiled in the program code.

Loading a file image. By default, the constructor does not load the file immediately but first time the UIma is displayed on the screen (but an optional arg changes this behavior). The load() and read() functions can also be used to (re)load a file.

Filename and formats:

Loading compiled XPM data XPM data is compiled in the program code. It is not duplicated and must not be freed. As for files, the data is loaded when the image appers for the fisrt time.

Alpha channel and Background Transparency

See also
: the UPix subclass.

Constructor & Destructor Documentation

§ UIma() [1/3]

ubit::UIma::UIma ( const char *  filename = null,
bool  load_now = false 
)

creates a new image from an image file.

By default, the image file is NOT loaded immediately but the first time the UIma is displayed on the screen. 'load_now' = true, forces the file to be loaded immediately

See also
: shortcut uima(const char* filename) and class UIma for more details.

§ UIma() [2/3]

ubit::UIma::UIma ( const UStr filename,
bool  load_now = false 
)

creates a new image from an image file.

By default, the image file is NOT loaded immediately but the first time the UIma is displayed on the screen. 'load_now' = true, forces the file to be loaded immediately

See also
: shortcut uima(const UStr& filename) and class UIma for more details.

§ UIma() [3/3]

ubit::UIma::UIma ( const char **  xpm_data,
bool  load_now = false 
)

creates a new image from XPM data (beware that XPM data is NOT duplicated!).

By default, the data is NOT loaded immediately but the first time the UIma is displayed on the screen. 'load_now' = true, forces the data to be loaded immediately

!NOTE that the XPM data is not duplicated and should NEVER be freed!

See also
: shortcut uima(const char** xpm_data) and class UIma for more details.

Member Function Documentation

§ getFullPath()

void ubit::UIma::getFullPath ( UStr fullpath,
const char *  filename 
)
static

gets the full image pathname.

UAppli::getImaPath() (the default image pathname) is prefixed to image filenames that don't start with / or .

§ isLoaded()

bool ubit::UIma::isLoaded ( ) const
inline

returns true if the image has been loaded.

Note that images that have not yet been displayed on the screen are not loaded except if stated explicitely (see the UIma::Uima, load(), read())

§ loadFromData()

int ubit::UIma::loadFromData ( const char **  xpm_data)
virtual

loads XPM data.

the XPM data is not duplicated and should not be destroyed. note: use UIma::set() instead of read() to postone loading.

§ loadNow()

int ubit::UIma::loadNow ( )
virtual

loads the image file that was specified by set() or by the constructor.

returns the reading status (

See also
UFilestat).

§ operator=()

UIma & ubit::UIma::operator= ( const UIma ima2)

copies the content of ima2 to this image.

bewaee that no action is performed if ima2 has not yet been loaded (

See also
isLoaded()).

§ read() [1/2]

int ubit::UIma::read ( const UStr filename,
int  max_width = 0,
int  max_height = 0 
)
virtual

loads an image file.

calls resize(max_width,max_height,true,true) if max_width and max_height are >0. returns the reading status (

See also
UFilestat). note: use UIma::set() instead of read() to postone loading.

§ read() [2/2]

int ubit::UIma::read ( const char *  filename,
int  max_width = 0,
int  max_height = 0 
)
virtual

loads an image file.

calls resize(max_width,max_height,true,true) if max_width and max_height are >0. returns the reading status (

See also
UFilestat). note: use UIma::set() instead of read() to postone loading.

§ realize()

int ubit::UIma::realize ( int  max_w = 0,
int  max_h = 0,
UDisp disp = null,
bool  force_reload = true 
) const

[impl] allocates physical resources and loads the image in memory.

this function is automatically called when this image is displayed for the first time: there no need to call it in client code. details:

  • returns the loading status (see UFilestat)
  • the 'disp' arg. can be the UAppli
  • the 'force_reload' arg. specifies if the file must be reloaded: #- if false, previously loaded files are not reloaded #- if true files are always reloaded

§ resize() [1/2]

void ubit::UIma::resize ( int  width,
int  height 
)
inline

resizes the image data to the specified size.

See also
: resize(int width, int height, bool preserve_ratio, bool dont_magnify);

§ resize() [2/2]

void ubit::UIma::resize ( int  max_width,
int  max_height,
bool  preserve_ratio,
bool  dont_magnify 
)

resizes this image data according to the specified constraints.

the new size will be inferior or egal to the one specified according to:

  • preserves the aspect ratio if 'preserve_ratio' is true (either the actual width or height may be smaller than the requested one)
  • dont magnify images that are smaller than the requested size if 'dont_magnify' is true

§ set()

void ubit::UIma::set ( const char **  xpm_data)
virtual

specifies the file name.

the file is not loaded immediately but when the image appears for the first time. Call load() to load the file immediately.

§ setImpl()

void ubit::UIma::setImpl ( const char **  xpm_data)
virtual

!att: NOT copied!


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