|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tiio_quantel.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//#include "texception.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfilepath.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "filequantel.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
int getTypeFromExt(const string &ext)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (ext == "qnt")
|
|
Toshihiro Shimizu |
890ddd |
return QNT_FORMAT;
|
|
Toshihiro Shimizu |
890ddd |
if (ext == "qtl")
|
|
Toshihiro Shimizu |
890ddd |
return QTL_FORMAT;
|
|
Toshihiro Shimizu |
890ddd |
if (ext == "yuv")
|
|
Toshihiro Shimizu |
890ddd |
return YUV_FORMAT;
|
|
Toshihiro Shimizu |
890ddd |
if (ext == "sdl")
|
|
Toshihiro Shimizu |
890ddd |
return SDL_FORMAT;
|
|
Toshihiro Shimizu |
890ddd |
if (ext == "vpb")
|
|
Toshihiro Shimizu |
890ddd |
return VPB_FORMAT;
|
|
Toshihiro Shimizu |
890ddd |
return QNT_FORMAT;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}; //namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageP TImageReaderQuantel::load()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int w = 0, h = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int type = getTypeFromExt(getFilePath().getType());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void *buffer = img_read_quantel(getFilePath().getWideString().c_str(), &w, &h, type);
|
|
Toshihiro Shimizu |
890ddd |
if (buffer)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P raster(w, h, w, (TPixel32*)buffer);
|
|
Toshihiro Shimizu |
890ddd |
TRasterImageP rasImage(raster);
|
|
Toshihiro Shimizu |
890ddd |
return TImageP(rasImage);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
throw TImageException(getFilePath(), "unable to load file");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDimension TImageReaderQuantel::getSize() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int w, h;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
img_read_quantel_info(getFilePath().getWideString().c_str(), &w, &h, getTypeFromExt(getFilePath().getType()));
|
|
Toshihiro Shimizu |
890ddd |
return TDimension(w, h);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRect TImageReaderQuantel::getBBox() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int w, h;
|
|
Toshihiro Shimizu |
890ddd |
img_read_quantel_info(getFilePath().getWideString().c_str(), &w, &h, getTypeFromExt(getFilePath().getType()));
|
|
Toshihiro Shimizu |
890ddd |
return TRect(0,0,w-1, h-1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//============================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TImageWriterQuantel::save(const TImageP &image)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRasterImageP rasImage(image);
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P raster;
|
|
Toshihiro Shimizu |
890ddd |
raster = rasImage->getRaster();
|
|
Toshihiro Shimizu |
890ddd |
if (!raster)
|
|
Toshihiro Shimizu |
890ddd |
throw TException("not a rasterimage!");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (raster->getLx() != raster->getWrap())
|
|
Toshihiro Shimizu |
890ddd |
throw TException ("TImageWriterQuantel::save lx != wrap");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int type = getTypeFromExt(getFilePath().getType());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!img_write_quantel(getFilePath().getWideString().c_str(), raster->getRawData(), raster->getLx(), raster->getLy(), type))
|
|
Toshihiro Shimizu |
890ddd |
throw TException("error writing file");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
*/
|