98 lines
2.0 KiB
C++
Executable File
98 lines
2.0 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2010, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#ifndef headerfile_winix_core_thumb
|
|
#define headerfile_winix_core_thumb
|
|
|
|
#include <string>
|
|
#include <list>
|
|
#include "basethread.h"
|
|
#include "textstream.h"
|
|
#include "db/db.h"
|
|
#include "core/item.h"
|
|
#include "core/config.h"
|
|
|
|
|
|
class System;
|
|
|
|
|
|
|
|
// 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(const Item & item, size_t cx, size_t cy, int aspect_mode);
|
|
|
|
void SetDb(Db * pdb);
|
|
void SetConfig(Config * pconfig);
|
|
void SetSystem(System * psystem);
|
|
|
|
private:
|
|
|
|
Db * db;
|
|
Config * config;
|
|
System * system;
|
|
|
|
struct ThumbItem
|
|
{
|
|
Item file;
|
|
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;
|
|
|
|
// only for second thread
|
|
ThumbItem item_work;
|
|
std::wstring src_path, dst_path;
|
|
std::string tempa, string_tmp_patha;
|
|
TextStream<std::string> command;
|
|
TextStream<std::wstring> stream_tmp_path;
|
|
DbItemQuery iq;
|
|
|
|
virtual bool SignalReceived();
|
|
virtual void Do();
|
|
bool CreateCommand();
|
|
void SaveTmpThumbnail();
|
|
void CreateThumbnail();
|
|
void SelectAspect();
|
|
void EscapePath(const std::string & path);
|
|
};
|
|
|
|
|
|
#endif
|