Laxkit  0.0.7.1
Public Member Functions | Public Attributes | Protected Attributes
Laxkit::LaxImlibImage Class Reference

A LaxImage based on Imlib_Images. More...

Inheritance diagram for Laxkit::LaxImlibImage:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 LaxImlibImage (const char *fname, Imlib_Image img=0, const char *npreviewfile=NULL, int maxx=0, int maxy=0, char del=0)
virtual ~LaxImlibImage ()
 Free image if it happens to exist.
virtual Imlib_Image Image (int which=0)
 Return the image. Loads from filename if !image.
virtual void doneForNow ()
 Calling this makes it easier on the imlib cache.
virtual unsigned int imagestate ()
virtual int imagetype ()
virtual int w ()
virtual int h ()
virtual int dataw ()
virtual int datah ()
virtual void clear ()
virtual unsigned chargetImageBuffer ()
 Return the buffer from imlib_image_get_data().
virtual int doneWithBuffer (unsigned char *buffer)
 Restore data via imlib_image_put_back_data().
- Public Member Functions inherited from Laxkit::LaxImage
 LaxImage (const char *fname)
virtual ~LaxImage ()
- Public Member Functions inherited from Laxkit::anObject
 anObject ()
 Set object_id=getUniqueNumber().
virtual ~anObject ()
 Empty virtual destructor.
virtual const charwhattype ()
 Returns the type of anObject.
virtual anObjectduplicate (anObject *ref=NULL)
virtual int inc_count ()
 Increment the data's count by 1. Returns count.
virtual int dec_count ()
 Decrement the count of the data, deleting if count is less than or equal to 0.
virtual int the_count ()

Public Attributes

Imlib_Image image
int width
 The actual width of the full image.
int height
 The actual height of the full image.
int dwidth
 The actual width of the preview image, or 0 if not loadable.
int dheight
 The actual height of the preview image, or 0 if not loadable.
- Public Attributes inherited from Laxkit::LaxImage
char delpreview
 1 to unlink previewfile in the destructor, else 0.
charfilename
charpreviewfile
clock_t lastaccesstime
- Public Attributes inherited from Laxkit::anObject
int suppress_debug
DeleteRefCountedFunc deleteMe
 Called when the count is decremented to 0.
unsigned long object_id
charobject_idstr

Protected Attributes

char flag
 1 if the image should be free'd when not in use (assumes filename is good). else 0.
char whichimage
 Which image is in memory. 0 for none, 1 for main, 2 for preview.

Detailed Description

A LaxImage based on Imlib_Images.


Constructor & Destructor Documentation

Laxkit::LaxImlibImage::LaxImlibImage ( const char fname,
Imlib_Image  img = 0,
const char npfile = NULL,
int  maxx = 0,
int  maxy = 0,
char  del = 0 
)

If fname and img, then assume that img corresponds to fname, read dimensions from img, then free it. If fname and !img, then get the dims from imlib by loading fname and reading off dims. If !fname and img, then set flag=0 (do not free image during LaxImage lifetime).

Note that Imlib docs say loading, reading off things, then freeing is a good thing.

The preview image is set up only if the main image exists, and only if the image's dimensions exceed maxx or maxy. Also if the main image does not exist, previewfile is set to NULL, and npfile is ignored. Whether the main image exists is by checking whether width>0, not by whether filename exists, since there might be no associated filename for the image.

If npfile is given, but maxx<=0 or maxy<=0, then set up the preview file only if it existed already. A new preview is not generated. A new preview IS generated whenever maxx>0 or maxy>0 AND the main image's dimensions are too big for the specified bounds, AND npfile cannot be opened as an image by Imlib. If only one of maxx or maxy is greater than 0, then only fit to be within that bound.

If del is non-zero, then the previewfile is unlinked in this's destructor.

Todo:

*** needs to be some error checking when generating new previews

scaling to maxx OR maxy if either 0 not implemented. both must currently be nonzero.

when generating preview, might be wise to have check for freedesktop thumb locations to enforce proper sizing

References Laxkit::LaxImage::delpreview, dheight, dwidth, flag, Laxkit::generate_preview_image, height, newstr(), whichimage, and width.


Member Function Documentation

void Laxkit::LaxImlibImage::doneForNow ( )
virtual

Calling this makes it easier on the imlib cache.

Calls imlib_context_set_image(image) then imlib_free_image() if image was not null and flag==0.

Reimplemented from Laxkit::LaxImage.

References flag, and whichimage.

Referenced by Laxkit::load_imlib_image(), and Laxkit::load_imlib_image_with_preview().

int Laxkit::LaxImlibImage::doneWithBuffer ( unsigned char buffer)
virtual

Restore data via imlib_image_put_back_data().

WARNING! If image==NULL, then buffer is not put back, and 1 is returned.

0 is returned on success.

Implements Laxkit::LaxImage.

Imlib_Image Laxkit::LaxImlibImage::Image ( int  which = 0)
virtual

Return the image. Loads from filename if !image.

Attempts to load the previewfile. If that fails, then attempts to load the real file.

which==0 is get default (whichever is already loaded, or if none loaded, then preview if avaible, else main image), 1 is main, 2 is preview. If 1 and main is unavailable, or 2 and the preview is unavailable, then NULL is returned.

Todo:
note that if image is already loaded, this function does not yet switch to the proper one..

References dwidth, and whichimage.

Referenced by Laxkit::DisplayerXlib::imageout().


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

Mon Feb 17 2014 11:52:59, Laxkit