|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "stdfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamuiconcept.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class RadialBlurFx : public TStandardRasterFx
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_DECLARATION(RadialBlurFx)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterFxPort m_input;
|
|
Toshihiro Shimizu |
890ddd |
TPointParamP m_point;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_radius;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_blur;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
RadialBlurFx()
|
|
Toshihiro Shimizu |
890ddd |
: m_point(TPointD(0.0, 0.0)), m_radius(0.0), m_blur(5.0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_point->getX()->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
m_point->getY()->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
m_radius->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "point", m_point);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "radius", m_radius);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "blur", m_blur);
|
|
Toshihiro Shimizu |
890ddd |
addInputPort("Source", m_input);
|
|
Toshihiro Shimizu |
890ddd |
m_radius->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Toshihiro Shimizu |
890ddd |
m_blur->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~RadialBlurFx(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getMaxBraid(const TRectD &bBox, double frame, const TAffine &aff = TAffine())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double scale = sqrt(fabs(aff.det()));
|
|
Toshihiro Shimizu |
890ddd |
TPointD point = aff * m_point->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double radius = m_radius->getValue(frame) * scale;
|
|
Toshihiro Shimizu |
890ddd |
double blur = m_blur->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double intensity = blur * (TConsts::pi / 180);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD p1 = bBox.getP00() - point;
|
|
Toshihiro Shimizu |
890ddd |
TPointD p2 = bBox.getP01() - point;
|
|
Toshihiro Shimizu |
890ddd |
TPointD p3 = bBox.getP10() - point;
|
|
Toshihiro Shimizu |
890ddd |
TPointD p4 = bBox.getP11() - point;
|
|
Toshihiro Shimizu |
890ddd |
double d1 = p1.x * p1.x + p1.y * p1.y;
|
|
Toshihiro Shimizu |
890ddd |
double d2 = p2.x * p2.x + p2.y * p2.y;
|
|
Toshihiro Shimizu |
890ddd |
double d3 = p3.x * p3.x + p3.y * p3.y;
|
|
Toshihiro Shimizu |
890ddd |
double d4 = p4.x * p4.x + p4.y * p4.y;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double maxD = tmax(tmax(tmax(d3, d4), d2), d1);
|
|
Toshihiro Shimizu |
890ddd |
return tround(tmax(sqrt(maxD) - radius, 0.0)) * intensity;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void enlarge(
|
|
Toshihiro Shimizu |
890ddd |
const TRectD &bbox, TRectD &requestedGeom,
|
|
Toshihiro Shimizu |
890ddd |
const TRenderSettings &ri, double frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool doGetBBox(double frame, TRectD &bBox, const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_input.isConnected()) {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_input->doGetBBox(frame, bBox, info);
|
|
Toshihiro Shimizu |
890ddd |
bBox = bBox.enlarge(getMaxBraid(bBox, frame));
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
bBox = TRectD();
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void transform(double frame,
|
|
Toshihiro Shimizu |
890ddd |
int port,
|
|
Toshihiro Shimizu |
890ddd |
const TRectD &rectOnOutput,
|
|
Toshihiro Shimizu |
890ddd |
const TRenderSettings &infoOnOutput,
|
|
Toshihiro Shimizu |
890ddd |
TRectD &rectOnInput,
|
|
Toshihiro Shimizu |
890ddd |
TRenderSettings &infoOnInput);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void doCompute(TTile &tile, double frame, const TRenderSettings &);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getMemoryRequirement(const TRectD &rect, double frame, const TRenderSettings &info);
|
|
Toshihiro Shimizu |
890ddd |
bool canHandle(const TRenderSettings &info, double frame)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (info.m_isSwatch)
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return m_blur->getValue(frame) == 0 ? true : isAlmostIsotropic(info.m_affine);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void getParamUIs(TParamUIConcept *&concepts, int &length)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
concepts = new TParamUIConcept[length = 2];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
concepts[0].m_type = TParamUIConcept::POINT;
|
|
Toshihiro Shimizu |
890ddd |
concepts[0].m_label = "Center";
|
|
Toshihiro Shimizu |
890ddd |
concepts[0].m_params.push_back(m_point);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
concepts[1].m_type = TParamUIConcept::RADIUS;
|
|
Toshihiro Shimizu |
890ddd |
concepts[1].m_label = "Radius";
|
|
Toshihiro Shimizu |
890ddd |
concepts[1].m_params.push_back(m_radius);
|
|
Toshihiro Shimizu |
890ddd |
concepts[1].m_params.push_back(m_point);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
template <typename channel_type,="" int="" max_channel_value="" pixel,="" typename=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
void doRadialBlur(const TRasterPT<pixel> rout, const TRasterPT<pixel> rin, double blur, double radius, TPointD point)</pixel></pixel>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/*-センター位置-*/
|
|
Toshihiro Shimizu |
890ddd |
int dx = (int)point.x;
|
|
Toshihiro Shimizu |
890ddd |
int dy = (int)point.y;
|
|
Toshihiro Shimizu |
890ddd |
int i, j;
|
|
Toshihiro Shimizu |
890ddd |
/*- 出力サイズ -*/
|
|
Toshihiro Shimizu |
890ddd |
int lx = rout->getLx();
|
|
Toshihiro Shimizu |
890ddd |
int ly = rout->getLy();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PIXEL *src_buf, *dst_buf;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*- チャンネル最大値(bppにより異なる) -*/
|
|
Toshihiro Shimizu |
890ddd |
double CROP_VAL = (double)MAX_CHANNEL_VALUE;
|
|
Toshihiro Shimizu |
890ddd |
CHANNEL_TYPE U_CROP_VAL = MAX_CHANNEL_VALUE;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double intensity = blur * (TConsts::pi / 180);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-出力サイズの画面の中の、ブラーのセンター位置-*/
|
|
Toshihiro Shimizu |
890ddd |
int cx = lx / 2 + dx;
|
|
Toshihiro Shimizu |
890ddd |
int cy = ly / 2 + dy;
|
|
Toshihiro Shimizu |
890ddd |
rin->lock();
|
|
Toshihiro Shimizu |
890ddd |
rout->lock();
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < ly; i++) {
|
|
Toshihiro Shimizu |
890ddd |
src_buf = rin->pixels(i);
|
|
Toshihiro Shimizu |
890ddd |
dst_buf = rout->pixels(i);
|
|
Toshihiro Shimizu |
890ddd |
for (j = 0; j < lx; j++, src_buf++, dst_buf++) {
|
|
Toshihiro Shimizu |
890ddd |
double valr = 0, valg = 0, valb = 0, valm = 0;
|
|
Toshihiro Shimizu |
890ddd |
double sinangle = 0, cosangle = 0;
|
|
Toshihiro Shimizu |
890ddd |
double angle = 0, dist, rangeinv = 0;
|
|
Toshihiro Shimizu |
890ddd |
int ii, vx, vy;
|
|
Toshihiro Shimizu |
890ddd |
int shiftx, shifty, range = 0, rangehalf;
|
|
Toshihiro Shimizu |
890ddd |
/*- ブラー中心→現在のピクセルへのベクトル -*/
|
|
Toshihiro Shimizu |
890ddd |
vx = (int)(j - cx);
|
|
Toshihiro Shimizu |
890ddd |
vy = (int)(i - cy);
|
|
Toshihiro Shimizu |
890ddd |
dist = sqrt((double)(vx * vx + vy * vy));
|
|
Toshihiro Shimizu |
890ddd |
/*- ブラーのかかる大きさ。(距離-radius)に比例 -*/
|
|
Toshihiro Shimizu |
890ddd |
range = (int)((dist - radius) * intensity);
|
|
Toshihiro Shimizu |
890ddd |
/*- ブラーが少しでもかかる場合 -*/
|
|
Toshihiro Shimizu |
890ddd |
if (range >= 1 && (dist - radius) > 0) {
|
|
Toshihiro Shimizu |
890ddd |
rangehalf = range / 2;
|
|
Toshihiro Shimizu |
890ddd |
/*- ブラーの角度 -*/
|
|
Toshihiro Shimizu |
890ddd |
angle = atan2((double)vy, (double)vx);
|
|
Toshihiro Shimizu |
890ddd |
cosangle = cos(angle);
|
|
Toshihiro Shimizu |
890ddd |
if (vx)
|
|
Toshihiro Shimizu |
890ddd |
sinangle = cosangle * (vy / (float)vx);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
sinangle = sin(angle);
|
|
Toshihiro Shimizu |
890ddd |
for (ii = 0; ii <= range; ii++) {
|
|
Toshihiro Shimizu |
890ddd |
shiftx = (int)((ii - rangehalf) * cosangle);
|
|
Toshihiro Shimizu |
890ddd |
shifty = (int)((ii - rangehalf) * sinangle);
|
|
Toshihiro Shimizu |
890ddd |
/*- 画面外にはみだす条件 -*/
|
|
Toshihiro Shimizu |
890ddd |
if ((j + shiftx) < 0)
|
|
Toshihiro Shimizu |
890ddd |
continue; // shiftx=-j;
|
|
Toshihiro Shimizu |
890ddd |
if ((j + shiftx) >= lx)
|
|
Toshihiro Shimizu |
890ddd |
continue; //shiftx=lx-j-1;
|
|
Toshihiro Shimizu |
890ddd |
if ((i + shifty) < 0)
|
|
Toshihiro Shimizu |
890ddd |
continue; //shifty=-i;
|
|
Toshihiro Shimizu |
890ddd |
if ((i + shifty) >= ly)
|
|
Toshihiro Shimizu |
890ddd |
continue; //shifty=ly-i-1;
|
|
Toshihiro Shimizu |
890ddd |
valr += rin->pixels(i + shifty)[j + shiftx].r;
|
|
Toshihiro Shimizu |
890ddd |
valg += rin->pixels(i + shifty)[j + shiftx].g;
|
|
Toshihiro Shimizu |
890ddd |
valb += rin->pixels(i + shifty)[j + shiftx].b;
|
|
Toshihiro Shimizu |
890ddd |
valm += rin->pixels(i + shifty)[j + shiftx].m;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
rangeinv = 1.0 / (range + 1);
|
|
Toshihiro Shimizu |
890ddd |
valr *= rangeinv;
|
|
Toshihiro Shimizu |
890ddd |
valg *= rangeinv;
|
|
Toshihiro Shimizu |
890ddd |
valb *= rangeinv;
|
|
Toshihiro Shimizu |
890ddd |
valm *= rangeinv;
|
|
Toshihiro Shimizu |
890ddd |
dst_buf->r = (valr > CROP_VAL) ? U_CROP_VAL : ((valr < 0) ? 0 : (CHANNEL_TYPE)valr);
|
|
Toshihiro Shimizu |
890ddd |
dst_buf->g = (valg > CROP_VAL) ? U_CROP_VAL : ((valg < 0) ? 0 : (CHANNEL_TYPE)valg);
|
|
Toshihiro Shimizu |
890ddd |
dst_buf->b = (valb > CROP_VAL) ? U_CROP_VAL : ((valb < 0) ? 0 : (CHANNEL_TYPE)valb);
|
|
Toshihiro Shimizu |
890ddd |
dst_buf->m = (valm > CROP_VAL) ? U_CROP_VAL : ((valm < 0) ? 0 : (CHANNEL_TYPE)valm);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
*(dst_buf) = *(src_buf);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
rin->unlock();
|
|
Toshihiro Shimizu |
890ddd |
rout->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Calculates the geometry we need for this node computation, given
|
|
Toshihiro Shimizu |
890ddd |
//!the known input data (bbox) and the requested output (requestedGeom).
|
|
Toshihiro Shimizu |
890ddd |
void RadialBlurFx::enlarge(
|
|
Toshihiro Shimizu |
890ddd |
const TRectD &bbox, TRectD &requestedGeom,
|
|
Toshihiro Shimizu |
890ddd |
const TRenderSettings &ri, double frame)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRectD enlargedBbox(bbox);
|
|
Toshihiro Shimizu |
890ddd |
TRectD enlargedGeom(requestedGeom);
|
|
Toshihiro Shimizu |
890ddd |
TPointD originalP00(requestedGeom.getP00());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double maxRange = getMaxBraid(enlargedBbox, frame, ri.m_affine);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*- 最低でも1pixel追加する -*/
|
|
Toshihiro Shimizu |
890ddd |
maxRange = tmax(maxRange, 1.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enlargedBbox = enlargedBbox.enlarge(maxRange);
|
|
Toshihiro Shimizu |
890ddd |
enlargedGeom = enlargedGeom.enlarge(maxRange);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//We are to find out the geometry that is useful for the fx computation.
|
|
Toshihiro Shimizu |
890ddd |
//There are some rules to follow:
|
|
Toshihiro Shimizu |
890ddd |
// a) First, the interesting output we can generate is bounded by both
|
|
Toshihiro Shimizu |
890ddd |
// the requestedRect and the blurred bbox (i.e. enlarged by the blur radius).
|
|
Toshihiro Shimizu |
890ddd |
// b) Pixels contributing to any output are necessarily part of bbox - and only
|
|
Toshihiro Shimizu |
890ddd |
// those which are blurrable into the requestedRect are useful to us
|
|
Toshihiro Shimizu |
890ddd |
// (i.e. pixels contained in its enlargement by the blur radius).
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
requestedGeom = (enlargedGeom * bbox) + (enlargedBbox * requestedGeom);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Finally, make sure that the result is coherent with the original P00
|
|
Toshihiro Shimizu |
890ddd |
requestedGeom -= originalP00;
|
|
Toshihiro Shimizu |
890ddd |
requestedGeom.x0 = tfloor(requestedGeom.x0);
|
|
Toshihiro Shimizu |
890ddd |
requestedGeom.y0 = tfloor(requestedGeom.y0);
|
|
Toshihiro Shimizu |
890ddd |
requestedGeom.x1 = tceil(requestedGeom.x1);
|
|
Toshihiro Shimizu |
890ddd |
requestedGeom.y1 = tceil(requestedGeom.y1);
|
|
Toshihiro Shimizu |
890ddd |
requestedGeom += originalP00;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RadialBlurFx::transform(
|
|
Toshihiro Shimizu |
890ddd |
double frame,
|
|
Toshihiro Shimizu |
890ddd |
int port,
|
|
Toshihiro Shimizu |
890ddd |
const TRectD &rectOnOutput,
|
|
Toshihiro Shimizu |
890ddd |
const TRenderSettings &infoOnOutput,
|
|
Toshihiro Shimizu |
890ddd |
TRectD &rectOnInput,
|
|
Toshihiro Shimizu |
890ddd |
TRenderSettings &infoOnInput)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRectD rectOut(rectOnOutput);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (canHandle(infoOnOutput, frame))
|
|
Toshihiro Shimizu |
890ddd |
infoOnInput = infoOnOutput;
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
infoOnInput = infoOnOutput;
|
|
Toshihiro Shimizu |
890ddd |
infoOnInput.m_affine = TAffine(); // because the affine does not commute
|
|
Toshihiro Shimizu |
890ddd |
rectOut = infoOnOutput.m_affine.inv() * rectOut;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD bbox;
|
|
Toshihiro Shimizu |
890ddd |
m_input->getBBox(frame, bbox, infoOnInput);
|
|
Toshihiro Shimizu |
890ddd |
if (rectOnInput == TConsts::infiniteRectD)
|
|
Toshihiro Shimizu |
890ddd |
bbox = rectOut;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
rectOnInput = rectOut;
|
|
Toshihiro Shimizu |
890ddd |
enlarge(bbox, rectOnInput, infoOnInput, frame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RadialBlurFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_input.isConnected())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double scale = sqrt(fabs(ri.m_affine.det()));
|
|
Toshihiro Shimizu |
890ddd |
TPointD point = ri.m_affine * m_point->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double radius = m_radius->getValue(frame) * scale;
|
|
Toshihiro Shimizu |
890ddd |
double blur = m_blur->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD tileRect = convert(tile.getRaster()->getBounds()) + tile.m_pos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD bBox;
|
|
Toshihiro Shimizu |
890ddd |
m_input->getBBox(frame, bBox, ri);
|
|
Toshihiro Shimizu |
890ddd |
if (bBox.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (bBox == TConsts::infiniteRectD)
|
|
Toshihiro Shimizu |
890ddd |
bBox = tileRect;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enlarge(bBox, tileRect, ri, frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD tileRectCenter = (tileRect.getP00() + tileRect.getP11()) * 0.5;
|
|
Toshihiro Shimizu |
890ddd |
point -= tileRectCenter;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int rasInLx = tileRect.getLx();
|
|
Toshihiro Shimizu |
890ddd |
int rasInLy = tileRect.getLy();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P raster32 = tile.getRaster();
|
|
Toshihiro Shimizu |
890ddd |
TRaster64P raster64 = tile.getRaster();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint offset = convert(tile.m_pos - tileRect.getP00());
|
|
Toshihiro Shimizu |
890ddd |
TTile tileIn;
|
|
Toshihiro Shimizu |
890ddd |
if (raster32) {
|
|
Toshihiro Shimizu |
890ddd |
m_input->allocateAndCompute(tileIn, tileRect.getP00(),
|
|
Toshihiro Shimizu |
890ddd |
TDimension(rasInLx, rasInLy),
|
|
Toshihiro Shimizu |
890ddd |
raster32, frame, ri);
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P rin = tileIn.getRaster();
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P app = raster32->create(rasInLx, rasInLy);
|
|
Toshihiro Shimizu |
890ddd |
doRadialBlur<tpixel32, 255="" uchar,="">(app, rin, blur, radius, point);</tpixel32,>
|
|
Toshihiro Shimizu |
890ddd |
raster32->copy(app, -offset);
|
|
Toshihiro Shimizu |
890ddd |
} else if (raster64) {
|
|
Toshihiro Shimizu |
890ddd |
TRaster64P raster64 = tile.getRaster();
|
|
Toshihiro Shimizu |
890ddd |
m_input->allocateAndCompute(tileIn, tileRect.getP00(),
|
|
Toshihiro Shimizu |
890ddd |
TDimension(rasInLx, rasInLy),
|
|
Toshihiro Shimizu |
890ddd |
raster64, frame, ri);
|
|
Toshihiro Shimizu |
890ddd |
TRaster64P rin = tileIn.getRaster();
|
|
Toshihiro Shimizu |
890ddd |
TRaster64P app = raster64->create(rasInLx, rasInLy);
|
|
Toshihiro Shimizu |
890ddd |
doRadialBlur<tpixel64, 65535="" ushort,="">(app, rin, blur, radius, point);</tpixel64,>
|
|
Toshihiro Shimizu |
890ddd |
raster64->copy(app, -offset);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
throw TException("Brightness&Contrast: unsupported Pixel Type");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int RadialBlurFx::getMemoryRequirement(const TRectD &rect, double frame, const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double scale = sqrt(fabs(info.m_affine.det()));
|
|
Toshihiro Shimizu |
890ddd |
TPointD point = info.m_affine * m_point->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double blur = m_blur->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD bBox;
|
|
Toshihiro Shimizu |
890ddd |
m_input->getBBox(frame, bBox, info);
|
|
Toshihiro Shimizu |
890ddd |
if (bBox.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (bBox == TConsts::infiniteRectD)
|
|
Toshihiro Shimizu |
890ddd |
bBox = rect;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD tileRect(rect);
|
|
Toshihiro Shimizu |
890ddd |
enlarge(bBox, tileRect, info, frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return TRasterFx::memorySize(tileRect.enlarge(blur), info.m_bpp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(RadialBlurFx, "radialBlurFx")
|