本文整理汇总了C++中LLImageRaw::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ LLImageRaw::resize方法的具体用法?C++ LLImageRaw::resize怎么用?C++ LLImageRaw::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLImageRaw
的用法示例。
在下文中一共展示了LLImageRaw::resize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
//.........这里部分代码省略.........
/* close the byte stream */
opj_cio_close(cio);
/* free remaining structures */
if(dinfo)
{
opj_destroy_decompress(dinfo);
}
// The image decode failed if the return was NULL or the component
// count was zero. The latter is just a sanity check before we
// dereference the array.
if(!image || !image->numcomps)
{
LL_DEBUGS("Texture") << "ERROR -> decodeImpl: failed to decode image!" << LL_ENDL;
if (image)
{
opj_image_destroy(image);
}
return TRUE; // done
}
// sometimes we get bad data out of the cache - check to see if the decode succeeded
for (S32 i = 0; i < image->numcomps; i++)
{
if (image->comps[i].factor != base.getRawDiscardLevel())
{
// if we didn't get the discard level we're expecting, fail
opj_image_destroy(image);
base.mDecoding = FALSE;
return TRUE;
}
}
if(image->numcomps <= first_channel)
{
llwarns << "trying to decode more channels than are present in image: numcomps: " << image->numcomps << " first_channel: " << first_channel << llendl;
if (image)
{
opj_image_destroy(image);
}
return TRUE;
}
// Copy image data into our raw image format (instead of the separate channel format
S32 img_components = image->numcomps;
S32 channels = img_components - first_channel;
if( channels > max_channel_count )
channels = max_channel_count;
// Component buffers are allocated in an image width by height buffer.
// The image placed in that buffer is ceil(width/2^factor) by
// ceil(height/2^factor) and if the factor isn't zero it will be at the
// top left of the buffer with black filled in the rest of the pixels.
// It is integer math so the formula is written in ceildivpo2.
// (Assuming all the components have the same width, height and
// factor.)
S32 comp_width = image->comps[0].w;
S32 f=image->comps[0].factor;
S32 width = ceildivpow2(image->x1 - image->x0, f);
S32 height = ceildivpow2(image->y1 - image->y0, f);
raw_image.resize(width, height, channels);
U8 *rawp = raw_image.getData();
// first_channel is what channel to start copying from
// dest is what channel to copy to. first_channel comes from the
// argument, dest always starts writing at channel zero.
for (S32 comp = first_channel, dest=0; comp < first_channel + channels;
comp++, dest++)
{
if (image->comps[comp].data)
{
S32 offset = dest;
for (S32 y = (height - 1); y >= 0; y--)
{
for (S32 x = 0; x < width; x++)
{
rawp[offset] = image->comps[comp].data[y*comp_width + x];
offset += channels;
}
}
}
else // Some rare OpenJPEG versions have this bug.
{
LL_DEBUGS("Texture") << "ERROR -> decodeImpl: failed to decode image! (NULL comp data - OpenJPEG bug)" << LL_ENDL;
opj_image_destroy(image);
return TRUE; // done
}
}
/* free image data structure */
opj_image_destroy(image);
return TRUE; // done
}
示例2: llmin
BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count, int discard_level, int* region)
{
base.resetLastError();
// *FIX: kdu calls our callback function if there's an error, and then bombs.
// To regain control, we throw an exception, and catch it here.
try
{
// Merov : Test!! DO NOT COMMIT!!
//findDiscardLevelsBoundaries(base);
base.updateRawDiscardLevel();
setupCodeStream(base, TRUE, mode);
mRawImagep = &raw_image;
mCodeStreamp->change_appearance(false, true, false);
// Apply loading discard level and cropping if required
kdu_dims* region_kdu = NULL;
if (region != NULL)
{
region_kdu = new kdu_dims;
region_kdu->pos.x = region[0];
region_kdu->pos.y = region[1];
region_kdu->size.x = region[2] - region[0];
region_kdu->size.y = region[3] - region[1];
}
int discard = (discard_level != -1 ? discard_level : base.getRawDiscardLevel());
//llinfos << "Merov debug : initDecode, discard used = " << discard << ", asked = " << discard_level << llendl;
// Apply loading restrictions
mCodeStreamp->apply_input_restrictions( first_channel, max_channel_count, discard, 0, region_kdu);
// Clean-up
if (region_kdu)
{
delete region_kdu;
region_kdu = NULL;
}
// Resize raw_image according to the image to be decoded
kdu_dims dims; mCodeStreamp->get_dims(0,dims);
S32 channels = base.getComponents() - first_channel;
channels = llmin(channels,max_channel_count);
raw_image.resize(dims.size.x, dims.size.y, channels);
if (!mTileIndicesp)
{
mTileIndicesp = new kdu_dims;
}
mCodeStreamp->get_valid_tiles(*mTileIndicesp);
if (!mTPosp)
{
mTPosp = new kdu_coords;
mTPosp->y = 0;
mTPosp->x = 0;
}
}
catch (const char* msg)
{
base.setLastError(ll_safe_string(msg));
return FALSE;
}
catch (...)
{
base.setLastError("Unknown J2C error");
return FALSE;
}
return TRUE;
}
示例3:
//.........这里部分代码省略.........
// count was zero. The latter is just a sanity check before we
// dereference the array.
if(!image || !image->numcomps)
{
LL_DEBUGS("Texture") << "ERROR -> decodeImpl: failed to decode image!" << LL_ENDL;
if (image)
{
opj_image_destroy(image);
}
base.decodeFailed();
return TRUE; // done
}
// sometimes we get bad data out of the cache - check to see if the decode succeeded
for (S32 i = 0; i < image->numcomps; i++)
{
if (image->comps[i].factor != base.getRawDiscardLevel())
{
// if we didn't get the discard level we're expecting, fail
opj_image_destroy(image);
base.decodeFailed();
return TRUE;
}
}
if(image->numcomps <= first_channel)
{
LL_WARNS("Texture") << "trying to decode more channels than are present in image: numcomps: " << image->numcomps << " first_channel: " << first_channel << LL_ENDL;
if (image)
{
opj_image_destroy(image);
}
base.decodeFailed();
return TRUE;
}
// Copy image data into our raw image format (instead of the separate channel format
S32 img_components = image->numcomps;
S32 channels = img_components - first_channel;
if( channels > max_channel_count )
channels = max_channel_count;
// Component buffers are allocated in an image width by height buffer.
// The image placed in that buffer is ceil(width/2^factor) by
// ceil(height/2^factor) and if the factor isn't zero it will be at the
// top left of the buffer with black filled in the rest of the pixels.
// It is integer math so the formula is written in ceildivpo2.
// (Assuming all the components have the same width, height and
// factor.)
S32 comp_width = image->comps[0].w;
S32 f=image->comps[0].factor;
S32 width = ceildivpow2(image->x1 - image->x0, f);
S32 height = ceildivpow2(image->y1 - image->y0, f);
raw_image.resize(width, height, channels);
U8 *rawp = raw_image.getData();
if (!rawp)
{
opj_image_destroy(image);
base.setLastError("Memory error");
base.decodeFailed();
return true; // done
}
// first_channel is what channel to start copying from
// dest is what channel to copy to. first_channel comes from the
// argument, dest always starts writing at channel zero.
for (S32 comp = first_channel, dest=0; comp < first_channel + channels;
comp++, dest++)
{
if (image->comps[comp].data)
{
S32 offset = dest;
for (S32 y = (height - 1); y >= 0; y--)
{
for (S32 x = 0; x < width; x++)
{
rawp[offset] = image->comps[comp].data[y*comp_width + x];
offset += channels;
}
}
}
else // Some rare OpenJPEG versions have this bug.
{
LL_DEBUGS("Texture") << "ERROR -> decodeImpl: failed to decode image! (NULL comp data - OpenJPEG bug)" << LL_ENDL;
if (image)
{
opj_image_destroy(image);
}
base.decodeFailed();
return TRUE; // done
}
}
/* free image data structure */
opj_image_destroy(image);
return TRUE; // done
}
示例4: sizeof
//.........这里部分代码省略.........
decompdifference = llmax(decompdifference, cinfo.numdecompos[comp] - image->comps[comp].resno_decoded);
}
if (decompdifference < 0) // sanity
{
decompdifference = 0;
}
}
/* if OpenJPEG failed to decode all requested decomposition levels
the difference will be greater than this level */
if (decompdifference > base.getRawDiscardLevel())
{
LL_WARNS("Openjpeg") << "Not enough data for requested discard level " << (S32)base.getRawDiscardLevel() << ", difference: " << (decompdifference - base.getRawDiscardLevel()) << llendl;
opj_destroy_cstr_info(&cinfo);
opj_image_destroy(image);
if (base.getRawDiscardLevel() == 0)
{
base.decodeFailed();
}
return TRUE;
}
if(img_components <= first_channel)
{
LL_WARNS("Openjpeg") << "Trying to decode more channels than are present in image, numcomps: " << img_components << " first_channel: " << first_channel << LL_ENDL;
if (image)
{
opj_destroy_cstr_info(&cinfo);
opj_image_destroy(image);
}
if (base.getRawDiscardLevel() == 0)
{
base.decodeFailed();
}
return TRUE;
}
// Copy image data into our raw image format (instead of the separate channel format
S32 channels = img_components - first_channel;
if( channels > max_channel_count )
channels = max_channel_count;
// Component buffers are allocated in an image width by height buffer.
// The image placed in that buffer is ceil(width/2^factor) by
// ceil(height/2^factor) and if the factor isn't zero it will be at the
// top left of the buffer with black filled in the rest of the pixels.
// It is integer math so the formula is written in ceildivpo2.
// (Assuming all the components have the same width, height and
// factor.)
S32 comp_width = image->comps[0].w;
S32 f=image->comps[0].factor;
S32 width = ceildivpow2(image->x1 - image->x0, f);
S32 height = ceildivpow2(image->y1 - image->y0, f);
raw_image.resize(width, height, channels);
U8 *rawp = raw_image.getData();
// first_channel is what channel to start copying from
// dest is what channel to copy to. first_channel comes from the
// argument, dest always starts writing at channel zero.
for (S32 comp = first_channel, dest=0; comp < first_channel + channels;
comp++, dest++)
{
if (image->comps[comp].data)
{
S32 offset = dest;
for (S32 y = (height - 1); y >= 0; y--)
{
for (S32 x = 0; x < width; x++)
{
rawp[offset] = image->comps[comp].data[y*comp_width + x];
offset += channels;
}
}
}
else // Some rare OpenJPEG versions have this bug.
{
LL_WARNS("Openjpeg") << "Failed to decode image! (NULL comp data - OpenJPEG bug)" << LL_ENDL;
opj_destroy_cstr_info(&cinfo);
opj_image_destroy(image);
if (base.getRawDiscardLevel() == 0)
{
base.decodeFailed();
}
return TRUE; // done
}
}
/* free opj data structures */
if (image)
{
opj_destroy_cstr_info(&cinfo);
opj_image_destroy(image);
}
return TRUE; // done
}