本文整理汇总了C++中KisFixedPaintDeviceSP类的典型用法代码示例。如果您正苦于以下问题:C++ KisFixedPaintDeviceSP类的具体用法?C++ KisFixedPaintDeviceSP怎么用?C++ KisFixedPaintDeviceSP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KisFixedPaintDeviceSP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fromDabWithDensity
void HairyBrush::fromDabWithDensity(KisFixedPaintDeviceSP dab, qreal density)
{
int width = dab->bounds().width();
int height = dab->bounds().height();
int centerX = width * 0.5;
int centerY = height * 0.5;
// make mask
Bristle * bristle = 0;
qreal alpha;
quint8 * dabPointer = dab->data();
quint8 pixelSize = dab->pixelSize();
const KoColorSpace * cs = dab->colorSpace();
KoColor bristleColor(cs);
srand48(12345678);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
alpha = cs->opacityF(dabPointer);
if (alpha != 0.0){
if (density == 1.0 || drand48() <= density){
memcpy(bristleColor.data(), dabPointer, pixelSize);
bristle = new Bristle(x - centerX, y - centerY, alpha); // using value from image as length of bristle
bristle->setColor(bristleColor);
m_bristles.append(bristle);
}
}
dabPointer += pixelSize;
}
}
}
示例2: image
void KisFixedPaintDeviceTest::testBltPerformance()
{
QImage image(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa_transparent.png");
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisFixedPaintDeviceSP fdev = new KisFixedPaintDevice(cs);
fdev->convertFromQImage(image, 0);
KisPaintDeviceSP dev = new KisPaintDevice(cs);
dev->fill(0, 0, 640, 441, KoColor(Qt::white, cs).data());
QTime t;
t.start();
int x;
for (x = 0; x < 1000; ++x) {
KisPainter gc(dev);
gc.bltFixed(QPoint(0, 0), fdev, image.rect());
}
qDebug() << x
<< "blits"
<< " done in "
<< t.elapsed()
<< "ms";
}
示例3: applyThreshold
void KisPressureSharpnessOption::applyThreshold(KisFixedPaintDeviceSP dab)
{
if (!isChecked()) return;
const KoColorSpace * cs = dab->colorSpace();
// Set all alpha > opaque/2 to opaque, the rest to transparent.
// XXX: Using 4/10 as the 1x1 circle brush paints nothing with 0.5.
quint8* dabPointer = dab->data();
QRect rc = dab->bounds();
int pixelSize = dab->pixelSize();
int pixelCount = rc.width() * rc.height();
for (int i = 0; i < pixelCount; i++) {
quint8 alpha = cs->opacityU8(dabPointer);
if (alpha < (m_threshold * OPACITY_OPAQUE_U8) / 100) {
cs->setOpacity(dabPointer, OPACITY_TRANSPARENT_U8, 1);
}
else {
cs->setOpacity(dabPointer, OPACITY_OPAQUE_U8, 1);
}
dabPointer += pixelSize;
}
}
示例4: setPixel
inline void setPixel(KisFixedPaintDeviceSP dev, int x, int y, quint8 alpha)
{
KoColor c(Qt::black, dev->colorSpace());
c.setOpacity(alpha);
dev->fill(x, y, 1, 1, c.data());
}
示例5: KisFixedPaintDevice
void KisFixedPaintDeviceTest::testSilly()
{
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisFixedPaintDeviceSP dev = new KisFixedPaintDevice(cs);
dev->initialize();
dev->initialize();
}
示例6: pixel
inline quint8 pixel(KisFixedPaintDeviceSP dev, int x, int y)
{
KoColor c(Qt::black, dev->colorSpace());
dev->readBytes(c.data(), x, y, 1, 1);
return c.opacityU8();
}
示例7: memcpy
void KisFixedPaintDeviceTest::testFill()
{
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
quint8* red = new quint8[cs->pixelSize()];
memcpy(red, KoColor(Qt::red, cs).data(), cs->pixelSize());
cs->setOpacity(red, quint8(128), 1);
KisFixedPaintDeviceSP dev = new KisFixedPaintDevice(cs);
dev->fill(0, 0, 100, 100, red);
QVERIFY(dev->bounds() == QRect(0, 0, 100, 100));
QVERIFY(cs->opacityU8(dev->data()) == 128);
QVERIFY(memcmp(dev->data(), red, cs->pixelSize()) == 0);
//Compare fill will normal paint device
dev = new KisFixedPaintDevice(cs);
dev->setRect(QRect(0, 0, 150, 150));
dev->initialize();
dev->fill(50, 50, 50, 50, red);
KisPaintDeviceSP dev2 = new KisPaintDevice(cs);
dev2->fill(50, 50, 50, 50, red);
QImage image = dev->convertToQImage(0);
QImage checkImage = dev2->convertToQImage(0, 0, 0, 150, 150);
QPoint errpoint;
if (!TestUtil::compareQImages(errpoint, image, checkImage)) {
image.save("kis_fixed_paint_device_filled_result.png");
checkImage.save("kis_fixed_paint_device_filled_result_expected.png");
QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
}
delete[] red;
}
示例8: rc
//#define SAVE_OUTPUT_IMAGES
void KisAutoBrushTest::testCopyMasking()
{
int w = 64;
int h = 64;
int x = 0;
int y = 0;
QRect rc(x, y, w, h);
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KoColor black(Qt::black, cs);
KoColor red(Qt::red, cs);
KisPaintDeviceSP tempDev = new KisPaintDevice(cs);
tempDev->fill(0, 0, w, h, red.data());
#ifdef SAVE_OUTPUT_IMAGES
tempDev->convertToQImage(0).save("tempDev.png");
#endif
KisCircleMaskGenerator * mask = new KisCircleMaskGenerator(w, 1.0, 0.5, 0.5, 2, true);
KisAutoBrush brush(mask, 0, 0);
KisFixedPaintDeviceSP maskDab = new KisFixedPaintDevice(cs);
brush.mask(maskDab, black, KisDabShape(), KisPaintInformation());
maskDab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
#ifdef SAVE_OUTPUT_IMAGES
maskDab->convertToQImage(0, 0, 0, 64, 64).save("maskDab.png");
#endif
QCOMPARE(tempDev->exactBounds(), rc);
QCOMPARE(maskDab->bounds(), rc);
KisFixedPaintDeviceSP dev2fixed = new KisFixedPaintDevice(cs);
dev2fixed->setRect(rc);
dev2fixed->initialize();
tempDev->readBytes(dev2fixed->data(), rc);
dev2fixed->convertToQImage(0).save("converted-tempDev-to-fixed.png");
KisPaintDeviceSP dev = new KisPaintDevice(cs);
KisPainter painter(dev);
painter.setCompositeOp(COMPOSITE_COPY);
painter.bltFixedWithFixedSelection(x, y, dev2fixed, maskDab, 0, 0, 0, 0, rc.width(), rc.height());
//painter.bitBltWithFixedSelection(x, y, tempDev, maskDab, 0, 0, 0, 0, rc.width(), rc.height());
#ifdef SAVE_OUTPUT_IMAGES
dev->convertToQImage(0).save("final.png");
#endif
}
示例9: srand
QImage KisAutoBrush::createBrushPreview()
{
srand(0);
srand48(0);
int width = maskWidth(1.0, 0.0, 0.0, 0.0, KisPaintInformation());
int height = maskHeight(1.0, 0.0, 0.0, 0.0, KisPaintInformation());
KisPaintInformation info(QPointF(width * 0.5, height * 0.5), 0.5, 0, 0, 0, 0);
KisFixedPaintDeviceSP fdev = new KisFixedPaintDevice( KoColorSpaceRegistry::instance()->rgb8() );
fdev->setRect(QRect(0, 0, width, height));
fdev->initialize();
mask(fdev,KoColor(Qt::black, fdev->colorSpace()),1.0, 1.0, 0.0, info);
return fdev->convertToQImage(0);
}
示例10: Q_ASSERT
KisFixedPaintDeviceSP KisBrush::paintDevice(const KoColorSpace * colorSpace,
KisDabShape const& shape,
const KisPaintInformation& info,
double subPixelX, double subPixelY) const
{
Q_ASSERT(valid());
Q_UNUSED(info);
double angle = normalizeAngle(shape.rotation() + d->angle);
double scale = shape.scale() * d->scale;
prepareBrushPyramid();
QImage outputImage = d->brushPyramid->createImage(
KisDabShape(scale, shape.ratio(), -angle), subPixelX, subPixelY);
KisFixedPaintDeviceSP dab = new KisFixedPaintDevice(colorSpace);
Q_CHECK_PTR(dab);
dab->convertFromQImage(outputImage, "");
return dab;
}
示例11: benchmarkSIMD
void benchmarkSIMD(qreal fade) {
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisFixedPaintDeviceSP dev = new KisFixedPaintDevice(cs);
dev->setRect(QRect(0, 0, 1000, 1000));
dev->initialize();
MaskProcessingData data(dev, cs,
0.0, 1.0,
500, 500, 0);
KisCircleMaskGenerator gen(1000, 1.0, fade, fade, 2, false);
KisBrushMaskApplicatorBase *applicator = gen.applicator();
applicator->initializeData(&data);
QVector<QRect> rects = KritaUtils::splitRectIntoPatches(dev->bounds(), QSize(63, 63));
QBENCHMARK{
Q_FOREACH (const QRect &rc, rects) {
applicator->process(rc);
}
}
示例12: KisCircleMaskGenerator
void KisAutoBrushTest::testMaskGeneration()
{
KisCircleMaskGenerator* circle = new KisCircleMaskGenerator(10, 1.0, 1.0, 1.0, 2, false);
KisBrushSP a = new KisAutoBrush(circle, 0.0, 0.0);
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintInformation info(QPointF(100.0, 100.0), 0.5);
// check masking an existing paint device
KisFixedPaintDeviceSP fdev = new KisFixedPaintDevice(cs);
fdev->setRect(QRect(0, 0, 100, 100));
fdev->initialize();
cs->setOpacity(fdev->data(), OPACITY_OPAQUE_U8, 100 * 100);
QPoint errpoint;
QImage result(QString(FILES_DATA_DIR) + QDir::separator() + "result_autobrush_1.png");
QImage image = fdev->convertToQImage(0);
if (!TestUtil::compareQImages(errpoint, image, result)) {
image.save("kis_autobrush_test_1.png");
QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
}
// Check creating a mask dab with a single color
fdev = new KisFixedPaintDevice(cs);
a->mask(fdev, KoColor(Qt::black, cs), KisDabShape(), info);
result = QImage(QString(FILES_DATA_DIR) + QDir::separator() + "result_autobrush_3.png");
image = fdev->convertToQImage(0);
if (!TestUtil::compareQImages(errpoint, image, result)) {
image.save("kis_autobrush_test_3.png");
QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
}
// Check creating a mask dab with a color taken from a paint device
KoColor red(Qt::red, cs);
cs->setOpacity(red.data(), quint8(128), 1);
KisPaintDeviceSP dev = new KisPaintDevice(cs);
dev->fill(0, 0, 100, 100, red.data());
fdev = new KisFixedPaintDevice(cs);
a->mask(fdev, dev, KisDabShape(), info);
result = QImage(QString(FILES_DATA_DIR) + QDir::separator() + "result_autobrush_4.png");
image = fdev->convertToQImage(0);
if (!TestUtil::compareQImages(errpoint, image, result)) {
image.save("kis_autobrush_test_4.png");
QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
}
}
示例13: postProcessDab
void KisDabCache::postProcessDab(KisFixedPaintDeviceSP dab,
const KisPaintInformation& info)
{
if (m_d->mirrorOption) {
MirrorProperties mirror = m_d->mirrorOption->apply(info);
dab->mirror(mirror.horizontalMirror, mirror.verticalMirror);
}
if (m_d->sharpnessOption) {
m_d->sharpnessOption->applyThreshold(dab);
}
if (m_d->textureOption) {
m_d->textureOption->apply(dab, info.pos().toPoint(), info);
}
}
示例14: KisSpacingInformation
KisSpacingInformation KisFilterOp::paintAt(const KisPaintInformation& info)
{
if (!painter()) {
return KisSpacingInformation(1.0);
}
if (!m_filter) {
return KisSpacingInformation(1.0);
}
if (!source()) {
return KisSpacingInformation(1.0);
}
KisBrushSP brush = m_brush;
if (!brush) return KisSpacingInformation(1.0);
if (! brush->canPaintFor(info))
return KisSpacingInformation(1.0);
qreal scale = m_sizeOption.apply(info);
if (checkSizeTooSmall(scale)) return KisSpacingInformation();
setCurrentScale(scale);
qreal rotation = m_rotationOption.apply(info);
static const KoColorSpace *cs = KoColorSpaceRegistry::instance()->alpha8();
static KoColor color(Qt::black, cs);
QRect dstRect;
KisFixedPaintDeviceSP dab =
m_dabCache->fetchDab(cs, color, info.pos(),
scale, scale, rotation,
info, 1.0,
&dstRect);
if (dstRect.isEmpty()) return KisSpacingInformation(1.0);
QRect dabRect = dab->bounds();
// sanity check
Q_ASSERT(dstRect.size() == dabRect.size());
// Filter the paint device
QRect neededRect = m_filter->neededRect(dstRect, m_filterConfiguration);
KisPainter p(m_tmpDevice);
if (!m_smudgeMode) {
p.setCompositeOp(COMPOSITE_COPY);
}
p.bitBltOldData(neededRect.topLeft() - dstRect.topLeft(), source(), neededRect);
KisTransaction transaction(m_tmpDevice);
m_filter->process(m_tmpDevice, dabRect, m_filterConfiguration, 0);
transaction.end();
painter()->
bitBltWithFixedSelection(dstRect.x(), dstRect.y(),
m_tmpDevice, dab,
0, 0,
dabRect.x(), dabRect.y(),
dabRect.width(), dabRect.height());
painter()->renderMirrorMaskSafe(dstRect, m_tmpDevice, 0, 0, dab,
!m_dabCache->needSeparateOriginal());
return effectiveSpacing(scale, rotation);
}
示例15: generateMaskAndApplyMaskOrCreateDab
void KisAutoBrush::generateMaskAndApplyMaskOrCreateDab(KisFixedPaintDeviceSP dst,
KisBrush::ColoringInformation* coloringInformation,
double scaleX, double scaleY, double angle,
const KisPaintInformation& info,
double subPixelX , double subPixelY, qreal softnessFactor) const
{
Q_UNUSED(info);
// Generate the paint device from the mask
const KoColorSpace* cs = dst->colorSpace();
quint32 pixelSize = cs->pixelSize();
// mask dimension methods already includes KisBrush::angle()
int dstWidth = maskWidth(scaleX, angle, subPixelX, subPixelY, info);
int dstHeight = maskHeight(scaleY, angle, subPixelX, subPixelY, info);
QPointF hotSpot = this->hotSpot(scaleX, scaleY, angle, info);
// mask size and hotSpot function take the KisBrush rotation into account
angle += KisBrush::angle();
// if there's coloring information, we merely change the alpha: in that case,
// the dab should be big enough!
if (coloringInformation) {
// old bounds
QRect oldBounds = dst->bounds();
// new bounds. we don't care if there is some extra memory occcupied.
dst->setRect(QRect(0, 0, dstWidth, dstHeight));
if (dstWidth * dstHeight <= oldBounds.width() * oldBounds.height()) {
// just clear the data in dst,
memset(dst->data(), OPACITY_TRANSPARENT_U8, dstWidth * dstHeight * dst->pixelSize());
} else {
// enlarge the data
dst->initialize();
}
} else {
if (dst->data() == 0 || dst->bounds().isEmpty()) {
qWarning() << "Creating a default black dab: no coloring info and no initialized paint device to mask";
dst->clear(QRect(0, 0, dstWidth, dstHeight));
}
Q_ASSERT(dst->bounds().width() >= dstWidth && dst->bounds().height() >= dstHeight);
}
quint8* dabPointer = dst->data();
quint8* color = 0;
if (coloringInformation) {
if (dynamic_cast<PlainColoringInformation*>(coloringInformation)) {
color = const_cast<quint8*>(coloringInformation->color());
}
}
double invScaleX = 1.0 / scaleX;
double invScaleY = 1.0 / scaleY;
double centerX = hotSpot.x() - 0.5 + subPixelX;
double centerY = hotSpot.y() - 0.5 + subPixelY;
d->shape->setSoftness( softnessFactor );
if (coloringInformation) {
if (color && pixelSize == 4) {
fillPixelOptimized_4bytes(color, dabPointer, dstWidth * dstHeight);
} else if (color) {
fillPixelOptimized_general(color, dabPointer, dstWidth * dstHeight, pixelSize);
} else {
for (int y = 0; y < dstHeight; y++) {
for (int x = 0; x < dstWidth; x++) {
memcpy(dabPointer, coloringInformation->color(), pixelSize);
coloringInformation->nextColumn();
dabPointer += pixelSize;
}
coloringInformation->nextRow();
}
}
}
MaskProcessingData data(dst, cs, d->randomness, d->density,
centerX, centerY,
invScaleX, invScaleY,
angle);
KisBrushMaskApplicatorBase *applicator = d->shape->applicator();
applicator->initializeData(&data);
int jobs = d->idealThreadCountCached;
if(dstHeight > 100 && jobs >= 4) {
int splitter = dstHeight/jobs;
QVector<QRect> rects;
for(int i = 0; i < jobs - 1; i++) {
rects << QRect(0, i*splitter, dstWidth, splitter);
}
rects << QRect(0, (jobs - 1)*splitter, dstWidth, dstHeight - (jobs - 1)*splitter);
OperatorWrapper wrapper(applicator);
QtConcurrent::blockingMap(rects, wrapper);
} else {
QRect rect(0, 0, dstWidth, dstHeight);
applicator->process(rect);
//.........这里部分代码省略.........