Hydra 0.20
|
#include <Thumb.h>
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 |
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.
hydra::Thumb::Thumb | ( | const QString & | filename | ) |
Constructor. The source image file. This doesnt load the file until (and if) Generate is called.
hydra::Thumb::Thumb | ( | QImage & | srcimg | ) |
Constructor. Uses the existing in-memory QImage.
note | that no additional rotating will be done on this image |
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.
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.
rotateCode | is how to rotate the image. it must be >=0 |
static void hydra::Thumb::mkThumbDir | ( | void | ) | [static] |
Creates the thumb nail directory.
static QString hydra::Thumb::thumbDir | ( | void | ) | [static] |
Returns the thumb dir, which is usually in a subdir of Engine::dbDir()