|
Toshihiro Shimizu |
890ddd |
#include "tenv.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "ino_common.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* copy and paste from
|
|
Toshihiro Shimizu |
890ddd |
igs_ifx_common.h */
|
|
Toshihiro Shimizu |
890ddd |
namespace igs
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
namespace image
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
namespace rgba
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
enum num { blu = 0,
|
|
Toshihiro Shimizu |
890ddd |
gre,
|
|
Toshihiro Shimizu |
890ddd |
red,
|
|
Toshihiro Shimizu |
890ddd |
alp,
|
|
Toshihiro Shimizu |
890ddd |
siz };
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// T is TPixel32 or TPixel64
|
|
Toshihiro Shimizu |
890ddd |
// U is unsigned char or unsigned short
|
|
Toshihiro Shimizu |
890ddd |
template <class class="" t,="" u=""></class>
|
|
Toshihiro Shimizu |
890ddd |
void ras_to_arr_(
|
|
Toshihiro Shimizu |
890ddd |
const TRasterPT<t> ras, U *arr, const int channels)</t>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
using namespace igs::image::rgba;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (int yy = 0; yy < ras->getLy(); ++yy) {
|
|
Toshihiro Shimizu |
890ddd |
const T *ras_sl = ras->pixels(yy);
|
|
Toshihiro Shimizu |
890ddd |
for (int xx = 0; xx < ras->getLx(); ++xx, arr += channels) {
|
|
Toshihiro Shimizu |
890ddd |
if (red < channels) {
|
|
Toshihiro Shimizu |
890ddd |
arr[red] = ras_sl[xx].r;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (gre < channels) {
|
|
Toshihiro Shimizu |
890ddd |
arr[gre] = ras_sl[xx].g;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (blu < channels) {
|
|
Toshihiro Shimizu |
890ddd |
arr[blu] = ras_sl[xx].b;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (alp < channels) {
|
|
Toshihiro Shimizu |
890ddd |
arr[alp] = ras_sl[xx].m;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
template <class class="" t="" u,=""></class>
|
|
Toshihiro Shimizu |
890ddd |
void arr_to_ras_(
|
|
Toshihiro Shimizu |
890ddd |
const U *arr, const int channels, TRasterPT<t> ras, const int margin // default is 0</t>
|
|
Toshihiro Shimizu |
890ddd |
)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
arr += (ras->getLx() + margin + margin) * margin * channels +
|
|
Toshihiro Shimizu |
890ddd |
margin * channels;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace igs::image::rgba;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (int yy = 0; yy < ras->getLy(); ++yy, arr += (ras->getLx() + margin + margin) * channels) {
|
|
Toshihiro Shimizu |
890ddd |
const U *arrx = arr;
|
|
Toshihiro Shimizu |
890ddd |
T *ras_sl = ras->pixels(yy);
|
|
Toshihiro Shimizu |
890ddd |
for (int xx = 0; xx < ras->getLx(); ++xx, arrx += channels) {
|
|
Toshihiro Shimizu |
890ddd |
if (red < channels) {
|
|
Toshihiro Shimizu |
890ddd |
ras_sl[xx].r = arrx[red];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (gre < channels) {
|
|
Toshihiro Shimizu |
890ddd |
ras_sl[xx].g = arrx[gre];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (blu < channels) {
|
|
Toshihiro Shimizu |
890ddd |
ras_sl[xx].b = arrx[blu];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (alp < channels) {
|
|
Toshihiro Shimizu |
890ddd |
ras_sl[xx].m = arrx[alp];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//--------------------
|
|
Toshihiro Shimizu |
890ddd |
void ino::ras_to_arr(
|
|
Toshihiro Shimizu |
890ddd |
const TRasterP in_ras, const int channels, unsigned char *out_arr)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if ((TRaster32P)in_ras) {
|
|
Toshihiro Shimizu |
890ddd |
ras_to_arr_<tpixel32, char="" unsigned="">(</tpixel32,>
|
|
Toshihiro Shimizu |
890ddd |
in_ras, out_arr, channels);
|
|
Toshihiro Shimizu |
890ddd |
} else if ((TRaster64P)in_ras) {
|
|
Toshihiro Shimizu |
890ddd |
ras_to_arr_<tpixel64, short="" unsigned="">(</tpixel64,>
|
|
Toshihiro Shimizu |
890ddd |
in_ras, reinterpret_cast<unsigned *="" short="">(out_arr), channels);</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void ino::arr_to_ras(
|
|
Toshihiro Shimizu |
890ddd |
const unsigned char *in_arr, const int channels, TRasterP out_ras, const int margin)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if ((TRaster32P)out_ras) {
|
|
Toshihiro Shimizu |
890ddd |
arr_to_ras_<unsigned char,="" tpixel32="">(</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
in_arr, channels, out_ras, margin);
|
|
Toshihiro Shimizu |
890ddd |
} else if ((TRaster64P)out_ras) {
|
|
Toshihiro Shimizu |
890ddd |
arr_to_ras_<unsigned short,="" tpixel64="">(</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
reinterpret_cast<const *="" short="" unsigned="">(in_arr), channels, out_ras, margin);</const>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//--------------------
|
|
Toshihiro Shimizu |
890ddd |
void ino::ras_to_vec(
|
|
Toshihiro Shimizu |
890ddd |
const TRasterP in_ras, const int channels, std::vector<unsigned char=""> &out_vec)</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
out_vec.resize(
|
|
Toshihiro Shimizu |
890ddd |
in_ras->getLy() * in_ras->getLx() * channels *
|
|
Toshihiro Shimizu |
890ddd |
(((TRaster64P)in_ras) ? sizeof(unsigned short) : sizeof(unsigned char)));
|
|
Toshihiro Shimizu |
890ddd |
ino::ras_to_arr(in_ras, channels, &out_vec.at(0));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void ino::vec_to_ras(
|
|
Toshihiro Shimizu |
890ddd |
std::vector<unsigned char=""> &in_vec, const int channels, TRasterP out_ras, const int margin // default is 0</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
ino::arr_to_ras(&in_vec.at(0), channels, out_ras, margin);
|
|
Toshihiro Shimizu |
890ddd |
in_vec.clear();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//--------------------
|
|
Toshihiro Shimizu |
890ddd |
#if 0 //---
|
|
Toshihiro Shimizu |
890ddd |
void ino::Lx_to_wrap( TRasterP ras ) {
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
ras->getLx() : 描画の幅
|
|
Toshihiro Shimizu |
890ddd |
ras->getWrap() : データの存在幅
|
|
Toshihiro Shimizu |
890ddd |
描画幅よりデータの存在幅の方が大きい場合、
|
|
Toshihiro Shimizu |
890ddd |
存在幅位置に置き直し、残りをゼロクリア
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
if ( ras->getWrap() <= ras->getLx() ) { return; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const int rowSize = ras->getLx() * ras->getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
const int wrapSize = ras->getWrap() * ras->getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
const int restSize = wrapSize - rowSize;
|
|
Toshihiro Shimizu |
890ddd |
const UCHAR *rowImg = ras->getRawData()+rowSize *(ras->getLy()-1);
|
|
Toshihiro Shimizu |
890ddd |
UCHAR *wrapImg = ras->getRawData()+wrapSize*(ras->getLy()-1);
|
|
Toshihiro Shimizu |
890ddd |
for (int yy = 0; yy < ras->getLy(); ++yy) {
|
|
Toshihiro Shimizu |
890ddd |
::memcpy(wrapImg, rowImg, rowSize);
|
|
Toshihiro Shimizu |
890ddd |
::memset(wrapImg+rowSize, 0, restSize); /* 上下にはみ出すとここで落ちる */
|
|
Toshihiro Shimizu |
890ddd |
rowImg -= rowSize;
|
|
Toshihiro Shimizu |
890ddd |
wrapImg -= wrapSize;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#endif //---
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
bool enable_sw_ = true;
|
|
Toshihiro Shimizu |
890ddd |
bool check_sw_ = true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
bool ino::log_enable_sw(void)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (check_sw_) {
|
|
Toshihiro Shimizu |
890ddd |
TFileStatus file(
|
|
Toshihiro Shimizu |
890ddd |
// ToonzFolder::getProfileFolder()
|
|
Toshihiro Shimizu |
890ddd |
TEnv::getConfigDir() + "fx_ino_no_log.setup");
|
|
Toshihiro Shimizu |
890ddd |
if (file.doesExist()) {
|
|
Toshihiro Shimizu |
890ddd |
enable_sw_ = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
check_sw_ = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return enable_sw_;
|
|
Toshihiro Shimizu |
890ddd |
}
|