本文整理汇总了C++中FileFormat::support方法的典型用法代码示例。如果您正苦于以下问题:C++ FileFormat::support方法的具体用法?C++ FileFormat::support怎么用?C++ FileFormat::support使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileFormat
的用法示例。
在下文中一共展示了FileFormat::support方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_palette
Palette* load_palette(const char *filename)
{
std::string ext = base::string_to_lower(base::get_file_extension(filename));
Palette* pal = NULL;
if (ext == "col") {
pal = doc::file::load_col_file(filename);
}
else if (ext == "gpl") {
pal = doc::file::load_gpl_file(filename);
}
else {
FileFormat* ff = FileFormatsManager::instance()->getFileFormatByExtension(ext.c_str());
if (ff->support(FILE_SUPPORT_LOAD)) {
FileOp* fop = fop_to_load_document(NULL, filename,
FILE_LOAD_SEQUENCE_NONE |
FILE_LOAD_ONE_FRAME);
if (fop && !fop->has_error()) {
fop_operate(fop, NULL);
fop_post_load(fop);
if (fop->document &&
fop->document->sprite() &&
fop->document->sprite()->getPalette(FrameNumber(0))) {
pal = new Palette(
*fop->document->sprite()->getPalette(FrameNumber(0)));
// TODO remove this line when support for palettes with less
// than 256 colors is added.
pal->resize(Palette::MaxColors);
}
delete fop->document;
fop_done(fop);
}
}
}
if (pal)
pal->setFilename(filename);
return pal;
}
示例2: save_palette
bool save_palette(const char *filename, Palette* pal)
{
std::string ext = base::string_to_lower(base::get_file_extension(filename));
bool success = false;
if (ext == "col") {
success = doc::file::save_col_file(pal, filename);
}
else if (ext == "gpl") {
success = doc::file::save_gpl_file(pal, filename);
}
else {
FileFormat* ff = FileFormatsManager::instance()->getFileFormatByExtension(ext.c_str());
if (ff->support(FILE_SUPPORT_SAVE)) {
app::Context tmpContext;
doc::Document* doc = tmpContext.documents().add(
16, 16, doc::ColorMode::INDEXED,
Palette::MaxColors);
Sprite* sprite = doc->sprite();
doc->sprite()->setPalette(pal, false);
LayerImage* layer = dynamic_cast<LayerImage*>(sprite->folder()->getFirstLayer());
Image* image = layer->getCel(FrameNumber(0))->image();
int x, y, c;
for (y=c=0; y<16; y++)
for (x=0; x<16; x++)
image->putPixel(x, y, c++);
doc->setFilename(filename);
success = (save_document(&tmpContext, doc) == 0);
doc->close();
delete doc;
}
}
return success;
}