本文整理汇总了C++中TgaImporter::openData方法的典型用法代码示例。如果您正苦于以下问题:C++ TgaImporter::openData方法的具体用法?C++ TgaImporter::openData怎么用?C++ TgaImporter::openData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TgaImporter
的用法示例。
在下文中一共展示了TgaImporter::openData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void TgaImporterTest::colorBits32() {
TgaImporter importer;
const unsigned char data[] = {
0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 32, 0,
1, 2, 3, 1, 2, 3, 4, 1,
3, 4, 5, 1, 4, 5, 6, 1,
5, 6, 7, 1, 6, 7, 8, 1
};
#ifndef MAGNUM_TARGET_GLES
const char* pixels = reinterpret_cast<const char*>(data) + 18;
#else
const char pixels[] = {
3, 2, 1, 1, 4, 3, 2, 1,
5, 4, 3, 1, 6, 5, 4, 1,
7, 6, 5, 1, 8, 7, 6, 1
};
#endif
CORRADE_VERIFY(importer.openData(data));
std::optional<Trade::ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(image->format(), ImageFormat::BGRA);
#else
CORRADE_COMPARE(image->format(), ImageFormat::RGBA);
#endif
CORRADE_COMPARE(image->size(), Vector2i(2, 3));
CORRADE_COMPARE(image->type(), ImageType::UnsignedByte);
CORRADE_COMPARE(std::string(reinterpret_cast<const char*>(image->data()), 2*3*3), std::string(pixels, 2*3*3));
}
示例2: paletted
void TgaImporterTest::paletted() {
TgaImporter importer;
const char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
CORRADE_VERIFY(importer.openData(data));
std::ostringstream debug;
Error::setOutput(&debug);
CORRADE_VERIFY(!importer.image2D(0));
CORRADE_COMPARE(debug.str(), "Trade::TgaImporter::image2D(): paletted files are not supported\n");
}
示例3: openShort
void TgaImporterTest::openShort() {
TgaImporter importer;
const char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
CORRADE_VERIFY(importer.openData(data));
std::ostringstream debug;
Error::setOutput(&debug);
CORRADE_VERIFY(!importer.image2D(0));
CORRADE_COMPARE(debug.str(), "Trade::TgaImporter::image2D(): the file is too short: 17 bytes\n");
}
示例4:
void TgaImporterTest::grayscaleBits16() {
TgaImporter importer;
const char data[] = { 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0 };
CORRADE_VERIFY(importer.openData(data));
std::ostringstream debug;
Error::setOutput(&debug);
CORRADE_VERIFY(!importer.image2D(0));
CORRADE_COMPARE(debug.str(), "Trade::TgaImporter::image2D(): unsupported grayscale bits-per-pixel: 16\n");
}
示例5: compressed
void TgaImporterTest::compressed() {
TgaImporter importer;
const char data[] = { 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
CORRADE_VERIFY(importer.openData(data));
std::ostringstream debug;
Error::setOutput(&debug);
CORRADE_VERIFY(!importer.image2D(0));
CORRADE_COMPARE(debug.str(), "Trade::TgaImporter::image2D(): unsupported (compressed?) image type: 9\n");
}
示例6: rgba
void TgaImageConverterTest::rgba() {
const auto data = TgaImageConverter().exportToData(OriginalRGBA);
TgaImporter importer;
CORRADE_VERIFY(importer.openData(data));
std::optional<Trade::ImageData2D> converted = importer.image2D(0);
CORRADE_VERIFY(converted);
CORRADE_COMPARE(converted->storage().alignment(), 4);
CORRADE_COMPARE(converted->size(), Vector2i(2, 3));
CORRADE_COMPARE(converted->format(), PixelFormat::RGBA);
CORRADE_COMPARE(converted->type(), PixelType::UnsignedByte);
CORRADE_COMPARE_AS(converted->data(), Containers::ArrayView<const char> {OriginalDataRGBA},
TestSuite::Compare::Container);
}
示例7: data
void TgaImageConverterTest::data() {
const auto data = TgaImageConverter().exportToData(original);
TgaImporter importer;
CORRADE_VERIFY(importer.openData(data));
std::optional<Trade::ImageData2D> converted = importer.image2D(0);
CORRADE_VERIFY(converted);
CORRADE_COMPARE(converted->size(), Vector2i(2, 3));
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(converted->format(), ColorFormat::BGR);
#else
CORRADE_COMPARE(converted->format(), ColorFormat::RGB);
#endif
CORRADE_COMPARE(converted->type(), ColorType::UnsignedByte);
CORRADE_COMPARE((std::string{converted->data(), 2*3*3}),
(std::string{original.data(), 2*3*3}));
}