Skip to content

Commit

Permalink
Merge topic 'openjpegtest005bug'
Browse files Browse the repository at this point in the history
f7480d2 Fixed bug when images is smaller than 64x64.
  • Loading branch information
Luis Ibanez authored and kwrobot committed Oct 4, 2010
2 parents adbdd17 + f7480d2 commit 0eff1ec
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Code/Review/itkJPEG2000ImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,30 @@ ::Write(const void *buffer)
w = this->m_Dimensions[0];
h = this->m_Dimensions[1];


// Compute the proper number of resolutions to use.
// This is mostly done for images smaller than 64 pixels
// along any dimension.
unsigned int numberOfResolutions = 0;

int tw = w >> 1;
int th = h >> 1;

while( tw && th )
{
numberOfResolutions++;
tw >>= 1;
th >>= 1;
}

// Clamp the number of resolutions to 6.
if( numberOfResolutions > 6 )
{
numberOfResolutions = 6;
}

parameters.numresolution = numberOfResolutions;

OPJ_COLOR_SPACE color_space = CLRSPC_GRAY;
opj_image_cmptparm_t cmptparm[3];

Expand Down

0 comments on commit 0eff1ec

Please sign in to comment.