Skip to content

Commit

Permalink
Fixed bug when images is smaller than 64x64.
Browse files Browse the repository at this point in the history
Now we compute the proper number of resolution levels to use when
an images has size smaller than 64x64 pixels.

Change-Id: I27b4d784c4416b88a8536eff44b285b3b9b2fdd6
  • Loading branch information
Luis Ibanez committed Oct 4, 2010
1 parent adbdd17 commit f7480d2
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 f7480d2

Please sign in to comment.