mirror of
https://github.com/SatDump/SatDump
synced 2026-08-13 17:47:30 -04:00
J2K fixes
This commit is contained in:
parent
6268fc11ab
commit
4df3a270eb
1 changed files with 24 additions and 3 deletions
|
|
@ -21,6 +21,7 @@ namespace image
|
|||
OPJ_CODEC_FORMAT codec_format = OPJ_CODEC_J2K;
|
||||
|
||||
opj_set_default_encoder_parameters(¶meters);
|
||||
parameters.numresolution = 5;
|
||||
|
||||
{
|
||||
opj_image_cmptparm_t comp_params[4];
|
||||
|
|
@ -162,10 +163,30 @@ namespace image
|
|||
}
|
||||
|
||||
// Parse into image
|
||||
int depth = image->comps[0].prec;
|
||||
init(image->x1, image->y1, image->numcomps);
|
||||
for (int c = 0; c < d_channels; c++)
|
||||
for (int i = 0; i < int(image->x1 * image->y1); i++)
|
||||
channel(c)[i] = image->comps[c].data[i];
|
||||
|
||||
if (d_depth == 16)
|
||||
{
|
||||
for (int c = 0; c < d_channels; c++)
|
||||
for (int i = 0; i < int(image->x1 * image->y1); i++)
|
||||
channel(c)[i] = image->comps[c].data[i] << (16 - depth);
|
||||
}
|
||||
else if (d_depth == 8)
|
||||
{
|
||||
if (depth >= 8)
|
||||
{
|
||||
for (int c = 0; c < d_channels; c++)
|
||||
for (int i = 0; i < int(image->x1 * image->y1); i++)
|
||||
channel(c)[i] = image->comps[c].data[i] >> (depth - 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int c = 0; c < d_channels; c++)
|
||||
for (int i = 0; i < int(image->x1 * image->y1); i++)
|
||||
channel(c)[i] = image->comps[c].data[i] << (8 - depth);
|
||||
}
|
||||
}
|
||||
|
||||
// Free everything up
|
||||
opj_destroy_codec(l_codec);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue