这篇教程C++ stbi_load_from_memory函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中stbi_load_from_memory函数的典型用法代码示例。如果您正苦于以下问题:C++ stbi_load_from_memory函数的具体用法?C++ stbi_load_from_memory怎么用?C++ stbi_load_from_memory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了stbi_load_from_memory函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: stbi_set_flip_vertically_on_loadvoid Texture::loadImageFromMemory(const unsigned char* blob, unsigned int size, bool flipOnLoad) { unsigned char* pixels = nullptr; int width, height, comp; // stbi_load_from_memory loads the image as a serie of scanline starting from // the top-left corner of the image. When shouldFlip is set to true, the image // would be flipped vertically. stbi_set_flip_vertically_on_load((int)flipOnLoad); if (blob != nullptr && size != 0) { pixels = stbi_load_from_memory(blob, size, &width, &height, &comp, STBI_rgb_alpha); } if (pixels) { resize(width, height); setData(reinterpret_cast<GLuint*>(pixels), width * height); stbi_image_free(pixels); m_validData = true; } else { // Default inconsistent texture data is set to a 1*1 pixel texture // This reduces inconsistent behavior when texture failed loading // texture data but a Tangram style shader requires a shader sampler GLuint blackPixel = 0x0000ff; setData(&blackPixel, 1); LOGE("Decoding image from memory failed"); m_validData = false; }}
开发者ID:hymn4u,项目名称:tangram-es,代码行数:34,
示例2: definedvoid Stb::Read(SoyPixelsImpl& Pixels,const ArrayBridge<char>& ArrayBuffer,TReadFunction ReadFunction){#if defined(USE_STB) const stbi_uc* Buffer = reinterpret_cast<const stbi_uc*>( ArrayBuffer.GetArray() ); auto BufferSize = size_cast<int>( ArrayBuffer.GetDataSize() ); int Width = 0; int Height = 0; int Channels = 0; int RequestedChannels = 4; auto* DecodedPixels = stbi_load_from_memory( Buffer, BufferSize, &Width, &Height, &Channels, RequestedChannels ); if ( !DecodedPixels ) { // gr: as this is not thread safe, it could come out mangled :( maybe add a lock around error popping before read (maybe have to lock around the whole thing) auto* StbError = stbi_failure_reason(); if ( !StbError ) StbError = "Unknown error"; std::stringstream Error; Error << "Failed to read image pixels; " << StbError; throw Soy::AssertException( Error.str() ); } // convert output into pixels // gr: have to assume size auto Format = SoyPixelsFormat::GetFormatFromChannelCount( Channels ); SoyPixelsMeta Meta( Width, Height, Format ); SoyPixelsRemote OutputPixels( DecodedPixels, Meta.GetDataSize(), Meta ); Pixels.Copy( OutputPixels );#else throw Soy::AssertException("No STB support, no image reading");#endif}
开发者ID:SoylentGraham,项目名称:SoyLib,代码行数:32,
示例3: create_ios_launch_imagesstatic bool create_ios_launch_images(const char *dir, export_config *conf) { size_t len; stbi_uc *img_data; int width, height; if (conf->launch_image == NULL) { width = 1024; height = 1024; len = width * height * 4; img_data = (stbi_uc*)malloc(len); memset(img_data, 255, len); } else { void *data = am_read_file(conf->launch_image, &len); int components = 4; stbi_set_flip_vertically_on_load(0); img_data = stbi_load_from_memory((stbi_uc const *)data, len, &width, &height, &components, 4); free(data); if (img_data == NULL) return false; } if (!resize_image(img_data, width, height, dir, "Default.png", 320, 480) || !resize_image(img_data, width, height, dir, "[email C++ std_err函数代码示例 C++ stbi_load函数代码示例
|