本文整理汇总了C++中IWriteFile::write方法的典型用法代码示例。如果您正苦于以下问题:C++ IWriteFile::write方法的具体用法?C++ IWriteFile::write怎么用?C++ IWriteFile::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWriteFile
的用法示例。
在下文中一共展示了IWriteFile::write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onWriteFontFile
bool CBinaryFontWriter::onWriteFontFile( const SFontInfo& fontInfo )
{
std::string filename = getFilename() + ".xft";
IWriteFile* writer = device->getFileSystem()->createAndWriteFile(filename.c_str());
writeT(writer, 0xabcdefff);
writeT(writer, (int) FONT_VERSION);
writeT(writer, useAlphaChannel);
writeT(writer, fontInfo.images.size());
std::string imageName;
for (u32 i = 0; i < fontInfo.images.size(); ++i)
{
imageName = getImageName(i);
// write image
writeT(writer, imageName.size());
writer->write(imageName.c_str(), imageName.size());
}
// write charmap
writeT(writer, fontInfo.charMap.size());
for (const std::pair<wchar_t, SFontArea>& chToarea : fontInfo.charMap)
writeT(writer, chToarea);
writer->drop();
return true;
}
示例2: writeImageToFile
//! Tests IVideoDriver::writeImageToFile() using IWriteFile
bool writeImageToFile(void)
{
IrrlichtDevice *device = createDevice( EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32);
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
// Draw a cube background so that we can check that the pixels' alpha is working.
ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60));
cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
cube->setMaterialFlag(video::EMF_LIGHTING, false);
(void)smgr->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
// Test for benign handling of offscreen pixel values as well as onscreen ones.
for(s32 x = -10; x < 170; ++x)
{
s32 y = 120 * x / 160;
driver->drawPixel((u32)x, (u32)y, SColor(255, 255 * x / 640, 255 * (640 - x) / 640, 0));
y = 120 - y;
driver->drawPixel((u32)x, (u32)y, SColor(255 * x / 640, 0, 255, 255));
}
driver->endScene();
bool result = false;
IWriteFile * writtenFile = 0;
IWriteFile * memoryFile = 0;
const char * writtenFilename = 0;
const u32 BUFFER_SIZE = 160 * 120 * 4;
c8 * buffer = 0;
const char * referenceFilename = 0;
video::ECOLOR_FORMAT format;
irr::video::IImage * screenshot = driver->createScreenShot();
if(!screenshot)
{
logTestString("Failed to take screenshot\n");
assert(false);
goto cleanup;
}
format = screenshot->getColorFormat();
if(format != video::ECF_R8G8B8)
{
irr::video::IImage * fixedScreenshot = driver->createImage(video::ECF_R8G8B8, screenshot);
screenshot->drop();
if(!fixedScreenshot)
{
logTestString("Failed to convert screenshot to ECF_A8R8G8B8\n");
assert(false);
goto cleanup;
}
screenshot = fixedScreenshot;
}
buffer = new c8[BUFFER_SIZE];
writtenFilename = "results" DIR_SEP_STRING "Burning's Video-drawPixel.png";
memoryFile = device->getFileSystem()->createMemoryWriteFile(buffer, BUFFER_SIZE, writtenFilename, false);
if(!driver->writeImageToFile(screenshot, memoryFile))
{
logTestString("Failed to write png to memory file\n");
assert(false);
goto cleanup;
}
writtenFile = device->getFileSystem()->createAndWriteFile(memoryFile->getFileName());
if(!writtenFile)
{
logTestString("Can't open %s for writing.\n", writtenFilename);
assert(false);
goto cleanup;
}
if(memoryFile->getPos() != writtenFile->write(buffer, memoryFile->getPos()))
{
logTestString("Error while writing to %s.\n", writtenFilename);
assert(false);
goto cleanup;
}
writtenFile->drop();
writtenFile = 0;
referenceFilename = "media" DIR_SEP_STRING "Burning's Video-drawPixel.png";
if(!binaryCompareFiles(writtenFilename, referenceFilename))
{
logTestString("File written from memory is not the same as the reference file.\n");
assert(false);
goto cleanup;
}
result = true;
//.........这里部分代码省略.........