这篇教程C++ AAsset_getLength函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中AAsset_getLength函数的典型用法代码示例。如果您正苦于以下问题:C++ AAsset_getLength函数的具体用法?C++ AAsset_getLength怎么用?C++ AAsset_getLength使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了AAsset_getLength函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: AAssetManager_openShader::Shader(AAssetManager* assetMgr){ AAsset* asset; long sizeAsset; asset = AAssetManager_open(assetMgr, "Shaders/triangle.vert", AASSET_MODE_STREAMING); sizeAsset = AAsset_getLength(asset); gVertexShader = (char*) malloc (sizeof(char)*sizeAsset + 1); AAsset_read (asset,gVertexShader,sizeAsset); gVertexShader[sizeAsset] = 0; AAsset_close(asset); asset = AAssetManager_open(assetMgr, "Shaders/triangle.frag", AASSET_MODE_STREAMING); sizeAsset = AAsset_getLength(asset); gFragmentShader = (char*) malloc (sizeof(char)*sizeAsset + 1); AAsset_read (asset,gFragmentShader,sizeAsset); gFragmentShader[sizeAsset] = 0; AAsset_close(asset); asset = AAssetManager_open(assetMgr, "Shaders/line.vert", AASSET_MODE_STREAMING); sizeAsset = AAsset_getLength(asset); gLineVertexShader = (char*) malloc (sizeof(char)*sizeAsset + 1); AAsset_read (asset,gLineVertexShader,sizeAsset); gLineVertexShader[sizeAsset] = 0; LOGE("%s/n",gLineVertexShader); AAsset_close(asset); asset = AAssetManager_open(assetMgr, "Shaders/line.frag", AASSET_MODE_STREAMING); sizeAsset = AAsset_getLength(asset); gFragmentLineShader = (char*) malloc (sizeof(char)*sizeAsset + 1); AAsset_read (asset,gFragmentLineShader,sizeAsset); gFragmentLineShader[sizeAsset] = 0; LOGE("%s/n",gFragmentLineShader); AAsset_close(asset);}
开发者ID:rakesh-malviya,项目名称:Android-Game-Engine-NDK,代码行数:33,
示例2: TRACE_LOG/** * Get shader program according to type. */GLuint ShaderProgramFactory::CreateShaderProgram(AAssetManager* assetManager, ShaderType type) { if (mShaderPrograms[type] != INVALID_PROGRAM) { // Already created. return mShaderPrograms[type]; } TRACE_LOG("Create new ShaderProgram."); // Get vertex/fragment shader src file path. const char* vertexShaderSrcFile = getShaderSrcFileName(GL_VERTEX_SHADER, type); const char* fragmentShaderSrcFile = getShaderSrcFileName(GL_FRAGMENT_SHADER, type); if (vertexShaderSrcFile == NULL || fragmentShaderSrcFile == NULL) { LOGE("Unexpected ShaderType."); return INVALID_PROGRAM; } // Vertex. // Open assets. AAsset* vertexSrcAsset = AAssetManager_open( assetManager, vertexShaderSrcFile, AASSET_MODE_RANDOM); GLsizei vertSrcLen = AAsset_getLength(vertexSrcAsset); // Src codes. GLchar vertSrc[vertSrcLen + 1]; // Read. AAsset_seek(vertexSrcAsset, 0, 0); AAsset_read(vertexSrcAsset, vertSrc, vertSrcLen); vertSrc[vertSrcLen] = NULL; // Terminal. // Close assets. AAsset_close(vertexSrcAsset); // Fragment. // Open assets. AAsset* fragmentSrcAsset = AAssetManager_open( assetManager, fragmentShaderSrcFile, AASSET_MODE_RANDOM); GLsizei fragSrcLen = AAsset_getLength(fragmentSrcAsset); // Src codes. GLchar fragSrc[fragSrcLen + 1]; // Read. AAsset_seek(fragmentSrcAsset, 0, 0); AAsset_read(fragmentSrcAsset, fragSrc, fragSrcLen); fragSrc[fragSrcLen] = NULL; // Terminal. // Close assets. AAsset_close(fragmentSrcAsset); // Create program. mShaderPrograms[type] = createProgram(vertSrc, vertSrcLen + 1, fragSrc, fragSrcLen + 1); return mShaderPrograms[type];}
开发者ID:talalbutt,项目名称:3-layered-hybrid-app-template,代码行数:57,
示例3: AndroidGetAssetBytesByteArray AndroidGetAssetBytes(const char *inResource){ AAsset *asset = AndroidGetAsset(inResource); if (asset) { long size = AAsset_getLength(asset); ByteArray result(size); AAsset_read(asset, result.Bytes(), size); AAsset_close(asset); return result; } return 0; /*JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/GameActivity"); jmethodID mid = env->GetStaticMethodID(cls, "getResource", "(Ljava/lang/String;)[B"); if (mid == 0) return 0; jstring str = env->NewStringUTF( inResource ); jbyteArray bytes = (jbyteArray)env->CallStaticObjectMethod(cls, mid, str); env->DeleteLocalRef(str); if (bytes==0) { return 0; } jint len = env->GetArrayLength(bytes); ByteArray result(len); env->GetByteArrayRegion(bytes, (jint)0, (jint)len, (jbyte*)result.Bytes()); return result;*/}
开发者ID:madrazo,项目名称:openfl-native-p8,代码行数:35,
示例4: assertshared_ptr<Scene> Scene::loadColladaFromAsset( shared_ptr<EngineContext> engineContext, const string &assetFile) { AAssetManager *assetManager = engineContext->getAssetManager(); assert(assetManager != NULL); AAsset* asset = AAssetManager_open(assetManager, assetFile.c_str(), AASSET_MODE_BUFFER); if (!asset) { ALOGE("Failed to open asset: %s", assetFile.c_str()); return nullptr; } off_t length = AAsset_getLength(asset); unique_ptr<char[]> buffer(new char[length]); size_t sz = AAsset_read(asset, buffer.get(), length); AAsset_close(asset); if (sz != length) { ALOGE("Partial read %d bytes", sz); return nullptr; } return loadColladaFromMemory(buffer.get(), length, assetFile);}
开发者ID:jiayu1016,项目名称:dizzy,代码行数:25,
示例5: test_assets void test_assets() { AAsset* a = AAssetManager_open( g_asset_mgr, "raw/test.jpg", AASSET_MODE_RANDOM ); assert( a != 0 ); off_t len = AAsset_getLength(a); const char *buf = (const char *)AAsset_getBuffer(a); LOGI( "asset: %p %d/n", a, len ); for( size_t i = 0; i < len; ++i ) { LOGI( "x: %c/n", buf[i] ); }// AAssetDir *dir = AAssetManager_openDir(g_asset_mgr, "assets" );// // while( true ) {// const char *name = AAssetDir_getNextFileName(dir);// // if( name == 0 ) {// break;// }// // LOGI( "asset: %s/n", name );// } }
开发者ID:sim82,项目名称:native_gl2,代码行数:26,
示例6: Java_org_gearvrf_NativeImporter_readFileFromAssetsJNIEXPORT jlong JNICALLJava_org_gearvrf_NativeImporter_readFileFromAssets(JNIEnv * env, jobject obj, jobject asset_manager, jstring filename) { const char* native_string = env->GetStringUTFChars(filename, 0); AAssetManager* mgr = AAssetManager_fromJava(env, asset_manager); AAsset* asset = AAssetManager_open(mgr, native_string, AASSET_MODE_UNKNOWN); if (NULL == asset) { LOGE("_ASSET_NOT_FOUND_"); return JNI_FALSE; } long size = AAsset_getLength(asset); char* buffer = (char*) malloc(sizeof(char) * size); AAsset_read(asset, buffer, size); AssimpImporter* assimp_scene = Importer::readFileFromAssets( buffer, size); AAsset_close(asset); free(buffer); env->ReleaseStringUTFChars(filename, native_string); return reinterpret_cast<jlong>(assimp_scene);}
开发者ID:Bonch90,项目名称:GearVRf,代码行数:25,
示例7: ReadFile// Read the contents of the give file return the content and the file size.// The calling function is responsible for free the memory allocated for Content.void ReadFile( const char* pFileName, char** ppContent, unsigned int* pSize ){ assert( g_pManager ); // Open files AAsset* pFile = AAssetManager_open( g_pManager, pFileName, AASSET_MODE_UNKNOWN ); if( pFile != NULL ) { // Determine file size off_t fileSize = AAsset_getLength( pFile ); // Read data char* pData = new char[fileSize]; AAsset_read( pFile, pData, fileSize ); // Allocate space for the file content *ppContent = new char[fileSize]; // Copy the content memcpy( *ppContent, pData, fileSize ); *pSize = fileSize; Log("File length %d",*pSize); delete pData; // Close the file AAsset_close( pFile ); }}
开发者ID:nazgee,项目名称:OpenGlExamples,代码行数:31,
示例8: SOIL_load_OGL_texturevoid Renderer::LoadTexture(const string* filePath, TextureID* id){#ifdef PLATFORM_WINDOWS string nPath = Renderer::GetInstance()->ASSET_PATH + *filePath; id->name = *filePath; id->id = SOIL_load_OGL_texture(nPath.c_str(), SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB);#else AAssetManager* mgr = System::GetInstance()->GetEngineData()->app->activity->assetManager; AAsset* textureAsset = AAssetManager_open(mgr, filePath->c_str(), AASSET_MODE_UNKNOWN); unsigned int length = AAsset_getLength(textureAsset); unsigned char * bitmap = new unsigned char[length]; AAsset_read(textureAsset, (void*)bitmap, length); id->name = *filePath; id->id = SOIL_load_OGL_texture_from_memory(bitmap, length, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB); ++length;#endif}
开发者ID:ACPLMaverick,项目名称:MAVNET,代码行数:28,
示例9: strcpyvoid OSLOgg::load(char* filename) { strcpy(this->filename, filename);// LOGD("filename = %s, this->filename = %s",filename, this->filename); // if set Player Buffer, than load audio data to PCM buffer if(playerType == BUFFER){ AAsset* f = openFile(filename); if (!f) { LOGE("no file %s",filename); throw "no file %s"; } buf = 0; off_t length = AAsset_getLength(f); buf = (char*) malloc(length); if (buf) { if (AAsset_read(f,buf, length)) { } else { free(buf); AAsset_close(f); LOGE("smthng wrong with %s",filename); throw "smthng wrong while reading file"; // return; } }// LOGD("length = %d", length); this->buf = (char *) ConvertOggToPCM(length, buf); if(f) AAsset_close(f); }}
开发者ID:Suvitruf,项目名称:Android-ndk,代码行数:34,
示例10: openFilechar* OSLSound::readWAVFull(AAssetManager *mgr, BasicWAVEHeader* header) { char* buffer = 0; AAsset * file = openFile(filename); if (!file) { LOGE("no file %s in readWAV",filename); return 0; } char extra[2]; int res = AAsset_read (file,header,sizeof(BasicWAVEHeader)); if(!strstr(header->data, "data")) { AAsset_read (file,extra,2); header->dataSize = AAsset_getLength(file) - sizeof(BasicWAVEHeader)-2; } if(res) { buffer = (char*)malloc(header->dataSize); if (buffer) { res = AAsset_read (file,buffer,header->dataSize); if(res) { AAsset_close(file); return buffer; } free(buffer); } } AAsset_close(file); return 0;}
开发者ID:cibergod,项目名称:Pac-man-for-android-NDK,代码行数:29,
示例11: files FileInfoListPtr APKFileSystemArchive::findFileInfo(const String& pattern, bool recursive, bool dirs) { FileInfoListPtr files(new FileInfoList); std::map<String, std::vector< String > >::iterator iter = mFiles.find( mName ); std::vector< String > fileList = iter->second; for( size_t i = 0; i < fileList.size(); i++ ) { if(StringUtil::match(fileList[i], pattern)) { AAsset* asset = AAssetManager_open(mAssetMgr, (mPathPreFix + fileList[i]).c_str(), AASSET_MODE_UNKNOWN); if(asset) { FileInfo info; info.archive = this; info.filename = fileList[i]; info.path = mName; info.basename = fileList[i]; info.compressedSize = AAsset_getLength(asset); info.uncompressedSize = info.compressedSize; files->push_back(info); AAsset_close(asset); } } } return files; }
开发者ID:Gerviba,项目名称:MuOnline,代码行数:25,
示例12: assetAssetFileCache::AssetFileCache ( AAsset* asset ) : asset ( asset ){ fileSize = AAsset_getLength ( asset ); pageSize = 1024 * 1024; nbrPageData = 8; pos = 0; uint32_t totalPages = fileSize / pageSize; if ( fileSize % pageSize != 0 ) { totalPages++; } this->totalPages = totalPages; if ( totalPages < nbrPageData ) { nbrPageData = totalPages; } for ( int32_t n = 0; n < totalPages; n++ ) { pages.push_back ( new Page() ); } for ( int32_t n = 0; n < nbrPageData; n++ ) { pageData.push_back ( new PageData ( pageSize ) ); } LOGI ( "Created, asset = %p, fileSize = %d, totalPages = %d, nbrPageData = %d", asset, fileSize, totalPages, nbrPageData );}
开发者ID:emileb,项目名称:MobileTouchControls,代码行数:34,
示例13: ReadAPKFile int ReadAPKFile(void ** data, const char * filename) { assert (gAssetManager != NULL); AAsset * pAsset = AAssetManager_open(gAssetManager, filename, AASSET_MODE_UNKNOWN); if (pAsset == NULL) return -1; size_t size = AAsset_getLength(pAsset); if (size > 0 && data != NULL) { unsigned char * pd = new unsigned char[size]; int read_count = AAsset_read(pAsset, pd, size); if(read_count <= 0) { n_log("?: Read APK File '%s'.", filename); delete[] pd; pd = NULL; size = 0; } *data = pd; } AAsset_close(pAsset); return size; }
开发者ID:MSoft1115,项目名称:Rad3D,代码行数:29,
示例14: GetAssetvoid GetAsset(char* path, GLchar *text, GLuint *length){ AAsset* asset = AAssetManager_open(Manager, path, AASSET_MODE_STREAMING); *length = AAsset_getLength(asset); AAsset_read(asset, text, length); AAsset_close(asset);}
开发者ID:jmoak3,项目名称:ImageViewer5000,代码行数:7,
示例15: androidReadvoid androidRead(const char* pFileName, char** ppContent, unsigned int* pSize) { assert( gActivity->assetManager ); AAsset* pFile = AAssetManager_open(gActivity->assetManager, pFileName, AASSET_MODE_STREAMING); if (pFile != NULL) { off_t fileSize = AAsset_getLength(pFile); std::string path = androidGetPath(pFileName); char* pData = new char[fileSize]; AAsset_read(pFile, pData, fileSize); *ppContent = new char[fileSize]; memcpy(*ppContent, pData, fileSize); *pSize = fileSize; FLOG_DEBUG("File %s length %d", pFileName, *pSize); delete pData; AAsset_close(pFile); }}
开发者ID:filipwasil,项目名称:fillwave,代码行数:25,
示例16: LOGDconst char* AndroidPlatformAdapter::loadAsset(const char* filename, size_t* size) { LOGD("loadAsset %s", filename); AAsset* asset = AAssetManager_open(m_AssetManager, filename, AASSET_MODE_UNKNOWN); if (NULL == asset) { LOGE("_ASSET_NOT_FOUND_ %s", filename); return 0; } size_t filesize = AAsset_getLength(asset); char* data; if(size) { *size = filesize; data = new char[filesize]; } else { data = new char[filesize + 1]; } AAsset_read (asset,data,filesize); AAsset_close(asset); if(!size) { data[filesize] = 0; } return data;}
开发者ID:EthrosDemon,项目名称:p3d,代码行数:27,
示例17: voidvoid LoaderAndroid::loadAsset(const char* filename, std::stringstream& stream) { //auto del = AAsset_close(); std::unique_ptr<AAsset, void (*)(AAsset*)> asset(AAssetManager_open(assetManager, filename, AASSET_MODE_BUFFER), AAsset_close); //std::unique_ptr<AAsset> asset(AAssetManager_open(assetManager, filename, AASSET_MODE_BUFFER)); //asset.get_deleter() //AAsset* asset = AAssetManager_open(assetManager, filename, AASSET_MODE_BUFFER); if(asset){ //std::string content; //content.resize(AAsset_getLength( asset )); std::vector<char> buffer; buffer.resize(AAsset_getLength( asset.get() )); //AAsset_read(asset, (void *)content.data(), content.size()); // ToDo: ugly hack AAsset_read( asset.get(), (void *)buffer.data(), buffer.size()); //stream << content; stream.write(buffer.data(), buffer.size()); } else{ LOG(WARNING) << "Asset %s not found"; } // ToDo: I want to return a stringstream object, but gnu_std doesn't support move constructor for stringstreams}
开发者ID:SOTR,项目名称:OpenGLTest,代码行数:27,
示例18: getFullFilePathveFileData* veFileAndroid::readFileToBuffer(const std::string &filePath) { if (!veFileAndroid::ASSET_MANAGER) return nullptr; std::string fullPath = getFullFilePath(filePath); if (!isFileExist(fullPath)) return nullptr; auto fileIter = _fileDataCache.find(fullPath); if (fileIter != _fileDataCache.end()) return fileIter->second; const char* str = fullPath.c_str() + strlen("assets/"); AAsset* asset = AAssetManager_open(veFileAndroid::ASSET_MANAGER, str, AASSET_MODE_UNKNOWN); if (asset) { off_t fileSize = AAsset_getLength(asset); char *buffer = new char[fileSize + 1]; buffer[fileSize] = '/0'; int bytesread = AAsset_read(asset, (void*)buffer, fileSize); auto fileData = new veFileData(); fileData->buffer = buffer; fileData->size = fileSize + 1; //veLog("filebuffer: %s, size: %d", buffer, fileSize); _fileDataCache[fullPath] = fileData; AAsset_close(asset); return fileData; } return nullptr;}
开发者ID:songchengjiang,项目名称:VoidEngine,代码行数:27,
示例19: loadShader // Android shaders are stored as assets in the apk // So they need to be loaded via the asset manager VkShaderModule loadShader(AAssetManager* assetManager, const char *fileName, VkDevice device, VkShaderStageFlagBits stage) { // Load shader from compressed asset AAsset* asset = AAssetManager_open(assetManager, fileName, AASSET_MODE_STREAMING); assert(asset); size_t size = AAsset_getLength(asset); assert(size > 0); char *shaderCode = new char[size]; AAsset_read(asset, shaderCode, size); AAsset_close(asset); VkShaderModule shaderModule; VkShaderModuleCreateInfo moduleCreateInfo; moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; moduleCreateInfo.pNext = NULL; moduleCreateInfo.codeSize = size; moduleCreateInfo.pCode = (uint32_t*)shaderCode; moduleCreateInfo.flags = 0; VK_CHECK_RESULT(vkCreateShaderModule(device, &moduleCreateInfo, NULL, &shaderModule)); delete[] shaderCode; return shaderModule; }
开发者ID:SaschaWillems,项目名称:VulkanSponza,代码行数:28,
示例20: files FileInfoListPtr APKFileSystemArchive::listFileInfo(bool recursive, bool dirs) { FileInfoListPtr files(new FileInfoList); AAssetDir* dir = AAssetManager_openDir(mAssetMgr, mName.c_str()); const char* fileName = NULL; while((fileName = AAssetDir_getNextFileName(dir)) != NULL) { AAsset* asset = AAssetManager_open(mAssetMgr, (mPathPreFix + String(fileName)).c_str(), AASSET_MODE_UNKNOWN); if(asset) { FileInfo info; info.archive = this; info.filename = fileName; info.path = mName; info.basename = fileName; info.compressedSize = AAsset_getLength(asset); info.uncompressedSize = info.compressedSize; files->push_back(info); AAsset_close(asset); } } AAssetDir_close(dir); return files; }
开发者ID:dorgonman,项目名称:cocos2d-x-ogre,代码行数:28,
示例21: AssetFileSystem_ftelllong int AssetFileSystem_ftell( AssetFileSystem_FILE * stream ){ off_t total = AAsset_getLength( stream ); off_t remain = AAsset_getRemainingLength( stream ); off_t offset = total - remain; return (offset >= 0 && offset <= total) ? offset : -1L;}
开发者ID:Ahbee,项目名称:Cinder,代码行数:7,
示例22: read_filestd::string read_file(const std::string& fname){ AAssetManager* assetManager = GetJavaAssetManager(); AAsset* asset; std::string name(fname); if(name[0] == '.' && name[1] == '/') { name = name.substr(2); } asset = AAssetManager_open(assetManager, name.c_str(), AASSET_MODE_RANDOM); if(asset != 0) { int len = AAsset_getLength(asset); std::vector<char> v; v.resize(len); if(AAsset_read(asset,&v[0],len)>0) { std::string s(v.begin(),v.end()); AAsset_close(asset); return s; } AAsset_close(asset); return 0; } // Couldn't find the file as an asset, try the standard filesystem std::string filename = find_file(fname); std::ifstream file(filename.c_str(),std::ios_base::binary); std::stringstream ss; ss << file.rdbuf(); return ss.str();}
开发者ID:Marjoe,项目名称:frogatto,代码行数:29,
示例23: _assetaasset_buffer_t::aasset_buffer_t(AAsset* asset) : _asset(asset), _position(0), _data(nullptr){ _size = AAsset_getLength(_asset);}
开发者ID:azorej,项目名称:zeptotest,代码行数:7,
示例24: bytesFromAssetManagerunsigned char* bytesFromAssetManager(const char* _path, unsigned int* _size) { unsigned char* data = nullptr; AAsset* asset = AAssetManager_open(assetManager, _path, AASSET_MODE_UNKNOWN); if (asset == nullptr) { logMsg("Failed to open asset at path: %s/n", _path); *_size = 0; return data; } *_size = AAsset_getLength(asset); data = (unsigned char*) malloc(sizeof(unsigned char) * (*_size)); int read = AAsset_read(asset, data, *_size); if (read <= 0) { logMsg("Failed to read asset at path: %s/n", _path); } AAsset_close(asset); return data;}
开发者ID:zerebubuth,项目名称:tangram-es,代码行数:26,
示例25: stringFromResourcestd::string stringFromResource(const char* _path) { std::string out; // Open asset AAsset* asset = AAssetManager_open(assetManager, _path, AASSET_MODE_STREAMING); if (asset == nullptr) { logMsg("Failed to open asset at path: %s/n", _path); return out; } // Allocate string int length = AAsset_getLength(asset); out.resize(length); // Read data int read = AAsset_read(asset, &out.front(), length); // Clean up AAsset_close(asset); if (read <= 0) { logMsg("Failed to read asset at path: %s/n", _path); } return out;}
开发者ID:xvilan,项目名称:tangram-es,代码行数:29,
示例26: LOGE int Asset::GetLength() { if(!mAsset) { LOGE("Asset::GetLength() error: asset is not opened"); return 0; } return AAsset_getLength(mAsset); }
开发者ID:gitter-badger,项目名称:MPACK,代码行数:9,
示例27: jpeg_std_errortImage *LoadJPG(const char *strFileName){ tImage *pImageData = NULL; struct jpeg_decompress_struct cinfo; jpeg_error_mgr jerr; pImageData = (tImage*)malloc(sizeof(tImage)); cinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); AAsset* pAsset = AAssetManager_open(g_amgr, strFileName, AASSET_MODE_UNKNOWN); if (!pAsset) { free(pImageData); LOGE("Error opening jpeg %s", strFileName); return NULL; } unsigned char* ucharRawData = (unsigned char*)AAsset_getBuffer(pAsset); long myAssetLength = (long)AAsset_getLength(pAsset); // the jpeg_stdio_src alternative func, which is also included in IJG's lib. jpeg_mem_src(&cinfo, ucharRawData, myAssetLength); jpeg_read_header(&cinfo, TRUE); jpeg_start_decompress(&cinfo); pImageData->channels = cinfo.num_components; pImageData->sizeX = cinfo.image_width; pImageData->sizeY = cinfo.image_height; int rowSpan = cinfo.image_width * cinfo.num_components; pImageData->data = ((unsigned char*)malloc(sizeof(unsigned char)*rowSpan*pImageData->sizeY)); unsigned char** rowPtr = new unsigned char*[pImageData->sizeY]; for (int i = 0; i < pImageData->sizeY; i++) rowPtr[i] = &(pImageData->data[i * rowSpan]); int rowsRead = 0; while (cinfo.output_scanline < cinfo.output_height) rowsRead += jpeg_read_scanlines(&cinfo, &rowPtr[rowsRead], cinfo.output_height - rowsRead); delete [] rowPtr; jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); AAsset_close(pAsset); return pImageData;}
开发者ID:zhaozw,项目名称:pathogenandroid,代码行数:57,
示例28: AAssetManager_openmy::buffer art::asset::retrieve(my::string request, my::string path) { DEBUG_SCOPE; my::buffer data; DEBUG_TRACE << "Attempting to find resource: " << request << my::endl; AAsset* asset = AAssetManager_open((AAssetManager*)manager_instance, request, AASSET_MODE_STREAMING); //m_ptr = asset; if(asset) { DEBUG_TRACE << "Found resource " << (int)AAsset_getLength(asset) << " bytes" << my::endl;// DEBUG_TRACE << "Contents: " << (char *)AAsset_getBuffer(asset) << my::endl;// DEBUG_TRACE << "Contents length: " << strlen((char *)AAsset_getBuffer(asset)) << my::endl; data.write((unsigned char *)AAsset_getBuffer(asset), AAsset_getLength(asset)); } else { DEBUG_TRACE << "Failure to load resource" << my::endl; } return(data);}
开发者ID:shizgnit,项目名称:ApplicationTemplate,代码行数:18,
示例29: apk_sizestatic long apk_size(struct stream_t* stream){ if (stream == NULL) { return -1; } struct io_stream_apk_t* s = (struct io_stream_apk_t*)stream; return AAsset_getLength(s->f);}
开发者ID:asqz,项目名称:runner,代码行数:10,
示例30: AAsset_getLengthbool BaseFile::at_end(){ if (flags & ANDROID_ASSET) { return AAsset_getLength((AAsset*)handle) == 0; } else { FILE * fp = (FILE*)handle; int c = getc(fp); ungetc(c, fp); return c == EOF; }}
开发者ID:mattl,项目名称:anaconda,代码行数:11,
注:本文中的AAsset_getLength函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ AAsset_read函数代码示例 C++ AAsset_close函数代码示例 |