本文整理汇总了C++中KisPaintDeviceSP::writePlanarBytes方法的典型用法代码示例。如果您正苦于以下问题:C++ KisPaintDeviceSP::writePlanarBytes方法的具体用法?C++ KisPaintDeviceSP::writePlanarBytes怎么用?C++ KisPaintDeviceSP::writePlanarBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisPaintDeviceSP
的用法示例。
在下文中一共展示了KisPaintDeviceSP::writePlanarBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: convertFromGmicImage
KisPaintDeviceSP KisGmicSimpleConvertor::convertFromGmicImage(CImg< float >& gmicImage, bool &preserveAlpha)
{
const KoColorSpace *rgbaFloat32bitcolorSpace = KoColorSpaceRegistry::instance()->colorSpace(RGBAColorModelID.id(),
Float32BitsColorDepthID.id(),
KoColorSpaceRegistry::instance()->rgb8()->profile());
KisPaintDeviceSP dev = new KisPaintDevice(rgbaFloat32bitcolorSpace);
unsigned int channelBytes = gmicImage._width * gmicImage._height * sizeof(float);
if (channelBytes == channelSize() * sizeof(float))
{
// ok, we can reuse read plannar bytes here
dbgPlugins << "[krita] Re-using read plannar bytes";
if ((gmicImage._spectrum == 1) || (gmicImage._spectrum == 3))
{
dbgPlugins << "[krita] Releasing alpha channel";
// we can delete alpha channel
releaseAlphaChannel();
}
}
else
{
// re-accumullate buffers, output image has different dimension..not sure if this ever happens
deletePlanes();
bool alphaChannelEnabled = ((gmicImage._spectrum == 2) || (gmicImage._spectrum == 4));
dbgPlugins << "Accumulating...!";
accumulate(gmicImage._width * gmicImage._height, alphaChannelEnabled);
}
switch (gmicImage._spectrum)
{
case 1:
{
grayscale2rgb(gmicImage, m_planarBytes);
preserveAlpha = true;
break;
}
case 2:
{
grayscaleAlpha2rgba(gmicImage, m_planarBytes);
break;
}
case 3:
{
rgb2rgb(gmicImage, m_planarBytes);
preserveAlpha = true;
break;
}
case 4:
rgba2rgba(gmicImage, m_planarBytes);
break;
default:
{
dbgPlugins << "Unsupported gmic output format : " << gmicImage._width << gmicImage._height << gmicImage._depth << gmicImage._spectrum;
}
}
dev->writePlanarBytes(m_planarBytes, 0, 0, gmicImage._width, gmicImage._height);
// release planes
deletePlanes();
return dev;
}