本文整理汇总了C++中KisPaintDeviceSP::channelCount方法的典型用法代码示例。如果您正苦于以下问题:C++ KisPaintDeviceSP::channelCount方法的具体用法?C++ KisPaintDeviceSP::channelCount怎么用?C++ KisPaintDeviceSP::channelCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisPaintDeviceSP
的用法示例。
在下文中一共展示了KisPaintDeviceSP::channelCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testCreation
void KisPaintDeviceTest::testCreation()
{
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintDeviceSP dev = new KisPaintDevice(cs);
QVERIFY(dev->objectName().isEmpty());
dev = new KisPaintDevice(cs);
QVERIFY(*dev->colorSpace() == *cs);
QVERIFY(dev->x() == 0);
QVERIFY(dev->y() == 0);
QVERIFY(dev->pixelSize() == cs->pixelSize());
QVERIFY(dev->channelCount() == cs->channelCount());
QVERIFY(dev->dataManager() != 0);
KisImageSP image = new KisImage(0, 1000, 1000, cs, "merge test");
KisPaintLayerSP layer = new KisPaintLayer(image, "bla", 125);
dev = new KisPaintDevice(layer.data(), cs);
QVERIFY(*dev->colorSpace() == *cs);
QVERIFY(dev->x() == 0);
QVERIFY(dev->y() == 0);
QVERIFY(dev->pixelSize() == cs->pixelSize());
QVERIFY(dev->channelCount() == cs->channelCount());
QVERIFY(dev->dataManager() != 0);
// Let the layer go out of scope and see what happens
{
KisPaintLayerSP l2 = new KisPaintLayer(image, "blabla", 250);
dev = new KisPaintDevice(l2.data(), cs);
}
}
示例2: testPlanarReadWrite
void KisPaintDeviceTest::testPlanarReadWrite()
{
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintDeviceSP dev = new KisPaintDevice(cs);
quint8* pixel = new quint8[cs->pixelSize()];
cs->fromQColor(QColor(255, 200, 155, 100), pixel);
dev->fill(0, 0, 5000, 5000, pixel);
delete[] pixel;
QColor c1;
dev->pixel(5, 5, &c1);
QVector<quint8*> planes = dev->readPlanarBytes(500, 500, 100, 100);
QVector<quint8*> swappedPlanes;
QCOMPARE((int)planes.size(), (int)dev->channelCount());
for (int i = 0; i < 100*100; i++) {
// BGRA encoded
QVERIFY(planes.at(2)[i] == 255);
QVERIFY(planes.at(1)[i] == 200);
QVERIFY(planes.at(0)[i] == 155);
QVERIFY(planes.at(3)[i] == 100);
}
for (uint i = 1; i < dev->channelCount() + 1; ++i) {
swappedPlanes.append(planes[dev->channelCount() - i]);
}
dev->writePlanarBytes(swappedPlanes, 0, 0, 100, 100);
dev->convertToQImage(0, 0, 0, 1000, 1000).save("planar.png");
dev->pixel(5, 5, &c1);
QVERIFY(c1.red() == 200);
QVERIFY(c1.green() == 255);
QVERIFY(c1.blue() == 100);
QVERIFY(c1.alpha() == 155);
dev->pixel(75, 50, &c1);
QVERIFY(c1.red() == 200);
QVERIFY(c1.green() == 255);
QVERIFY(c1.blue() == 100);
QVERIFY(c1.alpha() == 155);
// check if one of the planes is Null.
Q_ASSERT(planes.size() == 4);
delete planes[2];
planes[2] = 0;
dev->writePlanarBytes(planes, 0, 0, 100, 100);
dev->convertToQImage(0, 0, 0, 1000, 1000).save("planar_noR.png");
dev->pixel(75, 50, &c1);
QCOMPARE(c1.red(), 200);
QCOMPARE(c1.green(), 200);
QCOMPARE(c1.blue(), 155);
QCOMPARE(c1.alpha(), 100);
qDeleteAll(planes);
swappedPlanes.clear();
}
示例3: 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;
}