|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tcommon.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "timageinfo.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "timage_io.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tlevel_io.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "ttoonzimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trastercm.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorrenderdata.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpalette.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tgl.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorgl.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tofflinegl.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "timagecache.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshleveltypes.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/levelproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/fill.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Shinya Kitaoka |
70f81d |
#include <qimage></qimage>
|
|
Shinya Kitaoka |
70f81d |
#include <qthread></qthread>
|
|
Shinya Kitaoka |
70f81d |
#include <qopenglcontext></qopenglcontext>
|
|
Shinya Kitaoka |
70f81d |
#include <qoffscreensurface></qoffscreensurface>
|
|
Shinya Kitaoka |
70f81d |
#include <qopenglframebufferobject></qopenglframebufferobject>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "imagebuilders.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Global stuff
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
extern TOfflineGL *currentOfflineGL;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ImageLoader implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ImageLoader::ImageLoader(const TFilePath &path, const TFrameId &fid)
|
|
Toshihiro Shimizu |
890ddd |
: m_path(path), m_fid(fid), m_subsampling(0), m_64bitCompatible(false)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool ImageLoader::getInfo(TImageInfo &info, int imFlags, void *extData)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
try {
|
|
Toshihiro Shimizu |
890ddd |
TLevelReaderP lr(m_path);
|
|
Toshihiro Shimizu |
890ddd |
TImageReaderP fr = lr->getFrameReader(m_fid);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// NOTE: Currently not changing imageInfo's bpp stuff...
|
|
Toshihiro Shimizu |
890ddd |
// Ignoring subsampling too...
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return ImageBuilder::setImageInfo(info, fr.getPointer());
|
|
Toshihiro Shimizu |
890ddd |
} catch (TException &e) {
|
|
Toshihiro Shimizu |
890ddd |
QString msg = QString::fromStdWString(e.getMessage());
|
|
Toshihiro Shimizu |
890ddd |
if (msg == QString("Old 4.1 Palette"))
|
|
Toshihiro Shimizu |
890ddd |
throw;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline int ImageLoader::buildSubsampling(int imFlags, BuildExtData *data)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (imFlags & ImageManager::toBeModified) ? 1 : (data->m_subs > 0) ? data->m_subs : (m_subsampling > 0) ? m_subsampling : data->m_sl->getProperties()->getSubsampling();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageP ImageLoader::build(int imFlags, void *extData)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(extData);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Extract external data
|
|
Toshihiro Shimizu |
890ddd |
BuildExtData *data = static_cast<buildextdata *="">(extData);</buildextdata>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int subsampling = buildSubsampling(imFlags, data);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
try {
|
|
Toshihiro Shimizu |
890ddd |
// Initialize level reader
|
|
Toshihiro Shimizu |
890ddd |
TLevelReaderP lr(m_path);
|
|
Toshihiro Shimizu |
890ddd |
if (!lr)
|
|
Toshihiro Shimizu |
890ddd |
return TImageP();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Load info in cases where it's required first
|
|
Toshihiro Shimizu |
890ddd |
lr->doReadPalette(false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if ((m_path.getType() == "pli") || (m_path.getType() == "svg") || (m_path.getType() == "psd"))
|
|
Toshihiro Shimizu |
890ddd |
lr->loadInfo();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
lr->doReadPalette(true); // Allow palette loading
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageReaderP ir = lr->getFrameReader(m_fid);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool enable64bit = (imFlags & ImageManager::is64bitEnabled);
|
|
Toshihiro Shimizu |
890ddd |
ir->enable16BitRead(enable64bit); // Set 64-bit loading if required
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Load the image
|
|
Toshihiro Shimizu |
890ddd |
TImageP img;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (data->m_icon && m_path.getType() == "tlv")
|
|
Toshihiro Shimizu |
890ddd |
img = ir->loadIcon(); // TODO: Why just in the tlv case??
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
ir->setShrink(subsampling);
|
|
Toshihiro Shimizu |
890ddd |
img = ir->load();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ir->enable16BitRead(false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!img)
|
|
Toshihiro Shimizu |
890ddd |
return img; // There was an error loading the image.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = data->m_sl->getPalette();
|
|
Toshihiro Shimizu |
890ddd |
if (palette)
|
|
Toshihiro Shimizu |
890ddd |
img->setPalette(palette);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (subsampling > 1) {
|
|
Toshihiro Shimizu |
890ddd |
// Store the subsampling info in the image
|
|
Toshihiro Shimizu |
890ddd |
if (TRasterImageP ri = img)
|
|
Toshihiro Shimizu |
890ddd |
ri->setSubsampling(subsampling);
|
|
Toshihiro Shimizu |
890ddd |
else if (TToonzImageP ti = img)
|
|
Toshihiro Shimizu |
890ddd |
ti->setSubsampling(subsampling);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// In case the image will be cached, store its subsampling and 64 bit compatibility
|
|
Toshihiro Shimizu |
890ddd |
if (!(imFlags & ImageManager::dontPutInCache)) {
|
|
Toshihiro Shimizu |
890ddd |
m_subsampling = subsampling;
|
|
Toshihiro Shimizu |
890ddd |
m_64bitCompatible = data->m_sl->is16BitChannelLevel() ? enable64bit : true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return img;
|
|
Toshihiro Shimizu |
890ddd |
} catch (...) {
|
|
Toshihiro Shimizu |
890ddd |
return TImageP();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool ImageLoader::isImageCompatible(int imFlags, void *extData)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(extData);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
BuildExtData *data = static_cast<buildextdata *="">(extData);</buildextdata>
|
|
Toshihiro Shimizu |
890ddd |
const TXshSimpleLevel *sl = data->m_sl;
|
|
tomosu |
e5f7d8 |
|
|
tomosu |
e5f7d8 |
// NOTE: Vector and Mesh dont care about sub sampling rate and bit depth compatibility.
|
|
tomosu |
e5f7d8 |
// They are property of Raster.
|
|
tomosu |
e5f7d8 |
if (sl->getType() == PLI_XSHLEVEL || sl->getType() == MESH_XSHLEVEL)
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int subsampling = buildSubsampling(imFlags, data);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_subsampling <= 0 || subsampling != m_subsampling)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
tomosu |
e5f7d8 |
if (m_64bitCompatible || !(imFlags & ImageManager::is64bitEnabled)){
|
|
tomosu |
e5f7d8 |
return true;
|
|
tomosu |
e5f7d8 |
}else{
|
|
tomosu |
e5f7d8 |
return false;
|
|
tomosu |
e5f7d8 |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ImageLoader::invalidate()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
ImageBuilder::invalidate();
|
|
Toshihiro Shimizu |
890ddd |
m_subsampling = 0;
|
|
Toshihiro Shimizu |
890ddd |
m_64bitCompatible = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*-- ImageBuilder仮想関数の実装。アイコン、画像をLoad時に全てキャッシュに格納する --*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ImageLoader::buildAllIconsAndPutInCache(TXshSimpleLevel *level,
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tframeid> fids,</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
std::vector<std::string> iconIds,</std::string>
|
|
Toshihiro Shimizu |
890ddd |
bool cacheImagesAsWell)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_path.getType() != "tlv")
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (fids.empty() || iconIds.empty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
/*- fidとアイコンidの数は同じはず -*/
|
|
Toshihiro Shimizu |
890ddd |
if ((int)fids.size() != (int)iconIds.size())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
try {
|
|
Toshihiro Shimizu |
890ddd |
TLevelReaderP lr(m_path);
|
|
Toshihiro Shimizu |
890ddd |
if (!lr)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)fids.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
lr->doReadPalette(false);
|
|
Toshihiro Shimizu |
890ddd |
TImageReaderP ir = lr->getFrameReader(fids[i]);
|
|
Toshihiro Shimizu |
890ddd |
lr->doReadPalette(true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageInfo info;
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = level->getPalette();
|
|
Toshihiro Shimizu |
890ddd |
std::string fullImgId = level->getImageId(fids[i]);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*- 画像データも一緒にキャッシュする場合 -*/
|
|
Toshihiro Shimizu |
890ddd |
if (cacheImagesAsWell) {
|
|
Toshihiro Shimizu |
890ddd |
ir->enable16BitRead(m_64bitCompatible);
|
|
Toshihiro Shimizu |
890ddd |
ir->setShrink(1);
|
|
Toshihiro Shimizu |
890ddd |
TImageP fullImg = ir->load();
|
|
Toshihiro Shimizu |
890ddd |
if (fullImg) {
|
|
Toshihiro Shimizu |
890ddd |
if (palette)
|
|
Toshihiro Shimizu |
890ddd |
fullImg->setPalette(palette);
|
|
Toshihiro Shimizu |
890ddd |
TImageCache::instance()->add(fullImgId, fullImg, true);
|
|
Toshihiro Shimizu |
890ddd |
setImageInfo(info, fullImg.getPointer());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*- アイコンのロード -*/
|
|
Toshihiro Shimizu |
890ddd |
TImageP img = ir->loadIcon();
|
|
Toshihiro Shimizu |
890ddd |
ir->enable16BitRead(false);
|
|
Toshihiro Shimizu |
890ddd |
if (img) {
|
|
Toshihiro Shimizu |
890ddd |
if (palette)
|
|
Toshihiro Shimizu |
890ddd |
img->setPalette(palette);
|
|
Toshihiro Shimizu |
890ddd |
TImageCache::instance()->add(iconIds[i], img, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} catch (...) {
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ImageRasterizer implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool ImageRasterizer::getInfo(TImageInfo &info, int imFlags, void *extData)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(false); // None should get these... in case, TODO
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageP ImageRasterizer::build(int imFlags, void *extData)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(!(imFlags & ~(ImageManager::dontPutInCache | ImageManager::forceRebuild)));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDimension d(10, 10);
|
|
Toshihiro Shimizu |
890ddd |
TPoint off(0, 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Fetch image
|
|
Toshihiro Shimizu |
890ddd |
assert(extData);
|
|
Toshihiro Shimizu |
890ddd |
ImageLoader::BuildExtData *data = (ImageLoader::BuildExtData *)extData;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const std::string &srcImgId = data->m_sl->getImageId(data->m_fid);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageP img = ImageManager::instance()->getImage(srcImgId, imFlags, extData);
|
|
Toshihiro Shimizu |
890ddd |
if (img) {
|
|
Toshihiro Shimizu |
890ddd |
TVectorImageP vi = img;
|
|
Toshihiro Shimizu |
890ddd |
if (vi) {
|
|
Toshihiro Shimizu |
890ddd |
TRectD bbox = vi->getBBox();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
d = TDimension(tceil(bbox.getLx()) + 1, tceil(bbox.getLy()) + 1);
|
|
Toshihiro Shimizu |
890ddd |
off = TPoint((int)bbox.x0, (int)bbox.y0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPalette *vpalette = vi->getPalette();
|
|
Toshihiro Shimizu |
890ddd |
TVectorRenderData rd(TTranslation(-off.x, -off.y), TRect(TPoint(0, 0), d), vpalette, 0, true, true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TGlContext oldContext = tglGetCurrentContext();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
70f81d |
// this is too slow.
|
|
Shinya Kitaoka |
70f81d |
{
|
|
Shinya Kitaoka |
70f81d |
QSurfaceFormat format;
|
|
Shinya Kitaoka |
70f81d |
format.setProfile(QSurfaceFormat::CompatibilityProfile);
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
70f81d |
TRaster32P ras(d);
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
70f81d |
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
|
Shinya Kitaoka |
70f81d |
glMatrixMode(GL_MODELVIEW), glPushMatrix();
|
|
Shinya Kitaoka |
70f81d |
glMatrixMode(GL_PROJECTION), glPushMatrix();
|
|
Shinya Kitaoka |
70f81d |
{
|
|
Shinya Kitaoka |
70f81d |
std::unique_ptr<qopenglframebufferobject> fb(new QOpenGLFramebufferObject(d.lx, d.ly));</qopenglframebufferobject>
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
70f81d |
fb->bind();
|
|
Shinya Kitaoka |
70f81d |
assert(glGetError() == 0);
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
70f81d |
glViewport(0, 0, d.lx, d.ly);
|
|
Shinya Kitaoka |
70f81d |
glClearColor(0, 0, 0, 0);
|
|
Shinya Kitaoka |
70f81d |
glClear(GL_COLOR_BUFFER_BIT);
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
70f81d |
glMatrixMode(GL_PROJECTION);
|
|
Shinya Kitaoka |
70f81d |
glLoadIdentity();
|
|
Shinya Kitaoka |
70f81d |
gluOrtho2D(0, d.lx, 0, d.ly);
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
70f81d |
glMatrixMode(GL_MODELVIEW);
|
|
Shinya Kitaoka |
70f81d |
glLoadIdentity();
|
|
Shinya Kitaoka |
70f81d |
glTranslatef(0.375, 0.375, 0.0);
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
70f81d |
assert(glGetError() == 0);
|
|
Shinya Kitaoka |
70f81d |
tglDraw(rd, vi.getPointer());
|
|
Shinya Kitaoka |
70f81d |
assert(glGetError() == 0);
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
70f81d |
assert(glGetError() == 0);
|
|
Shinya Kitaoka |
70f81d |
glFlush();
|
|
Shinya Kitaoka |
70f81d |
assert(glGetError() == 0);
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
70f81d |
QImage img = fb->toImage().scaled(QSize(d.lx, d.ly), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
70f81d |
int wrap = ras->getLx() * sizeof(TPixel32);
|
|
Shinya Kitaoka |
70f81d |
uchar *srcPix = img.bits();
|
|
Shinya Kitaoka |
70f81d |
uchar *dstPix = ras->getRawData() + wrap * (d.ly - 1);
|
|
Shinya Kitaoka |
70f81d |
for (int y = 0; y < d.ly; y++) {
|
|
Shinya Kitaoka |
70f81d |
memcpy(dstPix, srcPix, wrap);
|
|
Shinya Kitaoka |
70f81d |
dstPix -= wrap;
|
|
Shinya Kitaoka |
70f81d |
srcPix += wrap;
|
|
Shinya Kitaoka |
70f81d |
}
|
|
Shinya Kitaoka |
70f81d |
fb->release();
|
|
Shinya Kitaoka |
70f81d |
}
|
|
Shinya Kitaoka |
70f81d |
glMatrixMode(GL_MODELVIEW), glPopMatrix();
|
|
Shinya Kitaoka |
70f81d |
glMatrixMode(GL_PROJECTION), glPopMatrix();
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
70f81d |
glPopAttrib();
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
108c32 |
tglMakeCurrent(oldContext);
|
|
Shinya Kitaoka |
7bc906 |
|
|
Shinya Kitaoka |
70f81d |
TRasterImageP ri = TRasterImageP(ras);
|
|
Shinya Kitaoka |
70f81d |
ri->setOffset(off + ras->getCenter());
|
|
Shinya Kitaoka |
70f81d |
|
|
Shinya Kitaoka |
70f81d |
return ri;
|
|
Shinya Kitaoka |
70f81d |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Error case: return a dummy image (is it really required?)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P ras(d);
|
|
Toshihiro Shimizu |
890ddd |
ras->fill(TPixel32(127, 0, 127, 127));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return TRasterImageP(ras);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ImageFiller implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool ImageFiller::getInfo(TImageInfo &info, int imFlags, void *extData)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(false); // None should get these... in case, TODO
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageP ImageFiller::build(int imFlags, void *extData)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(imFlags == ImageManager::none);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Fetch image
|
|
Toshihiro Shimizu |
890ddd |
assert(extData);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ImageLoader::BuildExtData *data = (ImageLoader::BuildExtData *)extData;
|
|
Toshihiro Shimizu |
890ddd |
assert(data->m_subs == 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const std::string &srcImgId = data->m_sl->getImageId(data->m_fid);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageP img = ImageManager::instance()->getImage(srcImgId, imFlags, extData);
|
|
Toshihiro Shimizu |
890ddd |
if (img) {
|
|
Toshihiro Shimizu |
890ddd |
TRasterImageP ri = img;
|
|
Toshihiro Shimizu |
890ddd |
if (ri) {
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P ras = ri->getRaster();
|
|
Toshihiro Shimizu |
890ddd |
if (ras) {
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P newRas = ras->clone();
|
|
Toshihiro Shimizu |
890ddd |
FullColorAreaFiller filler(newRas);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPaletteP palette = new TPalette();
|
|
Toshihiro Shimizu |
890ddd |
int styleId = palette->getPage(0)->addStyle(TPixel32::White);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FillParameters params;
|
|
Toshihiro Shimizu |
890ddd |
params.m_palette = palette.getPointer();
|
|
Toshihiro Shimizu |
890ddd |
params.m_styleId = styleId;
|
|
Toshihiro Shimizu |
890ddd |
params.m_minFillDepth = 0;
|
|
Toshihiro Shimizu |
890ddd |
params.m_maxFillDepth = 15;
|
|
Toshihiro Shimizu |
890ddd |
filler.rectFill(newRas->getBounds(), params, false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterImageP ri = TRasterImageP(newRas);
|
|
Toshihiro Shimizu |
890ddd |
return ri;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Error case: return a dummy image (is it really required?)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P ras(10, 10);
|
|
Toshihiro Shimizu |
890ddd |
ras->fill(TPixel32(127, 0, 127, 127));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return TRasterImageP(ras);
|
|
Toshihiro Shimizu |
890ddd |
}
|