Hydra 0.20
hydra::Thumb Class Reference

#include <Thumb.h>

List of all members.

Public Types

enum  { Generate_Ok = 0, Generate_FileExists, Generate_LoadError }

Public Member Functions

 Thumb (const QString &filename)
 Thumb (QImage &srcimg)
 ~Thumb ()
 dtor
int generate (const QString &destfilename, QImage *destimage, int rotateCode, unsigned long desiredW, unsigned long desiredH, unsigned long *actualW=0, unsigned long *actualH=0)

Static Public Member Functions

static QString thumbDir (void)
static void mkThumbDir (void)
static QString fileName (const QString &hash, int rotateCode, unsigned long desiredW, unsigned long desiredH)

Static Public Attributes

static const int DEFAULT_VIEW_W = 800
static const int DEFAULT_VIEW_H = 600
static const int DEFAULT_THUMB_W = 266
static const int DEFAULT_THUMB_H = 200

Detailed Description

Generator and maintainer of image thumbnails (and other scaled versions of an image).

Thumbnails are stores in ~/.hydradb/thumbs/imghash.wantedsize.rotatecode.jpg and generated when needed.

Where size is the thumbnail-desired size (but maybe not the final thumb size, as the aspect ratio will be conserved and therefore the image size will often be smaller than the thumbnail size. The rotatecode is the rotate code that was applied to the thumbnail.

Author:
Aleksander Demko

Constructor & Destructor Documentation

hydra::Thumb::Thumb ( const QString &  filename)

Constructor. The source image file. This doesnt load the file until (and if) Generate is called.

Author:
Aleksander Demko
hydra::Thumb::Thumb ( QImage &  srcimg)

Constructor. Uses the existing in-memory QImage.

Parameters:
notethat no additional rotating will be done on this image
Author:
Aleksander Demko

Member Function Documentation

static QString hydra::Thumb::fileName ( const QString &  hash,
int  rotateCode,
unsigned long  desiredW,
unsigned long  desiredH 
) [static]

Computes the standard thumbnail filename (suitable to be given to generate()) for an image with the given hash and desired dimensions.

Author:
Aleksander Demko
int hydra::Thumb::generate ( const QString &  destfilename,
QImage *  destimage,
int  rotateCode,
unsigned long  desiredW,
unsigned long  desiredH,
unsigned long *  actualW = 0,
unsigned long *  actualH = 0 
)

Makes the thumbnail and saves it to the given filename.

If destimage is non-null, then the given image object will be loaded with the genered thumbnail. If no thumbnail needed to be generated, then the existing one will be read into the destimage.

A Generate_* error code is returned.

Returns a Generate_* code.

Parameters:
rotateCodeis how to rotate the image. it must be >=0
Author:
Aleksander Demko
static void hydra::Thumb::mkThumbDir ( void  ) [static]

Creates the thumb nail directory.

Author:
Aleksander Demko
static QString hydra::Thumb::thumbDir ( void  ) [static]

Returns the thumb dir, which is usually in a subdir of Engine::dbDir()

Author:
Aleksander Demko

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables