本文整理汇总了C++中cairo::RefPtr::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::clear方法的具体用法?C++ RefPtr::clear怎么用?C++ RefPtr::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cairo::RefPtr
的用法示例。
在下文中一共展示了RefPtr::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: postprocess
/** Post-process files. Only valid for PNGs. */
void postprocess()
{
printf("Post-processing PNG files, resizing to %fx%f\n", maxwidth, maxheight);
struct dirent *d;
DIR *output_dir = opendir(outdir.c_str());
while ((d = readdir(output_dir)) != NULL) {
if (fnmatch("*.png", d->d_name, FNM_PATHNAME | FNM_PERIOD) == 0) {
infile = outdir + "/" + d->d_name;
Cairo::RefPtr<Cairo::ImageSurface> imgs = Cairo::ImageSurface::create_from_png(infile);
if ( (imgs->get_height() != maxheight) || (imgs->get_width() != maxwidth)) {
// need to re-create
char *tmpout = strdup((outdir + "/tmpXXXXXX").c_str());
FILE *f = fdopen(mkstemp(tmpout), "w");
outfile = tmpout;
free(tmpout);
Cairo::RefPtr<Cairo::ImageSurface> outs = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32,
(int)ceilf(maxwidth),
(int)ceilf(maxheight));
double tx = (maxwidth - imgs->get_width()) / 2.0;
double ty = (maxheight - imgs->get_height()) / 2.0;
printf("Re-creating %s for post-processing, "
"resizing from %ix%i, tx=%f, ty=%f\n", infile.c_str(),
imgs->get_width(), imgs->get_height(), tx, ty);
Cairo::RefPtr<Cairo::Context> cc = Cairo::Context::create(outs);
if (white_bg) {
cc->set_source_rgb(1, 1, 1);
cc->paint();
}
cc->set_source(imgs, tx, ty);
cc->paint();
outs->write_to_png(&SkillGuiBatchRenderer::write_func, f);
imgs.clear();
cc.clear();
outs.clear();
fclose(f);
rename(outfile.c_str(), infile.c_str());
}
}
}
closedir(output_dir);
}