本文整理汇总了C++中TRasterCM32P::getLy方法的典型用法代码示例。如果您正苦于以下问题:C++ TRasterCM32P::getLy方法的具体用法?C++ TRasterCM32P::getLy怎么用?C++ TRasterCM32P::getLy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRasterCM32P
的用法示例。
在下文中一共展示了TRasterCM32P::getLy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeRGBMValues
void computeRGBMValues(const TRasterCM32P &ras, TPaletteP pal,
int (*rgbmValues)[256]) {
assert(pal);
int y, lx = ras->getLx(), ly = ras->getLy();
TPixelCM32 *pix, *endPix;
int styleId;
TColorStyle *colorStyle;
TPixel32 color;
for (y = 0; y < ly; ++y)
for (pix = ras->pixels(y), endPix = pix + lx; pix < endPix; ++pix) {
styleId = (pix->getTone() < 127) ? pix->getInk() : pix->getPaint();
colorStyle = pal->getStyle(styleId);
if (!colorStyle) continue;
color = colorStyle->getAverageColor();
if (color.m) {
++rgbmValues[0][color.r];
++rgbmValues[1][color.g];
++rgbmValues[2][color.b];
}
++rgbmValues[3][color.m];
}
}
示例2:
void Convert2Tlv::removeAntialias(TRasterCM32P &r)
{
int threshold = (int)(m_antialiasValue * 255.0 / 100.0);
int tone;
for (int i = 0; i < r->getLy(); i++) {
TPixelCM32 *pix = r->pixels(i);
for (int j = 0; j < r->getLx(); j++, pix++)
if ((tone = pix->getTone()) != 0xff) //tone==ff e tone==0 non vanno toccati mai
pix->setTone(tone > threshold ? 0xff : 0);
}
}
示例3: nearestInk
TPoint nearestInk(const TRasterCM32P &r, const TPoint &p, int ray) {
int i, j;
TPixelCM32 *buf = (TPixelCM32 *)r->getRawData();
for (j = std::max(p.y - ray, 0); j <= std::min(p.y + ray, r->getLy() - 1);
j++)
for (i = std::max(p.x - ray, 0); i <= std::min(p.x + ray, r->getLx() - 1);
i++)
if (!(buf + j * r->getWrap() + i)->isPurePaint()) return TPoint(i, j);
return TPoint(-1, -1);
}
示例4: InkSegmenter
InkSegmenter(const TRasterCM32P &r, float growFactor, TTileSaverCM32 *saver)
: m_r(r)
, m_lx(r->getLx())
, m_ly(r->getLy())
, m_wrap(r->getWrap())
, m_buf((TPixelCM32 *)r->getRawData())
, m_bBox(r->getBounds())
, m_saver(saver)
, m_growFactor(growFactor) {
m_displaceVector[0] = -m_wrap - 1;
m_displaceVector[1] = -m_wrap;
m_displaceVector[2] = -m_wrap + 1;
m_displaceVector[3] = -1;
m_displaceVector[4] = +1;
m_displaceVector[5] = m_wrap - 1;
m_displaceVector[6] = m_wrap;
m_displaceVector[7] = m_wrap + 1;
}
示例5: updateSelection
void SelectionRaster::updateSelection(TRasterCM32P cm,
const BlendParam ¶m) {
// Make a hard copy of color indexes. We do so since we absolutely prefer
// having them SORTED!
std::vector<int> cIndexes = param.colorsIndexes;
std::sort(cIndexes.begin(), cIndexes.end());
unsigned int lx = cm->getLx(), ly = cm->getLy(), wrap = cm->getWrap();
// Scan each cm pixel, looking if its ink or paint is in param's colorIndexes.
cm->lock();
TPixelCM32 *pix, *pixBegin = (TPixelCM32 *)cm->getRawData();
SelectionData *selData = data();
const int *v =
&cIndexes[0]; // NOTE: cIndexes.size() > 0 due to external check.
unsigned int vSize = cIndexes.size();
unsigned int i, j;
// NOTE: It seems that linear searches are definitely best for small color
// indexes.
if (vSize > 50) {
for (i = 0; i < ly; ++i) {
pix = pixBegin + i * wrap;
for (j = 0; j < lx; ++j, ++pix, ++selData) {
selData->m_selectedInk = binarySearch(v, vSize, pix->getInk());
selData->m_selectedPaint = binarySearch(v, vSize, pix->getPaint());
}
}
} else {
for (i = 0; i < ly; ++i) {
pix = pixBegin + i * wrap;
for (j = 0; j < lx; ++j, ++pix, ++selData) {
selData->m_selectedInk = linearSearch(v, vSize, pix->getInk());
selData->m_selectedPaint = linearSearch(v, vSize, pix->getPaint());
}
}
}
cm->unlock();
}
示例6: fillautoInks
//-----------------------------------------------------------------------------
// questa funzione viene chiamata dopo il fill rect delle aree, e colora gli
// inchiostri di tipo "autoink"
// che confinano con le aree appena fillate con il rect. rbefore e' il rect del
// raster prima del rectfill.
void fillautoInks(TRasterCM32P &rin, TRect &rect, const TRasterCM32P &rbefore,
TPalette *plt) {
assert(plt);
TRasterCM32P r = rin->extract(rect);
assert(r->getSize() == rbefore->getSize());
int i, j;
for (i = 0; i < r->getLy(); i++) {
TPixelCM32 *pix = r->pixels(i);
TPixelCM32 *pixb = rbefore->pixels(i);
for (j = 0; j < r->getLx(); j++, pix++, pixb++) {
int paint = pix->getPaint();
int tone = pix->getTone();
int ink = pix->getInk();
if (paint != pixb->getPaint() && tone > 0 && tone < 255 && ink != paint &&
plt->getStyle(ink)->getFlags() != 0)
inkFill(rin, TPoint(j, i) + rect.getP00(), paint, 0, NULL, &rect);
}
}
}
示例7: buildLayers
// Copies the cmIn paint and ink colors to the output rasters.
void buildLayers(const TRasterCM32P &cmIn,
const std::vector<TPixel32> &palColors, TRaster32P &inkRaster,
TRaster32P &paintRaster) {
// Separate cmIn by copying the ink & paint colors directly to the layer
// rasters.
TPixelCM32 *cmPix, *cmBegin = (TPixelCM32 *)cmIn->getRawData();
TPixel32 *inkPix = (TPixel32 *)inkRaster->getRawData();
TPixel32 *paintPix = (TPixel32 *)paintRaster->getRawData();
unsigned int i, j, lx = cmIn->getLx(), ly = cmIn->getLy(),
wrap = cmIn->getWrap();
for (i = 0; i < ly; ++i) {
cmPix = cmBegin + i * wrap;
for (j = 0; j < lx; ++j, ++cmPix, ++inkPix, ++paintPix) {
*inkPix = palColors[cmPix->getInk()];
*paintPix = palColors[cmPix->getPaint()];
// Should pure colors be checked...?
}
}
}
示例8: isFlatNeighbourhood
// Returns true or false whether the selectedColor is the only selectable color
// in the neighbourhood. If so, the blend copies it to the output layer pixel
// directly.
inline bool isFlatNeighbourhood(int selectedColor, const TRasterCM32P &cmIn,
const TPoint &pos,
const SelectionRaster &selRas,
const BlurPattern &blurPattern) {
TPixelCM32 &pix = cmIn->pixels(pos.y)[pos.x];
int lx = cmIn->getLx(), ly = cmIn->getLy();
unsigned int xy;
TPoint samplePix;
const TPoint *samplePoint =
blurPattern.m_samples.empty() ? 0 : &blurPattern.m_samples[0];
// Read the samples to determine if they only have posSelectedColor
unsigned int i, samplesCount = blurPattern.m_samples.size();
for (i = 0; i < samplesCount; ++i, ++samplePoint) {
// Make sure the sample is inside the image
samplePix.x = pos.x + samplePoint->x;
samplePix.y = pos.y + samplePoint->y;
xy = samplePix.x + lx * samplePix.y;
if (samplePix.x < 0 || samplePix.y < 0 || samplePix.x >= lx ||
samplePix.y >= ly)
continue;
if (!selRas.isPurePaint(xy) && selRas.isSelectedInk(xy))
if (cmIn->pixels(samplePix.y)[samplePix.x].getInk() != selectedColor)
return false;
if (!selRas.isPureInk(xy) && selRas.isSelectedPaint(xy))
if (cmIn->pixels(samplePix.y)[samplePix.x].getPaint() != selectedColor)
return false;
}
return true;
}
示例9: data
SelectionRaster::SelectionRaster(TRasterCM32P cm) {
unsigned int lx = cm->getLx(), ly = cm->getLy(), wrap = cm->getWrap();
unsigned int size = lx * ly;
m_wrap = lx;
m_selection.allocate(size);
cm->lock();
TPixelCM32 *pix, *pixBegin = (TPixelCM32 *)cm->getRawData();
SelectionData *selData = data();
unsigned int i, j;
for (i = 0; i < ly; ++i) {
pix = pixBegin + i * wrap;
for (j = 0; j < lx; ++j, ++pix, ++selData) {
selData->m_pureInk = pix->getTone() == 0;
selData->m_purePaint = pix->getTone() == 255;
}
}
cm->unlock();
}
示例10: doBlend
// Performs a single color blending. This function can be repeatedly invoked to
// perform multiple color blending.
inline void doBlend(const TRasterCM32P &cmIn, RGBMRasterPair &inkLayer,
RGBMRasterPair &paintLayer, const SelectionRaster &selRas,
const std::vector<BlurPattern> &blurPatterns) {
// Declare some vars
unsigned int blurPatternsCount = blurPatterns.size();
int lx = cmIn->getLx(), ly = cmIn->getLy();
double totalFactor;
TPixelCM32 *cmPix, *cmBegin = (TPixelCM32 *)cmIn->getRawData();
TPixel32 *inkIn = (TPixel32 *)inkLayer.first->getRawData(),
*inkOut = (TPixel32 *)inkLayer.second->getRawData(),
*paintIn = (TPixel32 *)paintLayer.first->getRawData(),
*paintOut = (TPixel32 *)paintLayer.second->getRawData();
const BlurPattern *blurPattern, *blurPatternsBegin = &blurPatterns[0];
bool builtSamples = false;
DoubleRGBMPixel samplesSum;
// For every cmIn pixel
TPoint pos;
SelectionData *selData = selRas.data();
cmPix = cmBegin;
for (pos.y = 0; pos.y < ly;
++pos.y, cmPix = cmBegin + pos.y * cmIn->getWrap())
for (pos.x = 0; pos.x < lx; ++pos.x, ++inkIn, ++inkOut, ++paintIn,
++paintOut, ++selData, ++cmPix) {
blurPattern = blurPatternsBegin + (rand() % blurPatternsCount);
// Build the ink blend color
if (!selData->m_purePaint && selData->m_selectedInk) {
if (!builtSamples) {
// Build samples contributes
totalFactor = 1.0;
samplesSum.r = samplesSum.g = samplesSum.b = samplesSum.m = 0.0;
if (!isFlatNeighbourhood(cmPix->getInk(), cmIn, pos, selRas,
*blurPattern))
addSamples(cmIn, pos, inkLayer.first, paintLayer.first, selRas,
*blurPattern, samplesSum, totalFactor);
builtSamples = true;
}
// Output the blended pixel
inkOut->r = (samplesSum.r + inkIn->r) / totalFactor;
inkOut->g = (samplesSum.g + inkIn->g) / totalFactor;
inkOut->b = (samplesSum.b + inkIn->b) / totalFactor;
inkOut->m = (samplesSum.m + inkIn->m) / totalFactor;
} else {
// If the color is not blended, then just copy the old layer pixel
*inkOut = *inkIn;
}
// Build the paint blend color
if (!selData->m_pureInk && selData->m_selectedPaint) {
if (!builtSamples) {
// Build samples contributes
totalFactor = 1.0;
samplesSum.r = samplesSum.g = samplesSum.b = samplesSum.m = 0.0;
if (!isFlatNeighbourhood(cmPix->getPaint(), cmIn, pos, selRas,
*blurPattern))
addSamples(cmIn, pos, inkLayer.first, paintLayer.first, selRas,
*blurPattern, samplesSum, totalFactor);
builtSamples = true;
}
// Output the blended pixel
paintOut->r = (samplesSum.r + paintIn->r) / totalFactor;
paintOut->g = (samplesSum.g + paintIn->g) / totalFactor;
paintOut->b = (samplesSum.b + paintIn->b) / totalFactor;
paintOut->m = (samplesSum.m + paintIn->m) / totalFactor;
} else {
// If the color is not blended, then just copy the old layer pixel
*paintOut = *paintIn;
}
builtSamples = false;
}
}
示例11: addSamples
// Calculates the estimate of blend selection in the neighbourhood specified by
// blurPattern.
inline void addSamples(const TRasterCM32P &cmIn, const TPoint &pos,
const TRaster32P &inkRas, const TRaster32P &paintRas,
const SelectionRaster &selRas,
const BlurPattern &blurPattern, DoubleRGBMPixel &pixSum,
double &factorsSum) {
double inkFactor, paintFactor;
unsigned int xy, j, l;
int lx = cmIn->getLx(), ly = cmIn->getLy();
TPixel32 *color;
TPoint samplePos, pathPos;
const TPoint *samplePoint =
blurPattern.m_samples.empty() ? 0 : &blurPattern.m_samples[0];
const TPoint *pathPoint;
unsigned int i, blurSamplesCount = blurPattern.m_samples.size();
for (i = 0; i < blurSamplesCount; ++i, ++samplePoint) {
// Add each samples contribute to the sum
samplePos.x = pos.x + samplePoint->x;
samplePos.y = pos.y + samplePoint->y;
if (samplePos.x < 0 || samplePos.y < 0 || samplePos.x >= lx ||
samplePos.y >= ly)
continue;
// Ensure that each pixel on the sample's path (if any) is selected
l = blurPattern.m_samplePaths[i].size();
pathPoint = blurPattern.m_samplePaths[i].empty()
? 0
: &blurPattern.m_samplePaths[i][0];
for (j = 0; j < l; ++j, ++pathPoint) {
pathPos.x = pos.x + pathPoint->x;
pathPos.y = pos.y + pathPoint->y;
xy = pathPos.x + lx * pathPos.y;
if (!(selRas.isPurePaint(xy) || selRas.isSelectedInk(xy))) break;
if (!(selRas.isPureInk(xy) || selRas.isSelectedPaint(xy))) break;
}
if (j < l) continue;
xy = samplePos.x + lx * samplePos.y;
if (selRas.isSelectedInk(xy) && !selRas.isPurePaint(xy)) {
getFactors(cmIn->pixels(samplePos.y)[samplePos.x].getTone(), inkFactor,
paintFactor);
color = &inkRas->pixels(samplePos.y)[samplePos.x];
pixSum.r += inkFactor * color->r;
pixSum.g += inkFactor * color->g;
pixSum.b += inkFactor * color->b;
pixSum.m += inkFactor * color->m;
factorsSum += inkFactor;
}
if (selRas.isSelectedPaint(xy) && !selRas.isPureInk(xy)) {
getFactors(cmIn->pixels(samplePos.y)[samplePos.x].getTone(), inkFactor,
paintFactor);
color = &paintRas->pixels(samplePos.y)[samplePos.x];
pixSum.r += paintFactor * color->r;
pixSum.g += paintFactor * color->g;
pixSum.b += paintFactor * color->b;
pixSum.m += paintFactor * color->m;
factorsSum += paintFactor;
}
}
}
示例12: makeDataRaster
void OutlineVectorizer::makeDataRaster(const TRasterP &src)
{
m_vimage = new TVectorImage();
if (!src)
return;
m_src = src;
clearNodes();
clearJunctions();
int x, y, ii = 0;
TRaster32P srcRGBM = (TRaster32P)m_src;
TRasterCM32P srcCM = (TRasterCM32P)m_src;
TRasterGR8P srcGR = (TRasterGR8P)m_src;
// Inizializzo DataRasterP per i casi in cui si ha un TRaster32P, un TRasterGR8P o un TRasterCM32P molto grande
DataRasterP dataRaster(m_src->getSize().lx + 2, m_src->getSize().ly + 2);
if (srcRGBM || srcGR || (srcCM && srcCM->getLx() * srcCM->getLy() > 5000000)) {
int ly = dataRaster->getLy();
int lx = dataRaster->getLx();
int wrap = dataRaster->getWrap();
DataPixel *dataPix0 = dataRaster->pixels(0);
DataPixel *dataPix1 = dataRaster->pixels(0) + m_src->getLx() + 1;
for (y = 0; y < ly; y++, dataPix0 += wrap, dataPix1 += wrap) {
dataPix0->m_pos.x = 0;
dataPix1->m_pos.x = lx - 1;
dataPix0->m_pos.y = dataPix1->m_pos.y = y;
dataPix0->m_value = dataPix1->m_value = 0;
dataPix0->m_ink = dataPix1->m_ink = false;
dataPix0->m_node = dataPix1->m_node = 0;
}
dataPix0 = dataRaster->pixels(0);
dataPix1 = dataRaster->pixels(ly - 1);
for (x = 0; x < lx; x++, dataPix0++, dataPix1++) {
dataPix0->m_pos.x = dataPix1->m_pos.x = x;
dataPix0->m_pos.y = 0;
dataPix1->m_pos.y = ly - 1;
dataPix0->m_value = dataPix1->m_value = 0;
dataPix0->m_ink = dataPix1->m_ink = false;
dataPix0->m_node = dataPix1->m_node = 0;
}
}
if (srcRGBM) {
assert(m_palette);
int inkId = m_palette->getClosestStyle(m_configuration.m_inkColor);
if (!inkId || m_configuration.m_inkColor != m_palette->getStyle(inkId)->getMainColor()) {
inkId = m_palette->getStyleCount();
m_palette->getStylePage(1)->insertStyle(1, m_configuration.m_inkColor);
m_palette->setStyle(inkId, m_configuration.m_inkColor);
}
assert(inkId);
m_dataRasterArray.push_back(std::pair<int, DataRasterP>(inkId, dataRaster));
int maxDistance2 = m_configuration.m_threshold * m_configuration.m_threshold;
for (y = 0; y < m_src->getLy(); y++) {
TPixel32 *inPix = srcRGBM->pixels(y);
TPixel32 *inEndPix = inPix + srcRGBM->getLx();
DataPixel *dataPix = dataRaster->pixels(y + 1) + 1;
x = 0;
while (inPix < inEndPix) {
*dataPix = DataPixel();
int distance2 = colorDistance2(m_configuration.m_inkColor, *inPix);
if (y == 0 || y == m_src->getLy() - 1 || x == 0 || x == m_src->getLx() - 1 || inPix->m == 0) {
dataPix->m_value = 255;
dataPix->m_ink = false;
} else {
dataPix->m_value = (inPix->r + 2 * inPix->g + inPix->b) >> 2;
dataPix->m_ink = (distance2 < maxDistance2);
}
dataPix->m_pos.x = x++;
dataPix->m_pos.y = y;
dataPix->m_node = 0;
inPix++;
dataPix++;
}
}
} else if (srcGR) {
示例13: if
void Convert2Tlv::buildToonzRaster(TRasterCM32P &rout, const TRasterP &rin1, const TRasterP &rin2)
{
if (rin2)
assert(rin1->getSize() == rin2->getSize());
rout->clear();
std::cout << " computing inks...\n";
TRaster32P r1 = (TRaster32P)rin1;
TRasterGR8P r1gr = (TRasterGR8P)rin1;
TRaster32P r2 = (TRaster32P)rin2;
TRasterGR8P r2gr = (TRasterGR8P)rin2;
TRasterP rU, rP;
if (r1gr) {
rU = r1gr;
rP = r2;
} else if (r2gr) {
rU = r2gr;
rP = r1;
} else if (!r1)
rU = r2;
else if (!r2)
rU = r1;
else if (firstIsUnpainted(r1, r2)) {
rU = r1;
rP = r2;
} else {
rU = r2;
rP = r1;
}
TRasterCM32P r;
if (rout->getSize() != rU->getSize()) {
int dx = rout->getLx() - rU->getLx();
int dy = rout->getLy() - rU->getLy();
assert(dx >= 0 && dy >= 0);
r = rout->extract(dx / 2, dy / 2, dx / 2 + rU->getLx() - 1, dy / 2 + rU->getLy() - 1);
} else
r = rout;
if ((TRasterGR8P)rU)
buildInksFromGrayTones(r, rU);
else if (m_isUnpaintedFromNAA)
buildInksForNAAImage(r, (TRaster32P)rU);
else {
int maxMatte = getMaxMatte((TRaster32P)rU);
if (maxMatte == -1)
buildInksFromGrayTones(r, rU);
else {
if (maxMatte < 255)
normalize(rU, maxMatte);
buildInks(r, (TRaster32P)rU /*rP,*/);
}
}
if (m_autoclose)
TAutocloser(r, AutocloseDistance, AutocloseAngle, 1, AutocloseOpacity).exec();
if (rP) {
std::cout << " computing paints...\n";
doFill(r, rP);
}
if (m_antialiasType == 2) //remove antialias
removeAntialias(r);
else if (m_antialiasType == 1) //add antialias
{
TRasterCM32P raux(r->getSize());
TRop::antialias(r, raux, 10, m_antialiasValue);
rout = raux;
}
}
示例14: findNearestColor
void Convert2Tlv::doFill(TRasterCM32P &rout, const TRaster32P &rin)
{
//prima passata: si filla solo partendo da pixel senza inchiostro, senza antialiasing(tone==255)
for (int i = 0; i < rin->getLy(); i++) {
TPixel *pixin = rin->pixels(i);
TPixelCM32 *pixout = rout->pixels(i);
for (int j = 0; j < rin->getLx(); j++, pixin++, pixout++) {
if (!(pixout->getTone() == 255 && pixout->getPaint() == 0 && pixin->m == 255))
continue;
std::map<TPixel, int>::const_iterator it;
int paintIndex;
if ((it = m_colorMap.find(*pixin)) == m_colorMap.end()) {
if (m_colorTolerance > 0)
it = findNearestColor(*pixin);
// if (it==colorMap.end() && (int)colorMap.size()>origColorCount) //se non l'ho trovato tra i colori origari, lo cerco in quelli nuovi, ma in questo caso deve essere esattamente uguale(tolerance = 0)
// it = findNearestColor(*pixin, colorMap, colorTolerance, origColorCount, colorMap.size()-1);
if (it == m_colorMap.end() && m_lastIndex < 4096) {
m_colorMap[*pixin] = ++m_lastIndex;
paintIndex = m_lastIndex;
} else if (it != m_colorMap.end()) {
m_colorMap[*pixin] = it->second;
paintIndex = it->second;
}
} else
paintIndex = it->second;
FillParameters params;
params.m_p = TPoint(j, i);
params.m_styleId = paintIndex;
params.m_emptyOnly = true;
fill(rout, params);
//if (*((ULONG *)rout->getRawData())!=0xff)
// {
// int cavolo=0;
// }
}
}
//seconda passata: se son rimasti pixel antialiasati non fillati, si fillano, cercando nelle vicinanze un pixel di paint puro per capire il colore da usare
for (int i = 0; i < rin->getLy(); i++) {
TPixel *pixin = rin->pixels(i);
TPixelCM32 *pixout = rout->pixels(i);
for (int j = 0; j < rin->getLx(); j++, pixin++, pixout++) {
if (!(pixout->getTone() > 0 && pixout->getTone() < 255 && pixout->getPaint() == 0 && pixin->m == 255))
continue;
TPoint p = getClosestPurePaint(rout, i, j);
if (p.x == -1)
continue;
//pixout->setPaint( paintIndex);
FillParameters params;
params.m_p = TPoint(j, i);
params.m_styleId = (rout->pixels(p.y) + p.x)->getPaint();
params.m_emptyOnly = true;
fill(rout, params);
}
}
//infine, si filla di trasparente lo sfondo, percorrendo il bordo, nel caso di trasbordamenti di colore
TPixelCM32 *pixCm;
TPixel *pix;
pixCm = rout->pixels(0);
pix = rin->pixels(0);
FillParameters params;
params.m_styleId = 0;
for (int i = 0; i < rout->getLx(); i++, pixCm++, pix++)
if (pixCm->getTone() == 255 && pixCm->getPaint() != 0 && pix->m == 0) {
params.m_p = TPoint(i, 0);
fill(rout, params);
}
pixCm = rout->pixels(rout->getLy() - 1);
pix = rin->pixels(rout->getLy() - 1);
for (int i = 0; i < rout->getLx(); i++, pixCm++, pix++)
if (pixCm->getTone() == 255 && pixCm->getPaint() != 0 && pix->m == 0) {
params.m_p = TPoint(i, rout->getLy() - 1);
fill(rout, params);
}
int wrapCM = rout->getWrap();
int wrap = rin->getWrap();
pixCm = rout->pixels(0);
pix = rin->pixels(0);
for (int i = 0; i < rin->getLy(); i++, pixCm += wrapCM, pix += wrap)
if (pixCm->getTone() == 255 && pixCm->getPaint() != 0 && pix->m == 0) {
params.m_p = TPoint(0, i);
fill(rout, params);
}
pixCm = rout->pixels(0) + rout->getLx() - 1;
pix = rin->pixels(0) + rin->getLx() - 1;
for (int i = 0; i < rin->getLy(); i++, pixCm += wrapCM, pix += wrap)
if (pixCm->getTone() == 255 && pixCm->getPaint() != 0 && pix->m == 0) {
params.m_p = TPoint(rout->getLx() - 1, i);
fill(rout, params);
}
//.........这里部分代码省略.........
示例15: fill
/*-- 戻り値はsaveBoxが更新されたかどうか --*/
bool fill(const TRasterCM32P &r, const FillParameters ¶ms,
TTileSaverCM32 *saver) {
TPixelCM32 *pix, *limit, *pix0, *oldpix;
int oldy, xa, xb, xc, xd, dy;
int oldxc, oldxd;
int tone, oldtone;
TPoint p = params.m_p;
int x = p.x, y = p.y;
int paint = params.m_styleId;
int fillDepth =
params.m_shiftFill ? params.m_maxFillDepth : params.m_minFillDepth;
/*-- getBoundsは画像全面 --*/
TRect bbbox = r->getBounds();
/*- 画面外のクリックの場合はreturn -*/
if (!bbbox.contains(p)) return false;
/*- 既に同じ色が塗られている場合はreturn -*/
if ((r->pixels(p.y) + p.x)->getPaint() == paint) return false;
/*- 「透明部分だけを塗る」オプションが有効で、既に色が付いている場合はreturn
* -*/
if (params.m_emptyOnly && (r->pixels(p.y) + p.x)->getPaint() != 0)
return false;
assert(fillDepth >= 0 && fillDepth < 16);
switch (TPixelCM32::getMaxTone()) {
case 15:
fillDepth = (15 - fillDepth);
break;
case 255:
fillDepth = ((15 - fillDepth) << 4) | (15 - fillDepth);
break;
default:
assert(false);
}
/*-- 四隅の色を見て、一つでも変わったらsaveBoxを更新する --*/
TPixelCM32 borderIndex[4];
TPixelCM32 *borderPix[4];
pix = r->pixels(0);
borderPix[0] = pix;
borderIndex[0] = *pix;
pix += r->getLx() - 1;
borderPix[1] = pix;
borderIndex[1] = *pix;
pix = r->pixels(r->getLy() - 1);
borderPix[2] = pix;
borderIndex[2] = *pix;
pix += r->getLx() - 1;
borderPix[3] = pix;
borderIndex[3] = *pix;
std::stack<FillSeed> seeds;
fillRow(r, p, xa, xb, paint, params.m_palette, saver);
seeds.push(FillSeed(xa, xb, y, 1));
seeds.push(FillSeed(xa, xb, y, -1));
while (!seeds.empty()) {
FillSeed fs = seeds.top();
seeds.pop();
xa = fs.m_xa;
xb = fs.m_xb;
oldy = fs.m_y;
dy = fs.m_dy;
y = oldy + dy;
if (y > bbbox.y1 || y < bbbox.y0) continue;
pix = pix0 = r->pixels(y) + xa;
limit = r->pixels(y) + xb;
oldpix = r->pixels(oldy) + xa;
x = xa;
oldxd = (std::numeric_limits<int>::min)();
oldxc = (std::numeric_limits<int>::max)();
while (pix <= limit) {
oldtone = threshTone(*oldpix, fillDepth);
tone = threshTone(*pix, fillDepth);
if (pix->getPaint() != paint && tone <= oldtone && tone != 0) {
fillRow(r, TPoint(x, y), xc, xd, paint, params.m_palette, saver);
if (xc < xa) seeds.push(FillSeed(xc, xa - 1, y, -dy));
if (xd > xb) seeds.push(FillSeed(xb + 1, xd, y, -dy));
if (oldxd >= xc - 1)
oldxd = xd;
else {
if (oldxd >= 0) seeds.push(FillSeed(oldxc, oldxd, y, dy));
oldxc = xc;
oldxd = xd;
}
pix += xd - x + 1;
oldpix += xd - x + 1;
x += xd - x + 1;
} else {
pix++;
oldpix++, x++;
}
}
if (oldxd > 0) seeds.push(FillSeed(oldxc, oldxd, y, dy));
}
//.........这里部分代码省略.........