本文整理汇总了C++中ofBuffer::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ ofBuffer::getData方法的具体用法?C++ ofBuffer::getData怎么用?C++ ofBuffer::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofBuffer
的用法示例。
在下文中一共展示了ofBuffer::getData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
bool ofxTurboJpeg::load(const ofBuffer& buf, ofPixels &pix)
{
int w, h;
int subsamp;
int ok = tjDecompressHeader2(handleDecompress, (unsigned char*)buf.getData(), buf.size(), &w, &h, &subsamp);
if (ok != 0)
{
printf("Error in tjDecompressHeader2():\n%s\n", tjGetErrorStr());
return false;
}
pix.allocate(w, h, 3);
tjDecompress(handleDecompress, (unsigned char*)buf.getData(), buf.size(), pix.getData(), w, 0, h, 3, 0);
return true;
}
示例2: loadImage
static bool loadImage(ofPixels_<PixelType> & pix, const ofBuffer & buffer, const ofImageLoadSettings &settings){
ofInitFreeImage();
bool bLoaded = false;
FIBITMAP* bmp = nullptr;
FIMEMORY* hmem = nullptr;
hmem = FreeImage_OpenMemory((unsigned char*) buffer.getData(), buffer.size());
if (hmem == nullptr){
ofLogError("ofImage") << "loadImage(): couldn't load image from ofBuffer, opening FreeImage memory failed";
return false;
}
//get the file type!
FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(hmem);
if( fif == -1 ){
ofLogError("ofImage") << "loadImage(): couldn't load image from ofBuffer, unable to guess image format from memory";
FreeImage_CloseMemory(hmem);
return false;
}
//make the image!!
if(fif == FIF_JPEG) {
int option = getJpegOptionFromImageLoadSetting(settings);
bmp = FreeImage_LoadFromMemory(fif, hmem, option);
} else {
bmp = FreeImage_LoadFromMemory(fif, hmem, 0);
}
if( bmp != nullptr ){
bLoaded = true;
}
//-----------------------------
if (bLoaded){
putBmpIntoPixels(bmp,pix);
}
if (bmp != nullptr){
FreeImage_Unload(bmp);
}
if( hmem != nullptr ){
FreeImage_CloseMemory(hmem);
}
return bLoaded;
}
示例3: loadModel
bool ofxAssimpModelLoader::loadModel(ofBuffer & buffer, bool optimize, const char * extension){
ofLogVerbose("ofxAssimpModelLoader") << "loadModel(): loading from memory buffer \"." << extension << "\"";
if(scene.get() != nullptr){
clear();
// we reset the shared_ptr explicitly here, to force the old
// aiScene to be deleted **before** a new aiScene is created.
scene.reset();
}
// sets various properties & flags to a default preference
unsigned int flags = initImportProperties(optimize);
// loads scene from memory buffer - note this will not work for multipart files (obj, md3, etc)
scene = shared_ptr<const aiScene>(aiImportFileFromMemoryWithProperties(buffer.getData(), buffer.size(), flags, extension, store.get()), aiReleaseImport);
bool bOk = processScene();
return bOk;
}
示例4: load
vector<Mesh*> Loader::load(const ofBuffer &buffer)
{
return load(buffer.getData(), buffer.size());
}
示例5: readBytes
//----------------------------------------------------------------
long ofSerial::readBytes(ofBuffer & buffer, size_t length){
buffer.allocate(length);
return readBytes(buffer.getData(),length);
}
示例6: writeBytes
//----------------------------------------------------------------
long ofSerial::writeBytes(const ofBuffer & buffer){
return writeBytes(buffer.getData(),buffer.size());
}