本文整理汇总了C++中JSONWriter::writeBase64方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONWriter::writeBase64方法的具体用法?C++ JSONWriter::writeBase64怎么用?C++ JSONWriter::writeBase64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONWriter
的用法示例。
在下文中一共展示了JSONWriter::writeBase64方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enumToString
/**
* Dump the image of the currently bound read buffer.
*/
static inline void
dumpReadBufferImage(JSONWriter &json, GLint width, GLint height, GLenum format,
GLint internalFormat = GL_NONE)
{
GLint channels = _gl_format_channels(format);
if (internalFormat == GL_NONE) {
internalFormat = format;
}
Context context;
json.beginObject();
// Tell the GUI this is no ordinary object, but an image
json.writeStringMember("__class__", "image");
json.writeNumberMember("__width__", width);
json.writeNumberMember("__height__", height);
json.writeNumberMember("__depth__", 1);
json.writeStringMember("__format__", enumToString(internalFormat));
// Hardcoded for now, but we could chose types more adequate to the
// texture internal format
json.writeStringMember("__type__", "uint8");
json.writeBoolMember("__normalized__", true);
json.writeNumberMember("__channels__", channels);
GLenum type = GL_UNSIGNED_BYTE;
#if DEPTH_AS_RGBA
if (format == GL_DEPTH_COMPONENT) {
type = GL_UNSIGNED_INT;
channels = 4;
}
#endif
GLubyte *pixels = new GLubyte[width*height*channels];
// TODO: reset imaging state too
context.resetPixelPackState();
glReadPixels(0, 0, width, height, format, type, pixels);
context.restorePixelPackState();
json.beginMember("__data__");
char *pngBuffer;
int pngBufferSize;
image::writePixelsToBuffer(pixels, width, height, channels, true, &pngBuffer, &pngBufferSize);
//std::cerr <<" Before = "<<(width * height * channels * sizeof *pixels)
// <<", after = "<<pngBufferSize << ", ratio = " << double(width * height * channels * sizeof *pixels)/pngBufferSize;
json.writeBase64(pngBuffer, pngBufferSize);
free(pngBuffer);
json.endMember(); // __data__
delete [] pixels;
json.endObject();
}
示例2: resetPixelPackState
/**
* Dump the image of the currently bound read buffer.
*/
static inline void
dumpReadBufferImage(JSONWriter &json, GLint width, GLint height, GLenum format)
{
GLint channels = __gl_format_channels(format);
json.beginObject();
// Tell the GUI this is no ordinary object, but an image
json.writeStringMember("__class__", "image");
json.writeNumberMember("__width__", width);
json.writeNumberMember("__height__", height);
json.writeNumberMember("__depth__", 1);
// Hardcoded for now, but we could chose types more adequate to the
// texture internal format
json.writeStringMember("__type__", "uint8");
json.writeBoolMember("__normalized__", true);
json.writeNumberMember("__channels__", channels);
GLubyte *pixels = new GLubyte[width*height*channels];
resetPixelPackState();
glReadPixels(0, 0, width, height, format, GL_UNSIGNED_BYTE, pixels);
restorePixelPackState();
json.beginMember("__data__");
char *pngBuffer;
int pngBufferSize;
Image::writePixelsToBuffer(pixels, width, height, channels, false, &pngBuffer, &pngBufferSize);
//std::cerr <<" Before = "<<(width * height * channels * sizeof *pixels)
// <<", after = "<<pngBufferSize << ", ratio = " << double(width * height * channels * sizeof *pixels)/pngBufferSize;
json.writeBase64(pngBuffer, pngBufferSize);
free(pngBuffer);
json.endMember(); // __data__
delete [] pixels;
json.endObject();
}
示例3: glGetIntegerv
static inline void
dumpActiveTextureLevel(JSONWriter &json, Context &context, GLenum target, GLint level)
{
ImageDesc desc;
if (!getActiveTextureLevelDesc(context, target, level, desc)) {
return;
}
char label[512];
GLint active_texture = GL_TEXTURE0;
glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
snprintf(label, sizeof label, "%s, %s, level = %d",
enumToString(active_texture), enumToString(target), level);
json.beginMember(label);
json.beginObject();
GLuint channels;
GLenum format;
if (!context.ES && isDepthFormat(desc.internalFormat)) {
format = GL_DEPTH_COMPONENT;
channels = 1;
} else {
format = GL_RGBA;
channels = 4;
}
// Tell the GUI this is no ordinary object, but an image
json.writeStringMember("__class__", "image");
json.writeNumberMember("__width__", desc.width);
json.writeNumberMember("__height__", desc.height);
json.writeNumberMember("__depth__", desc.depth);
json.writeStringMember("__format__", enumToString(desc.internalFormat));
// Hardcoded for now, but we could chose types more adequate to the
// texture internal format
json.writeStringMember("__type__", "uint8");
json.writeBoolMember("__normalized__", true);
json.writeNumberMember("__channels__", channels);
GLubyte *pixels = new GLubyte[desc.depth*desc.width*desc.height*channels];
context.resetPixelPackState();
if (context.ES) {
getTexImageOES(target, level, desc, pixels);
} else {
glGetTexImage(target, level, format, GL_UNSIGNED_BYTE, pixels);
}
context.restorePixelPackState();
json.beginMember("__data__");
char *pngBuffer;
int pngBufferSize;
image::writePixelsToBuffer(pixels, desc.width, desc.height, channels, true, &pngBuffer, &pngBufferSize);
json.writeBase64(pngBuffer, pngBufferSize);
free(pngBuffer);
json.endMember(); // __data__
delete [] pixels;
json.endObject();
}
示例4: glGetTexLevelParameteriv
static inline void
dumpTextureImage(JSONWriter &json, GLenum target, GLint level)
{
GLint width, height = 1, depth = 1;
width = 0;
glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
if (target != GL_TEXTURE_1D) {
height = 0;
glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
if (target == GL_TEXTURE_3D) {
depth = 0;
glGetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth);
}
}
if (width <= 0 || height <= 0 || depth <= 0) {
return;
} else {
char label[512];
GLint active_texture = GL_TEXTURE0;
glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
snprintf(label, sizeof label, "%s, %s, level = %i", enumToString(active_texture), enumToString(target), level);
json.beginMember(label);
json.beginObject();
// Tell the GUI this is no ordinary object, but an image
json.writeStringMember("__class__", "image");
json.writeNumberMember("__width__", width);
json.writeNumberMember("__height__", height);
json.writeNumberMember("__depth__", depth);
// Hardcoded for now, but we could chose types more adequate to the
// texture internal format
json.writeStringMember("__type__", "uint8");
json.writeBoolMember("__normalized__", true);
json.writeNumberMember("__channels__", 4);
GLubyte *pixels = new GLubyte[depth*width*height*4];
resetPixelPackState();
glGetTexImage(target, level, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
restorePixelPackState();
json.beginMember("__data__");
char *pngBuffer;
int pngBufferSize;
Image::writePixelsToBuffer(pixels, width, height, 4, false, &pngBuffer, &pngBufferSize);
json.writeBase64(pngBuffer, pngBufferSize);
free(pngBuffer);
json.endMember(); // __data__
delete [] pixels;
json.endObject();
}
}