本文整理汇总了C++中Pixmap::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Pixmap::init方法的具体用法?C++ Pixmap::init怎么用?C++ Pixmap::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pixmap
的用法示例。
在下文中一共展示了Pixmap::init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: snapshot
bool RGLView::snapshot(PixmapFileFormatID formatID, const char* filename)
{
bool success = false;
if ( (formatID < PIXMAP_FILEFORMAT_LAST) && (pixmapFormat[formatID])
&& windowImpl->beginGL() ) {
// alloc pixmap memory
Pixmap snapshot;
snapshot.init(RGB24, width, height, 8);
// read front buffer
glPushAttrib(GL_PIXEL_MODE_BIT);
glReadBuffer(GL_FRONT);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0,0,width,height,GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*) snapshot.data);
glPopAttrib();
success = snapshot.save( pixmapFormat[formatID], filename );
windowImpl->endGL();
}
return success;
}
示例2: xortex
int xortex(Pixmap &map, const unsigned int width, const unsigned int height)
{
if (!width || !height)
return 1;
if(map.init(width, height))
return 2;
for(unsigned int j = 0; j < map.height(); j++) {
for(unsigned int i = 0; i < map.width(); i++) {
scalar_t val = (scalar_t)(i ^ j) / 255.0f;
ColorRGBAf &pixel = map.pixel(i, j);
pixel.r(val);
pixel.g(val);
pixel.b(val);
pixel.a(1.0f);
}
}
return 0;
}
示例3: ppm_raw
int ppm_raw(const char *filename, Pixmap &fb)
{
if (!filename)
return 1;
FILE* fp = fopen(filename, "rb");
if (fp == NULL) {
fb.init(0, 0);
return 5;
}
// Read the header.
int c = 0;
std::string header_token[4];
for (unsigned int tcount = 0; tcount < 4; tcount++) {
for (;;) {
while (isspace(c = getc(fp)));
if (c != '#')
break;
do {
c = getc(fp);
} while (c != '\n' && c != EOF);
if (c == EOF)
break;
}
if (c != EOF) {
do {
header_token[tcount].append(1, c);
c = getc(fp);
} while (!isspace(c) && c != '#' && c != EOF);
if (c == '#')
ungetc(c, fp);
}
}
if (header_token[0].compare("P6")) {
fclose(fp);
return 3;
}
int nx, ny, pm;
if (sscanf(header_token[1].c_str(), "%d", &nx) != 1 ||
sscanf(header_token[2].c_str(), "%d", &ny) != 1 ||
sscanf(header_token[3].c_str(), "%d", &pm) != 1) {
fclose(fp);
return 3;
}
if (pm != 255) {
fclose(fp);
return 3;
}
if (fb.init(nx, ny)) {
fclose(fp);
return 5;
}
// Read the pixel data.
for (unsigned int j = 0; j < fb.height(); j++) {
for (unsigned int i = 0; i < fb.width(); i++) {
unsigned char p[3];
if (fread(p, 1, 3, fp) != 3)
{
fclose(fp);
return 4;
}
ColorRGBAf &pixel = fb.pixel(i, j);
pixel.r((scalar_t)p[0] / 255.0f);
pixel.g((scalar_t)p[1] / 255.0f);
pixel.b((scalar_t)p[2] / 255.0f);
pixel.a(1.0f);
}
}
fclose(fp);
return 0;
}