added a special thread for making thumbnails (thumb.h thumb.cpp)
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@700 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
90
core/thumb.h
Executable file
90
core/thumb.h
Executable file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorethumb
|
||||
#define headerfilecmslucorethumb
|
||||
|
||||
#include "basethread.h"
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include "textstream.h"
|
||||
#include "db/db.h"
|
||||
|
||||
|
||||
|
||||
// Width given, height automagically selected to preserve aspect ratio.
|
||||
#define WINIX_THUMB_MODE_1 1
|
||||
|
||||
// Height given, width automagically selected to preserve aspect ratio.
|
||||
#define WINIX_THUMB_MODE_2 2
|
||||
|
||||
// Maximum values of height and width given, aspect ratio preserved.
|
||||
#define WINIX_THUMB_MODE_3 3
|
||||
|
||||
// Minimum values of width and height given, aspect ratio preserved.
|
||||
#define WINIX_THUMB_MODE_4 4
|
||||
|
||||
// Width and height emphatically given, original aspect ratio ignored.
|
||||
#define WINIX_THUMB_MODE_5 5
|
||||
|
||||
// Change as per widthxheight but only if an image dimension exceeds a specified dimension.
|
||||
#define WINIX_THUMB_MODE_6 6
|
||||
|
||||
// Change dimensions only if both image dimensions are less than specified dimensions.
|
||||
#define WINIX_THUMB_MODE_7 7
|
||||
|
||||
|
||||
|
||||
|
||||
class Thumb : public BaseThread
|
||||
{
|
||||
public:
|
||||
|
||||
void CreateThumb(long item_id, const std::wstring & source, const std::wstring & dst,
|
||||
size_t cx, size_t cy, int aspect_mode = WINIX_THUMB_MODE_2);
|
||||
|
||||
void SetConvertCmd(const std::wstring & cmd);
|
||||
void SetDb(Db * pdb);
|
||||
|
||||
private:
|
||||
|
||||
Db * db;
|
||||
|
||||
struct ThumbItem
|
||||
{
|
||||
long item_id;
|
||||
std::wstring source;
|
||||
std::wstring dst;
|
||||
size_t cx;
|
||||
size_t cy;
|
||||
int aspect_mode;
|
||||
};
|
||||
|
||||
// queue of thumbnails to create
|
||||
typedef std::list<ThumbItem> ThumbTab;
|
||||
ThumbTab thumb_tab;
|
||||
ThumbItem item_temp;
|
||||
|
||||
// this is set before the second thread starts
|
||||
std::wstring convert_cmd;
|
||||
|
||||
// only for second thread
|
||||
ThumbItem item_work;
|
||||
std::string tempa;
|
||||
TextStream<std::string> command;
|
||||
|
||||
virtual bool SignalReceived();
|
||||
virtual void Do();
|
||||
void CreateThumbnail();
|
||||
void SelectAspect();
|
||||
void EscapePath(const std::string & path);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user