本文整理汇总了C++中KisPaintDeviceSP::createHLineConstIteratorNG方法的典型用法代码示例。如果您正苦于以下问题:C++ KisPaintDeviceSP::createHLineConstIteratorNG方法的具体用法?C++ KisPaintDeviceSP::createHLineConstIteratorNG怎么用?C++ KisPaintDeviceSP::createHLineConstIteratorNG使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisPaintDeviceSP
的用法示例。
在下文中一共展示了KisPaintDeviceSP::createHLineConstIteratorNG方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processImpl
void KisSimpleNoiseReducer::processImpl(KisPaintDeviceSP device,
const QRect& applyRect,
const KisFilterConfiguration* config,
KoUpdater* progressUpdater
) const
{
QPoint srcTopLeft = applyRect.topLeft();
Q_ASSERT(device);
int threshold, windowsize;
if (config == 0) {
config = defaultConfiguration(device);
}
if (progressUpdater) {
progressUpdater->setRange(0, applyRect.width() * applyRect.height());
}
int count = 0;
threshold = config->getInt("threshold", 15);
windowsize = config->getInt("windowsize", 1);
const KoColorSpace* cs = device->colorSpace();
// Compute the blur mask
KisCircleMaskGenerator* kas = new KisCircleMaskGenerator(2*windowsize + 1, 1, windowsize, windowsize, 2);
KisConvolutionKernelSP kernel = KisConvolutionKernel::fromMaskGenerator(kas);
delete kas;
KisPaintDeviceSP interm = new KisPaintDevice(*device); // TODO no need for a full copy and then a transaction
KisConvolutionPainter painter(interm);
painter.beginTransaction("bouuh");
painter.applyMatrix(kernel, interm, srcTopLeft, srcTopLeft, applyRect.size(), BORDER_REPEAT);
painter.deleteTransaction();
if (progressUpdater && progressUpdater->interrupted()) {
return;
}
KisHLineIteratorSP dstIt = device->createHLineIteratorNG(srcTopLeft.x(), srcTopLeft.y(), applyRect.width());
KisHLineConstIteratorSP intermIt = interm->createHLineConstIteratorNG(srcTopLeft.x(), srcTopLeft.y(), applyRect.width());
for (int j = 0; j < applyRect.height() && !(progressUpdater && progressUpdater->interrupted()); j++) {
do {
quint8 diff = cs->difference(dstIt->oldRawData(), intermIt->oldRawData());
if (diff > threshold) {
memcpy(dstIt->rawData(), intermIt->oldRawData(), cs->pixelSize());
}
if (progressUpdater) progressUpdater->setValue(++count);
intermIt->nextPixel();
} while (dstIt->nextPixel() && !(progressUpdater && progressUpdater->interrupted()));
dstIt->nextRow();
intermIt->nextRow();
}
}
示例2: OilPaint
void KisOilPaintFilter::OilPaint(const KisPaintDeviceSP src, KisPaintDeviceSP dst, const QPoint& srcTopLeft, const QPoint& dstTopLeft, int w, int h,
int BrushSize, int Smoothness, KoUpdater* progressUpdater) const
{
if (progressUpdater) {
progressUpdater->setRange(0, w * h);
}
QRect bounds(srcTopLeft.x(), srcTopLeft.y(), w, h);
KisHLineConstIteratorSP it = src->createHLineConstIteratorNG(srcTopLeft.x(), srcTopLeft.y(), w);
KisHLineIteratorSP dstIt = dst->createHLineIteratorNG(dstTopLeft.x(), dstTopLeft.y(), w);
int progress = 0;
for (qint32 yOffset = 0; yOffset < h; yOffset++) {
do { //&& !cancelRequested()) {
MostFrequentColor(src, dstIt->rawData(), bounds, it->x(), it->y(), BrushSize, Smoothness);
} while (it->nextPixel() && dstIt->nextPixel());
it->nextRow();
dstIt->nextRow();
if (progressUpdater) progressUpdater->setValue(progress += w);
}
}
示例3: process
void KisUnsharpFilter::process(KisPaintDeviceSP device,
const QRect& applyRect,
const KisFilterConfiguration* config,
KoUpdater* progressUpdater
) const
{
QPointer<KoUpdater> filterUpdater = 0;
QPointer<KoUpdater> convolutionUpdater = 0;
KoProgressUpdater* updater = 0;
if (progressUpdater) {
updater = new KoProgressUpdater(progressUpdater);
updater->start();
// Two sub-sub tasks that each go from 0 to 100.
convolutionUpdater = updater->startSubtask();
filterUpdater = updater->startSubtask();
}
if (!config) config = new KisFilterConfiguration(id().id(), 1);
QVariant value;
uint halfSize = (config->getProperty("halfSize", value)) ? value.toUInt() : 5;
uint brushsize = 2 * halfSize + 1;
double amount = (config->getProperty("amount", value)) ? value.toDouble() : 0.5;
uint threshold = (config->getProperty("threshold", value)) ? value.toUInt() : 10;
KisCircleMaskGenerator* kas = new KisCircleMaskGenerator(brushsize, 1, halfSize, halfSize, 2);
KisConvolutionKernelSP kernel = KisConvolutionKernel::fromMaskGenerator(kas);
KisPaintDeviceSP interm = new KisPaintDevice(*device);
const KoColorSpace * cs = interm->colorSpace();
KoConvolutionOp * convolutionOp = cs->convolutionOp();
KisConvolutionPainter painter(interm); // TODO no need for a full copy and then a transaction
if (progressUpdater) {
painter.setProgress(convolutionUpdater);
}
QBitArray channelFlags = config->channelFlags();
if (channelFlags.isEmpty()) {
channelFlags = cs->channelFlags();
}
painter.setChannelFlags(channelFlags);
painter.beginTransaction("convolution step");
painter.applyMatrix(kernel, interm, applyRect.topLeft(), applyRect.topLeft(), applyRect.size(), BORDER_REPEAT);
painter.deleteTransaction();
if (progressUpdater && progressUpdater->interrupted()) {
return;
}
KisHLineIteratorSP dstIt = device->createHLineIteratorNG(applyRect.x(), applyRect.y(), applyRect.width());
KisHLineConstIteratorSP intermIt = interm->createHLineConstIteratorNG(applyRect.x(), applyRect.y(), applyRect.width());
int cdepth = cs -> pixelSize();
quint8 *colors[2];
colors[0] = new quint8[cdepth];
colors[1] = new quint8[cdepth];
int pixelsProcessed = 0;
qreal weights[2];
qreal factor = 128;
// XXX: Added static cast to avoid warning
weights[0] = static_cast<qreal>(factor * (1. + amount));
weights[1] = static_cast<qreal>(-factor * amount);
int steps = 100 / applyRect.width() * applyRect.height();
for (int j = 0; j < applyRect.height(); j++) {
do {
quint8 diff = cs->difference(dstIt->oldRawData(), intermIt->oldRawData());
if (diff > threshold) {
memcpy(colors[0], dstIt->oldRawData(), cdepth);
memcpy(colors[1], intermIt->oldRawData(), cdepth);
convolutionOp->convolveColors(colors, weights, dstIt->rawData(), factor, 0, 2.0, channelFlags);
} else {
memcpy(dstIt->rawData(), dstIt->oldRawData(), cdepth);
}
++pixelsProcessed;
if (progressUpdater) filterUpdater->setProgress(steps * pixelsProcessed);
intermIt->nextPixel();
} while (dstIt->nextPixel());
if (progressUpdater && progressUpdater->interrupted()) {
return;
}
dstIt->nextRow();
intermIt->nextRow();
}
delete colors[0];
delete colors[1];
delete updater;
if (progressUpdater) progressUpdater->setProgress(100);
}
示例4: saveLayerProjection
bool KisTIFFWriterVisitor::saveLayerProjection(KisLayer *layer)
{
dbgFile << "visiting on layer" << layer->name() << "";
KisPaintDeviceSP pd = layer->projection();
// Save depth
int depth = 8 * pd->pixelSize() / pd->channelCount();
TIFFSetField(image(), TIFFTAG_BITSPERSAMPLE, depth);
// Save number of samples
if (m_options->alpha) {
TIFFSetField(image(), TIFFTAG_SAMPLESPERPIXEL, pd->channelCount());
uint16 sampleinfo[1] = { EXTRASAMPLE_UNASSALPHA };
TIFFSetField(image(), TIFFTAG_EXTRASAMPLES, 1, sampleinfo);
} else {
TIFFSetField(image(), TIFFTAG_SAMPLESPERPIXEL, pd->channelCount() - 1);
TIFFSetField(image(), TIFFTAG_EXTRASAMPLES, 0);
}
// Save colorspace information
uint16 color_type;
uint16 sample_format = SAMPLEFORMAT_UINT;
if (!writeColorSpaceInformation(image(), pd->colorSpace(), color_type, sample_format)) { // unsupported colorspace
return false;
}
TIFFSetField(image(), TIFFTAG_PHOTOMETRIC, color_type);
TIFFSetField(image(), TIFFTAG_SAMPLEFORMAT, sample_format);
TIFFSetField(image(), TIFFTAG_IMAGEWIDTH, layer->image()->width());
TIFFSetField(image(), TIFFTAG_IMAGELENGTH, layer->image()->height());
// Set the compression options
TIFFSetField(image(), TIFFTAG_COMPRESSION, m_options->compressionType);
TIFFSetField(image(), TIFFTAG_FAXMODE, m_options->faxMode);
TIFFSetField(image(), TIFFTAG_JPEGQUALITY, m_options->jpegQuality);
TIFFSetField(image(), TIFFTAG_ZIPQUALITY, m_options->deflateCompress);
TIFFSetField(image(), TIFFTAG_PIXARLOGQUALITY, m_options->pixarLogCompress);
// Set the predictor
TIFFSetField(image(), TIFFTAG_PREDICTOR, m_options->predictor);
// Use contiguous configuration
TIFFSetField(image(), TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
// Use 8 rows per strip
TIFFSetField(image(), TIFFTAG_ROWSPERSTRIP, 8);
// Save profile
if (m_options->saveProfile) {
const KoColorProfile* profile = pd->colorSpace()->profile();
if (profile && profile->type() == "icc" && !profile->rawData().isEmpty()) {
QByteArray ba = profile->rawData();
TIFFSetField(image(), TIFFTAG_ICCPROFILE, ba.size(), ba.constData());
}
}
tsize_t stripsize = TIFFStripSize(image());
tdata_t buff = _TIFFmalloc(stripsize);
qint32 height = layer->image()->height();
qint32 width = layer->image()->width();
bool r = true;
for (int y = 0; y < height; y++) {
KisHLineConstIteratorSP it = pd->createHLineConstIteratorNG(0, y, width);
switch (color_type) {
case PHOTOMETRIC_MINISBLACK: {
quint8 poses[] = { 0, 1 };
r = copyDataToStrips(it, buff, depth, sample_format, 1, poses);
}
break;
case PHOTOMETRIC_RGB: {
quint8 poses[4];
if (sample_format == SAMPLEFORMAT_IEEEFP) {
poses[2] = 2;
poses[1] = 1;
poses[0] = 0;
poses[3] = 3;
} else {
poses[0] = 2;
poses[1] = 1;
poses[2] = 0;
poses[3] = 3;
}
r = copyDataToStrips(it, buff, depth, sample_format, 3, poses);
}
break;
case PHOTOMETRIC_SEPARATED: {
quint8 poses[] = { 0, 1, 2, 3, 4 };
r = copyDataToStrips(it, buff, depth, sample_format, 4, poses);
}
break;
case PHOTOMETRIC_ICCLAB: {
quint8 poses[] = { 0, 1, 2, 3 };
r = copyDataToStrips(it, buff, depth, sample_format, 3, poses);
}
break;
return false;
}
if (!r) return false;
TIFFWriteScanline(image(), buff, y, (tsample_t) - 1);
}
_TIFFfree(buff);
TIFFWriteDirectory(image());
return true;
}
示例5: paintAt
//.........这里部分代码省略.........
#endif
// Compute the translation in the perspective transformation space:
QPointF positionStartPaintingT = KisPerspectiveMath::matProd(endM, QPointF(m_duplicateStart));
QPointF duplicateStartPositionT = KisPerspectiveMath::matProd(endM, QPointF(m_duplicateStart) - QPointF(settings->offset()));
QPointF translat = duplicateStartPositionT - positionStartPaintingT;
KisRectIteratorSP dstIt = m_srcdev->createRectIteratorNG(0, 0, sw, sh);
KisRandomSubAccessorSP srcAcc = realSourceDevice->createRandomSubAccessor();
//Action
do {
QPointF p = KisPerspectiveMath::matProd(startM, KisPerspectiveMath::matProd(endM, QPointF(dstIt->x() + x, dstIt->y() + y)) + translat);
srcAcc->moveTo(p);
srcAcc->sampledOldRawData(dstIt->rawData());
} while (dstIt->nextPixel());
} else {
KisPainter copyPainter(m_srcdev);
copyPainter.setCompositeOp(COMPOSITE_COPY);
copyPainter.bitBltOldData(0, 0, realSourceDevice, srcPoint.x(), srcPoint.y(), sw, sh);
copyPainter.end();
}
// heal ?
if (m_healing) {
quint16 srcData[4];
quint16 tmpData[4];
qreal* matrix = new qreal[ 3 * sw * sh ];
// First divide
const KoColorSpace* srcCs = realSourceDevice->colorSpace();
const KoColorSpace* tmpCs = m_srcdev->colorSpace();
KisHLineConstIteratorSP srcIt = realSourceDevice->createHLineConstIteratorNG(x, y, sw);
KisHLineIteratorSP tmpIt = m_srcdev->createHLineIteratorNG(0, 0, sw);
qreal* matrixIt = &matrix[0];
for (int j = 0; j < sh; j++) {
for (int i = 0; i < sw; i++) {
srcCs->toLabA16(srcIt->oldRawData(), (quint8*)srcData, 1);
tmpCs->toLabA16(tmpIt->rawData(), (quint8*)tmpData, 1);
// Division
for (int k = 0; k < 3; k++) {
matrixIt[k] = srcData[k] / (qreal)qMax((int)tmpData [k], 1);
}
srcIt->nextPixel();
tmpIt->nextPixel();
matrixIt += 3;
}
srcIt->nextRow();
tmpIt->nextRow();
}
// Minimize energy
{
int iter = 0;
qreal err;
qreal* solution = new qreal [ 3 * sw * sh ];
do {
err = minimizeEnergy(&matrix[0], &solution[0], sw, sh);
// swap pointers
qreal *tmp = matrix;
matrix = solution;
solution = tmp;
iter++;
} while (err > 0.00001 && iter < 100);
示例6: processImpl
void KisFilterFastColorTransfer::processImpl(KisPaintDeviceSP device,
const QRect& applyRect,
const KisFilterConfiguration* config,
KoUpdater* progressUpdater) const
{
Q_ASSERT(device != 0);
dbgPlugins << "Start transferring color";
// Convert ref and src to LAB
const KoColorSpace* labCS = KoColorSpaceRegistry::instance()->lab16();
if (!labCS) {
dbgPlugins << "The LAB colorspace is not available.";
return;
}
dbgPlugins << "convert a copy of src to lab";
const KoColorSpace* oldCS = device->colorSpace();
KisPaintDeviceSP srcLAB = new KisPaintDevice(*device.data());
dbgPlugins << "srcLab : " << srcLAB->extent();
KUndo2Command* cmd = srcLAB->convertTo(labCS, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags());
delete cmd;
if (progressUpdater) {
progressUpdater->setRange(0, 2 * applyRect.width() * applyRect.height());
}
int count = 0;
// Compute the means and sigmas of src
dbgPlugins << "Compute the means and sigmas of src";
double meanL_src = 0., meanA_src = 0., meanB_src = 0.;
double sigmaL_src = 0., sigmaA_src = 0., sigmaB_src = 0.;
KisSequentialConstIterator srcIt(srcLAB, applyRect);
do {
const quint16* data = reinterpret_cast<const quint16*>(srcIt.oldRawData());
quint32 L = data[0];
quint32 A = data[1];
quint32 B = data[2];
meanL_src += L;
meanA_src += A;
meanB_src += B;
sigmaL_src += L * L;
sigmaA_src += A * A;
sigmaB_src += B * B;
if (progressUpdater) progressUpdater->setValue(++count);
} while (srcIt.nextPixel() && !(progressUpdater && progressUpdater->interrupted()));
double totalSize = 1. / (applyRect.width() * applyRect.height());
meanL_src *= totalSize;
meanA_src *= totalSize;
meanB_src *= totalSize;
sigmaL_src *= totalSize;
sigmaA_src *= totalSize;
sigmaB_src *= totalSize;
dbgPlugins << totalSize << "" << meanL_src << "" << meanA_src << "" << meanB_src << "" << sigmaL_src << "" << sigmaA_src << "" << sigmaB_src;
double meanL_ref = config->getDouble("meanL");
double meanA_ref = config->getDouble("meanA");
double meanB_ref = config->getDouble("meanB");
double sigmaL_ref = config->getDouble("sigmaL");
double sigmaA_ref = config->getDouble("sigmaA");
double sigmaB_ref = config->getDouble("sigmaB");
// Transfer colors
dbgPlugins << "Transfer colors";
{
double coefL = sqrt((sigmaL_ref - meanL_ref * meanL_ref) / (sigmaL_src - meanL_src * meanL_src));
double coefA = sqrt((sigmaA_ref - meanA_ref * meanA_ref) / (sigmaA_src - meanA_src * meanA_src));
double coefB = sqrt((sigmaB_ref - meanB_ref * meanB_ref) / (sigmaB_src - meanB_src * meanB_src));
KisHLineConstIteratorSP srcLABIt = srcLAB->createHLineConstIteratorNG(applyRect.x(), applyRect.y(), applyRect.width());
KisHLineIteratorSP dstIt = device->createHLineIteratorNG(applyRect.x(), applyRect.y(), applyRect.width());
quint16 labPixel[4];
for (int y = 0; y < applyRect.height() && !(progressUpdater && progressUpdater->interrupted()); ++y) {
do {
const quint16* data = reinterpret_cast<const quint16*>(srcLABIt->oldRawData());
labPixel[0] = (quint16)CLAMP(((double)data[0] - meanL_src) * coefL + meanL_ref, 0., 65535.);
labPixel[1] = (quint16)CLAMP(((double)data[1] - meanA_src) * coefA + meanA_ref, 0., 65535.);
labPixel[2] = (quint16)CLAMP(((double)data[2] - meanB_src) * coefB + meanB_ref, 0., 65535.);
labPixel[3] = data[3];
oldCS->fromLabA16(reinterpret_cast<const quint8*>(labPixel), dstIt->rawData(), 1);
if (progressUpdater) progressUpdater->setValue(++count);
srcLABIt->nextPixel();
} while(dstIt->nextPixel());
dstIt->nextRow();
srcLABIt->nextRow();
}
}
}