本文整理汇总了C++中LLImageJ2C::setSize方法的典型用法代码示例。如果您正苦于以下问题:C++ LLImageJ2C::setSize方法的具体用法?C++ LLImageJ2C::setSize怎么用?C++ LLImageJ2C::setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLImageJ2C
的用法示例。
在下文中一共展示了LLImageJ2C::setSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
BOOL LLImageJ2COJ::getMetadata(LLImageJ2C &base)
{
//
// FIXME: We get metadata by decoding the ENTIRE image.
//
// Update the raw discard level
base.updateRawDiscardLevel();
opj_dparameters_t parameters; /* decompression parameters */
opj_event_mgr_t event_mgr; /* event manager */
opj_image_t *image = NULL;
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
opj_cio_t *cio = NULL;
/* configure the event callbacks (not required) */
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
event_mgr.error_handler = error_callback;
event_mgr.warning_handler = warning_callback;
event_mgr.info_handler = info_callback;
/* set decoding parameters to default values */
opj_set_default_decoder_parameters(¶meters);
// Only decode what's required to get the size data.
parameters.cp_limit_decoding=LIMIT_TO_MAIN_HEADER;
//parameters.cp_reduce = mRawDiscardLevel;
/* decode the code-stream */
/* ---------------------- */
/* JPEG-2000 codestream */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_J2K);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder(dinfo, ¶meters);
/* open a byte stream */
cio = opj_cio_open((opj_common_ptr)dinfo, base.getData(), base.getDataSize());
/* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio);
/* close the byte stream */
opj_cio_close(cio);
/* free remaining structures */
if(dinfo)
{
opj_destroy_decompress(dinfo);
}
if(!image)
{
llwarns << "ERROR -> getMetadata: failed to decode image!" << llendl;
return FALSE;
}
// Copy image data into our raw image format (instead of the separate channel format
S32 width = 0;
S32 height = 0;
S32 img_components = image->numcomps;
width = image->x1 - image->x0;
height = image->y1 - image->y0;
base.setSize(width, height, img_components);
/* free image data structure */
opj_image_destroy(image);
return TRUE;
}
示例2: LLKDUMemSource
void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECodeStreamMode mode)
{
S32 data_size = base.getDataSize();
S32 max_bytes = (base.getMaxBytes() ? base.getMaxBytes() : data_size);
//
// Initialization
//
if (!kdu_message_initialized)
{
kdu_message_initialized = true;
kdu_customize_errors(&LLKDUMessageError::sDefaultMessage);
kdu_customize_warnings(&LLKDUMessageWarning::sDefaultMessage);
}
if (mCodeStreamp)
{
mCodeStreamp->destroy();
delete mCodeStreamp;
mCodeStreamp = NULL;
}
if (!mInputp && base.getData())
{
// The compressed data has been loaded
// Setup the source for the codestream
mInputp = new LLKDUMemSource(base.getData(), data_size);
}
if (mInputp)
{
mInputp->reset();
}
mCodeStreamp = new kdu_codestream;
mCodeStreamp->create(mInputp);
// Set the maximum number of bytes to use from the codestream
// *TODO: This seems to be wrong. The base class should have no idea of how j2c compression works so no
// good way of computing what's the byte range to be used.
mCodeStreamp->set_max_bytes(max_bytes,true);
// If you want to flip or rotate the image for some reason, change
// the resolution, or identify a restricted region of interest, this is
// the place to do it. You may use "kdu_codestream::change_appearance"
// and "kdu_codestream::apply_input_restrictions" for this purpose.
// If you wish to truncate the code-stream prior to decompression, you
// may use "kdu_codestream::set_max_bytes".
// If you wish to retain all compressed data so that the material
// can be decompressed multiple times, possibly with different appearance
// parameters, you should call "kdu_codestream::set_persistent" here.
// There are a variety of other features which must be enabled at
// this point if you want to take advantage of them. See the
// descriptions appearing with the "kdu_codestream" interface functions
// in "kdu_compressed.h" for an itemized account of these capabilities.
switch (mode)
{
case MODE_FAST:
mCodeStreamp->set_fast();
break;
case MODE_RESILIENT:
mCodeStreamp->set_resilient();
break;
case MODE_FUSSY:
mCodeStreamp->set_fussy();
break;
default:
llassert(0);
mCodeStreamp->set_fast();
}
kdu_dims dims;
mCodeStreamp->get_dims(0,dims);
S32 components = mCodeStreamp->get_num_components();
if (components >= 3)
{ // Check that components have consistent dimensions (for PPM file)
kdu_dims dims1; mCodeStreamp->get_dims(1,dims1);
kdu_dims dims2; mCodeStreamp->get_dims(2,dims2);
if ((dims1 != dims) || (dims2 != dims))
{
llerrs << "Components don't have matching dimensions!" << llendl;
}
}
// Get the number of resolution levels in that image
mLevels = mCodeStreamp->get_min_dwt_levels();
// Set the base dimensions
base.setSize(dims.size.x, dims.size.y, components);
base.setLevels(mLevels);
if (!keep_codestream)
{
mCodeStreamp->destroy();
delete mCodeStreamp;
mCodeStreamp = NULL;
delete mInputp;
//.........这里部分代码省略.........
示例3: mem_in
BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time, BOOL reversible)
{
// Declare and set simple arguments
bool transpose = false;
bool vflip = true;
bool hflip = false;
try
{
// Set up input image files
siz_params siz;
// Should set rate someplace here
LLKDUMemIn mem_in(raw_image.getData(),
raw_image.getDataSize(),
raw_image.getWidth(),
raw_image.getHeight(),
raw_image.getComponents(),
&siz);
base.setSize(raw_image.getWidth(), raw_image.getHeight(), raw_image.getComponents());
int num_components = raw_image.getComponents();
siz.set(Scomponents,0,0,num_components);
siz.set(Sdims,0,0,base.getHeight()); // Height of first image component
siz.set(Sdims,0,1,base.getWidth()); // Width of first image component
siz.set(Sprecision,0,0,8); // Image samples have original bit-depth of 8
siz.set(Ssigned,0,0,false); // Image samples are originally unsigned
kdu_params *siz_ref = &siz;
siz_ref->finalize();
siz_params transformed_siz; // Use this one to construct code-stream
transformed_siz.copy_from(&siz,-1,-1,-1,0,transpose,false,false);
// Construct the `kdu_codestream' object and parse all remaining arguments
U32 max_output_size = base.getWidth()*base.getHeight()*base.getComponents();
max_output_size = (max_output_size < 1000 ? 1000 : max_output_size);
U8 *output_buffer = new U8[max_output_size];
U32 output_size = 0; // Address updated by LLKDUMemTarget to give the final compressed buffer size
LLKDUMemTarget output(output_buffer, output_size, max_output_size);
kdu_codestream codestream;
codestream.create(&transformed_siz,&output);
if (comment_text)
{
// Set the comments for the codestream
kdu_codestream_comment comment = codestream.add_comment();
comment.put_text(comment_text);
}
if (num_components >= 3)
{
// Note that we always use YCC and not YUV
// *TODO: Verify this doesn't screws up reversible textures (like sculpties) as YCC is not reversible but YUV is...
set_default_colour_weights(codestream.access_siz());
}
// Set codestream options
int nb_layers = 0;
kdu_long layer_bytes[MAX_NB_LAYERS];
U32 max_bytes = (U32)(base.getWidth() * base.getHeight() * base.getComponents());
// Rate is the argument passed into the LLImageJ2C which specifies the target compression rate. The default is 8:1.
// *TODO: mRate is actually always 8:1 in the viewer. Test different values.
llassert (base.mRate > 0.f);
max_bytes = (U32)((F32)(max_bytes) * base.mRate);
// This code is where we specify the target number of bytes for each quality layer.
// We're using a logarithmic spacing rule that fits with our way of fetching texture data.
// Note: For more info on this layers business, read kdu_codestream::flush() doc in kdu_compressed.h
layer_bytes[nb_layers++] = FIRST_PACKET_SIZE;
U32 i = MIN_LAYER_SIZE;
while ((i < max_bytes) && (nb_layers < (MAX_NB_LAYERS-1)))
{
layer_bytes[nb_layers++] = i;
i *= 4;
}
// Note: for small images, we can have (max_bytes < FIRST_PACKET_SIZE), hence the test
if (layer_bytes[nb_layers-1] < max_bytes)
{
// Set the last quality layer so to fit the preset compression ratio
layer_bytes[nb_layers++] = max_bytes;
}
if (reversible)
{
// Use 0 for a last quality layer for reversible images so all remaining code blocks will be flushed
// Hack: KDU encoding for reversible images has a bug for small images that leads to j2c images that
// cannot be open or are very blurry. Avoiding that last layer prevents the problem to happen.
if ((base.getWidth() >= 32) || (base.getHeight() >= 32))
{
layer_bytes[nb_layers++] = 0;
}
codestream.access_siz()->parse_string("Creversible=yes");
// *TODO: we should use yuv in reversible mode
// Don't turn this on now though as it creates problems on decoding for the moment
//codestream.access_siz()->parse_string("Cycc=no");
}
//.........这里部分代码省略.........