|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/rasterstrokegenerator.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trastercm.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/rasterbrush.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trop.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
RasterStrokeGenerator::RasterStrokeGenerator(const TRasterCM32P &raster,
|
|
Shinya Kitaoka |
120a6e |
Tasks task, ColorType colorType,
|
|
Shinya Kitaoka |
120a6e |
int styleId, const TThickPoint &p,
|
|
Shinya Kitaoka |
120a6e |
bool selective, int selectedStyle,
|
|
shun-iwasawa |
975eb1 |
bool keepAntialias,
|
|
shun-iwasawa |
975eb1 |
bool isPaletteOrder)
|
|
Shinya Kitaoka |
120a6e |
: m_raster(raster)
|
|
Shinya Kitaoka |
120a6e |
, m_boxOfRaster(TRect(raster->getSize()))
|
|
Shinya Kitaoka |
120a6e |
, m_styleId(styleId)
|
|
Shinya Kitaoka |
120a6e |
, m_selective(selective)
|
|
Shinya Kitaoka |
120a6e |
, m_task(task)
|
|
Shinya Kitaoka |
120a6e |
, m_colorType(colorType)
|
|
Shinya Kitaoka |
120a6e |
, m_eraseStyle(4095)
|
|
Shinya Kitaoka |
120a6e |
, m_selectedStyle(selectedStyle)
|
|
Shinya Kitaoka |
120a6e |
, m_keepAntiAlias(keepAntialias)
|
|
shun-iwasawa |
975eb1 |
, m_doAnArc(false)
|
|
shun-iwasawa |
975eb1 |
, m_isPaletteOrder(isPaletteOrder) {
|
|
Shinya Kitaoka |
120a6e |
TThickPoint pp = p;
|
|
Shinya Kitaoka |
120a6e |
m_points.push_back(pp);
|
|
Shinya Kitaoka |
120a6e |
if (task == ERASE) m_styleId = m_eraseStyle;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
RasterStrokeGenerator::~RasterStrokeGenerator() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
cd7d6a |
void RasterStrokeGenerator::add(const TThickPoint &p) {
|
|
Shinya Kitaoka |
120a6e |
TThickPoint pp = p;
|
|
Shinya Kitaoka |
120a6e |
TThickPoint mid((m_points.back() + pp) * 0.5,
|
|
Shinya Kitaoka |
120a6e |
(p.thick + m_points.back().thick) * 0.5);
|
|
Shinya Kitaoka |
120a6e |
m_points.push_back(mid);
|
|
Shinya Kitaoka |
120a6e |
m_points.push_back(pp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Disegna il tratto interamente
|
|
Shinya Kitaoka |
120a6e |
void RasterStrokeGenerator::generateStroke(bool isPencil) const {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tthickpoint> points(m_points);</tthickpoint>
|
|
Shinya Kitaoka |
120a6e |
int size = points.size();
|
|
Shinya Kitaoka |
120a6e |
// Prende un buffer trasparente di appoggio
|
|
Shinya Kitaoka |
120a6e |
TRect box = getBBox(points);
|
|
Shinya Kitaoka |
120a6e |
TPoint newOrigin = box.getP00();
|
|
Shinya Kitaoka |
120a6e |
TRasterCM32P rasBuffer(box.getSize());
|
|
Shinya Kitaoka |
120a6e |
rasBuffer->clear();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Trasla i punti secondo il nuovo sitema di riferimento
|
|
Shinya Kitaoka |
120a6e |
translatePoints(points, newOrigin);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::vector<tthickpoint> partialPoints;</tthickpoint>
|
|
Shinya Kitaoka |
120a6e |
if (size == 1) {
|
|
Shinya Kitaoka |
120a6e |
rasterBrush(rasBuffer, points, m_styleId, !isPencil);
|
|
Shinya Kitaoka |
120a6e |
placeOver(m_raster, rasBuffer, newOrigin);
|
|
Shinya Kitaoka |
120a6e |
} else if (size <= 3) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tthickpoint> partialPoints;</tthickpoint>
|
|
Shinya Kitaoka |
120a6e |
partialPoints.push_back(points[0]);
|
|
Shinya Kitaoka |
120a6e |
partialPoints.push_back(points[1]);
|
|
Shinya Kitaoka |
120a6e |
rasterBrush(rasBuffer, partialPoints, m_styleId, !isPencil);
|
|
Shinya Kitaoka |
120a6e |
placeOver(m_raster, rasBuffer, newOrigin);
|
|
Shinya Kitaoka |
120a6e |
} else if (size % 2 == 1) /*-- 奇数の場合 --*/
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
int strokeCount = (size - 1) / 2 - 1;
|
|
Shinya Kitaoka |
120a6e |
std::vector<tthickpoint> partialPoints;</tthickpoint>
|
|
Shinya Kitaoka |
120a6e |
partialPoints.push_back(points[0]);
|
|
Shinya Kitaoka |
120a6e |
partialPoints.push_back(points[1]);
|
|
Shinya Kitaoka |
120a6e |
rasterBrush(rasBuffer, partialPoints, m_styleId, !isPencil);
|
|
Shinya Kitaoka |
120a6e |
placeOver(m_raster, rasBuffer, newOrigin);
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < strokeCount; i++) {
|
|
Shinya Kitaoka |
120a6e |
partialPoints.clear();
|
|
Shinya Kitaoka |
120a6e |
rasBuffer->clear();
|
|
Shinya Kitaoka |
120a6e |
partialPoints.push_back(points[i * 2 + 1]);
|
|
Shinya Kitaoka |
120a6e |
partialPoints.push_back(points[i * 2 + 2]);
|
|
Shinya Kitaoka |
120a6e |
partialPoints.push_back(points[i * 2 + 3]);
|
|
Shinya Kitaoka |
120a6e |
if (i == strokeCount - 1) partialPoints.push_back(points[i * 2 + 4]);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
rasterBrush(rasBuffer, partialPoints, m_styleId, !isPencil);
|
|
Shinya Kitaoka |
120a6e |
placeOver(m_raster, rasBuffer, newOrigin);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tthickpoint> partialPoints;</tthickpoint>
|
|
Shinya Kitaoka |
120a6e |
partialPoints.push_back(points[0]);
|
|
Shinya Kitaoka |
120a6e |
partialPoints.push_back(points[1]);
|
|
Shinya Kitaoka |
120a6e |
rasterBrush(rasBuffer, partialPoints, m_styleId, !isPencil);
|
|
Shinya Kitaoka |
120a6e |
placeOver(m_raster, rasBuffer, newOrigin);
|
|
Shinya Kitaoka |
120a6e |
if (size > 2) {
|
|
Shinya Kitaoka |
120a6e |
partialPoints.clear();
|
|
Shinya Kitaoka |
120a6e |
std::vector<tthickpoint>::iterator it = points.begin();</tthickpoint>
|
|
Shinya Kitaoka |
120a6e |
it++;
|
|
Shinya Kitaoka |
120a6e |
partialPoints.insert(partialPoints.begin(), it, points.end());
|
|
Shinya Kitaoka |
120a6e |
rasterBrush(rasBuffer, partialPoints, m_styleId, !isPencil);
|
|
Shinya Kitaoka |
120a6e |
placeOver(m_raster, rasBuffer, newOrigin);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRect RasterStrokeGenerator::generateLastPieceOfStroke(bool isPencil,
|
|
Shinya Kitaoka |
120a6e |
bool closeStroke) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tthickpoint> points;</tthickpoint>
|
|
Shinya Kitaoka |
120a6e |
int size = m_points.size();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (size == 3) {
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[0]);
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[1]);
|
|
Shinya Kitaoka |
120a6e |
} else if (size == 1)
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[0]);
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[size - 4]);
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[size - 3]);
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[size - 2]);
|
|
Shinya Kitaoka |
120a6e |
if (closeStroke) points.push_back(m_points[size - 1]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRect box = getBBox(points);
|
|
Shinya Kitaoka |
120a6e |
TPoint newOrigin = box.getP00();
|
|
Shinya Kitaoka |
120a6e |
TRasterCM32P rasBuffer(box.getSize());
|
|
Shinya Kitaoka |
120a6e |
rasBuffer->clear();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Trasla i punti secondo il nuovo sitema di riferimento
|
|
Shinya Kitaoka |
120a6e |
translatePoints(points, newOrigin);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
rasterBrush(rasBuffer, points, m_styleId, !isPencil);
|
|
Shinya Kitaoka |
120a6e |
placeOver(m_raster, rasBuffer, newOrigin);
|
|
Shinya Kitaoka |
120a6e |
return box;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Ritorna il rettangolo contenente i dischi generati con centri in "points" e
|
|
Shinya Kitaoka |
120a6e |
// diametro "points.thick" +3 pixel a bordo
|
|
Shinya Kitaoka |
120a6e |
TRect RasterStrokeGenerator::getBBox(
|
|
Shinya Kitaoka |
120a6e |
const std::vector<tthickpoint> &points) const {</tthickpoint>
|
|
Shinya Kitaoka |
120a6e |
double x0 = (std::numeric_limits<double>::max)(),</double>
|
|
Shinya Kitaoka |
120a6e |
y0 = (std::numeric_limits<double>::max)(),</double>
|
|
Shinya Kitaoka |
120a6e |
x1 = -(std::numeric_limits<double>::max)(),</double>
|
|
Shinya Kitaoka |
120a6e |
y1 = -(std::numeric_limits<double>::max)();</double>
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < (int)points.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
double radius = points[i].thick * 0.5;
|
|
Shinya Kitaoka |
120a6e |
if (points[i].x - radius < x0) x0 = points[i].x - radius;
|
|
Shinya Kitaoka |
120a6e |
if (points[i].x + radius > x1) x1 = points[i].x + radius;
|
|
Shinya Kitaoka |
120a6e |
if (points[i].y - radius < y0) y0 = points[i].y - radius;
|
|
Shinya Kitaoka |
120a6e |
if (points[i].y + radius > y1) y1 = points[i].y + radius;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return TRect(TPoint((int)floor(x0 - 3), (int)floor(y0 - 3)),
|
|
Shinya Kitaoka |
120a6e |
TPoint((int)ceil(x1 + 3), (int)ceil(y1 + 3)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Ricalcola i punti in un nuovo sistema di riferimento
|
|
Shinya Kitaoka |
120a6e |
void RasterStrokeGenerator::translatePoints(std::vector<tthickpoint> &points,</tthickpoint>
|
|
Shinya Kitaoka |
120a6e |
const TPoint &newOrigin) const {
|
|
Shinya Kitaoka |
120a6e |
TPointD p(newOrigin.x, newOrigin.y);
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < (int)points.size(); i++) points[i] -= p;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Effettua la over.
|
|
Shinya Kitaoka |
120a6e |
void RasterStrokeGenerator::placeOver(const TRasterCM32P &out,
|
|
Shinya Kitaoka |
120a6e |
const TRasterCM32P &in,
|
|
Shinya Kitaoka |
120a6e |
const TPoint &p) const {
|
|
Shinya Kitaoka |
120a6e |
TRect inBox = in->getBounds() + p;
|
|
Shinya Kitaoka |
120a6e |
TRect outBox = out->getBounds();
|
|
Shinya Kitaoka |
120a6e |
TRect box = inBox * outBox;
|
|
Shinya Kitaoka |
120a6e |
if (box.isEmpty()) return;
|
|
Shinya Kitaoka |
120a6e |
TRasterCM32P rOut = out->extract(box);
|
|
Shinya Kitaoka |
120a6e |
TRect box2 = box - p;
|
|
Shinya Kitaoka |
120a6e |
TRasterCM32P rIn = in->extract(box2);
|
|
Shinya Kitaoka |
120a6e |
for (int y = 0; y < rOut->getLy(); y++) {
|
|
Shinya Kitaoka |
120a6e |
/*-- Finger Toolの境界条件 --*/
|
|
Shinya Kitaoka |
120a6e |
if (m_task == FINGER && (y == 0 || y == rOut->getLy() - 1)) continue;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixelCM32 *inPix = rIn->pixels(y);
|
|
Shinya Kitaoka |
120a6e |
TPixelCM32 *outPix = rOut->pixels(y);
|
|
Shinya Kitaoka |
120a6e |
TPixelCM32 *outEnd = outPix + rOut->getLx();
|
|
Shinya Kitaoka |
120a6e |
for (; outPix < outEnd; ++inPix, ++outPix) {
|
|
Shinya Kitaoka |
120a6e |
if (m_task == BRUSH) {
|
|
Shinya Kitaoka |
120a6e |
int inTone = inPix->getTone();
|
|
Shinya Kitaoka |
120a6e |
int outTone = outPix->getTone();
|
|
Shinya Kitaoka |
120a6e |
if (inPix->isPureInk() && !m_selective) {
|
|
Shinya Kitaoka |
120a6e |
*outPix = TPixelCM32(inPix->getInk(), outPix->getPaint(), inTone);
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (outPix->isPureInk() && m_selective) {
|
|
shun-iwasawa |
975eb1 |
if (!m_isPaletteOrder || m_aboveStyleIds.contains(outPix->getInk())) {
|
|
shun-iwasawa |
975eb1 |
*outPix = TPixelCM32(outPix->getInk(), outPix->getPaint(), outTone);
|
|
shun-iwasawa |
975eb1 |
continue;
|
|
shun-iwasawa |
975eb1 |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (inTone <= outTone) {
|
|
Shinya Kitaoka |
120a6e |
*outPix = TPixelCM32(inPix->getInk(), outPix->getPaint(), inTone);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (m_task == ERASE) {
|
|
Shinya Kitaoka |
120a6e |
if (m_colorType == INK) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_keepAntiAlias) {
|
|
Shinya Kitaoka |
120a6e |
if (inPix->getTone() == 0 &&
|
|
Shinya Kitaoka |
120a6e |
(!m_selective ||
|
|
Shinya Kitaoka |
120a6e |
(m_selective && outPix->getInk() == m_selectedStyle))) {
|
|
Shinya Kitaoka |
120a6e |
outPix->setTone(255);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else if (inPix->getTone() < 255 &&
|
|
Shinya Kitaoka |
120a6e |
(!m_selective ||
|
|
Shinya Kitaoka |
120a6e |
(m_selective && outPix->getInk() == m_selectedStyle))) {
|
|
Shinya Kitaoka |
120a6e |
outPix->setTone(
|
|
Shinya Kitaoka |
120a6e |
std::max(outPix->getTone(), 255 - inPix->getTone()));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (m_colorType == PAINT) {
|
|
Shinya Kitaoka |
120a6e |
if (inPix->getTone() == 0 &&
|
|
Shinya Kitaoka |
120a6e |
(!m_selective ||
|
|
Shinya Kitaoka |
120a6e |
(m_selective && outPix->getPaint() == m_selectedStyle)))
|
|
Shinya Kitaoka |
120a6e |
outPix->setPaint(0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (m_colorType == INKNPAINT) {
|
|
Shinya Kitaoka |
120a6e |
if (inPix->getTone() < 255 &&
|
|
Shinya Kitaoka |
120a6e |
(!m_selective ||
|
|
Shinya Kitaoka |
120a6e |
(m_selective && outPix->getPaint() == m_selectedStyle)))
|
|
Shinya Kitaoka |
120a6e |
outPix->setPaint(0);
|
|
Shinya Kitaoka |
120a6e |
if (!m_keepAntiAlias) {
|
|
Shinya Kitaoka |
120a6e |
if (inPix->getTone() == 0 &&
|
|
Shinya Kitaoka |
120a6e |
(!m_selective ||
|
|
Shinya Kitaoka |
120a6e |
(m_selective && outPix->getInk() == m_selectedStyle))) {
|
|
Shinya Kitaoka |
120a6e |
outPix->setTone(255);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else if (inPix->getTone() < 255 &&
|
|
Shinya Kitaoka |
120a6e |
(!m_selective ||
|
|
Shinya Kitaoka |
120a6e |
(m_selective && outPix->getInk() == m_selectedStyle))) {
|
|
Shinya Kitaoka |
120a6e |
outPix->setTone(
|
|
Shinya Kitaoka |
120a6e |
std::max(outPix->getTone(), 255 - inPix->getTone()));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else if (m_task == PAINTBRUSH) {
|
|
Shinya Kitaoka |
120a6e |
if (!inPix->isPureInk()) continue;
|
|
Shinya Kitaoka |
120a6e |
bool changePaint =
|
|
Shinya Kitaoka |
120a6e |
!m_selective || (m_selective && outPix->getPaint() == 0);
|
|
Shinya Kitaoka |
120a6e |
if (m_colorType == INK)
|
|
Shinya Kitaoka |
120a6e |
*outPix = TPixelCM32(inPix->getInk(), outPix->getPaint(),
|
|
Shinya Kitaoka |
120a6e |
outPix->getTone());
|
|
Shinya Kitaoka |
120a6e |
if (m_colorType == PAINT)
|
|
Shinya Kitaoka |
120a6e |
if (changePaint)
|
|
Shinya Kitaoka |
120a6e |
*outPix = TPixelCM32(outPix->getInk(), inPix->getInk(),
|
|
Shinya Kitaoka |
120a6e |
outPix->getTone());
|
|
Shinya Kitaoka |
120a6e |
if (m_colorType == INKNPAINT)
|
|
Shinya Kitaoka |
120a6e |
*outPix =
|
|
Shinya Kitaoka |
120a6e |
TPixelCM32(inPix->getInk(),
|
|
Shinya Kitaoka |
120a6e |
changePaint ? inPix->getInk() : outPix->getPaint(),
|
|
Shinya Kitaoka |
120a6e |
outPix->getTone());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*-- Finger tool --*/
|
|
Shinya Kitaoka |
120a6e |
else if (m_task == FINGER) {
|
|
Shinya Kitaoka |
120a6e |
/*-- 境界条件 --*/
|
|
Shinya Kitaoka |
120a6e |
if (outPix == rOut->pixels(y) || outPix == outEnd - 1) continue;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int inkId = inPix->getInk();
|
|
Shinya Kitaoka |
120a6e |
if (inkId == 0) continue;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixelCM32 *neighbourPixels[4];
|
|
Shinya Kitaoka |
120a6e |
neighbourPixels[0] = outPix - 1; /* 左 */
|
|
Shinya Kitaoka |
120a6e |
neighbourPixels[1] = outPix + 1; /* 右 */
|
|
Shinya Kitaoka |
120a6e |
neighbourPixels[2] = outPix - rOut->getWrap(); /* 上 */
|
|
Shinya Kitaoka |
120a6e |
neighbourPixels[3] = outPix + rOut->getWrap(); /* 下 */
|
|
Shinya Kitaoka |
120a6e |
int count = 0;
|
|
Shinya Kitaoka |
120a6e |
int tone = outPix->getTone();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*--- Invertがオフのとき:穴を埋める操作 ---*/
|
|
Shinya Kitaoka |
120a6e |
if (!m_selective) {
|
|
Shinya Kitaoka |
120a6e |
/*-- 4近傍のピクセルについて --*/
|
|
Shinya Kitaoka |
120a6e |
int minTone = tone;
|
|
Shinya Kitaoka |
120a6e |
for (int p = 0; p < 4; p++) {
|
|
Shinya Kitaoka |
120a6e |
/*-- 自分Pixelより線が濃い(Toneが低い)ものを集計する --*/
|
|
Shinya Kitaoka |
120a6e |
if (neighbourPixels[p]->getTone() < tone) {
|
|
Shinya Kitaoka |
120a6e |
count++;
|
|
Shinya Kitaoka |
120a6e |
if (neighbourPixels[p]->getTone() < minTone)
|
|
Shinya Kitaoka |
120a6e |
minTone = neighbourPixels[p]->getTone();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*--- 周りの3つ以上のピクセルが濃ければ、最小Toneと置き換える ---*/
|
|
Shinya Kitaoka |
120a6e |
if (count <= 2) continue;
|
|
Shinya Kitaoka |
120a6e |
*outPix = TPixelCM32(inkId, outPix->getPaint(), minTone);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/*--- InvertがONのとき:出っ張りを削る操作 ---*/
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
if (outPix->isPurePaint() || outPix->getInk() != inkId) continue;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*-- 4近傍のピクセルについて --*/
|
|
Shinya Kitaoka |
120a6e |
int maxTone = tone;
|
|
Shinya Kitaoka |
120a6e |
for (int p = 0; p < 4; p++) {
|
|
Shinya Kitaoka |
120a6e |
/*--
|
|
Shinya Kitaoka |
120a6e |
* Ink#がCurrentでない、または、自分Pixelより線が薄い(Toneが高い)ものを集計する
|
|
Shinya Kitaoka |
120a6e |
* --*/
|
|
Shinya Kitaoka |
120a6e |
if (neighbourPixels[p]->getInk() != inkId) {
|
|
Shinya Kitaoka |
120a6e |
count++;
|
|
Shinya Kitaoka |
120a6e |
maxTone = 255;
|
|
Shinya Kitaoka |
120a6e |
} else if (neighbourPixels[p]->getTone() > tone) {
|
|
Shinya Kitaoka |
120a6e |
count++;
|
|
Shinya Kitaoka |
120a6e |
if (neighbourPixels[p]->getTone() > maxTone)
|
|
Shinya Kitaoka |
120a6e |
maxTone = neighbourPixels[p]->getTone();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*--- 周りの3つ以上のピクセルが薄ければ、最大Toneと置き換える ---*/
|
|
Shinya Kitaoka |
120a6e |
if (count <= 2) continue;
|
|
Shinya Kitaoka |
120a6e |
*outPix = TPixelCM32((maxTone == 255) ? 0 : inkId, outPix->getPaint(),
|
|
Shinya Kitaoka |
120a6e |
maxTone);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRect RasterStrokeGenerator::getLastRect() const {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tthickpoint> points;</tthickpoint>
|
|
Shinya Kitaoka |
120a6e |
int size = m_points.size();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (size == 3) {
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[0]);
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[1]);
|
|
Shinya Kitaoka |
120a6e |
} else if (size == 1)
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[0]);
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[size - 4]);
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[size - 3]);
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[size - 2]);
|
|
Shinya Kitaoka |
120a6e |
points.push_back(m_points[size - 1]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return getBBox(points);
|
|
Toshihiro Shimizu |
890ddd |
}
|