2121// -----------------------------------------------------------------------------
2222
2323// sample error callback expecting a FILE* client object
24- static void error_callback (const char * msg, void * client_data)
24+ static void error_callback (const char * /* msg*/ , void * client_data)
2525{
2626 (void )client_data;
2727 // fprintf(stdout, "[ERROR] %s", msg);
2828}
2929// sample warning callback expecting a FILE* client object
30- static void warning_callback (const char * msg, void * client_data)
30+ static void warning_callback (const char * /* msg*/ , void * client_data)
3131{
3232 (void )client_data;
3333 // fprintf(stdout, "[WARNING] %s", msg);
3434}
3535// sample debug callback expecting no client object
36- static void info_callback (const char * msg, void * client_data)
36+ static void info_callback (const char * /* msg*/ , void * client_data)
3737{
3838 (void )client_data;
3939 // fprintf(stdout, "[INFO] %s", msg);
@@ -53,8 +53,8 @@ XOpenJp2Image::XOpenJp2Image(const char* filename)
5353 m_nW = m_Image->x1 - m_Image->x0 ;
5454 m_nH = m_Image->y1 - m_Image->y0 ;
5555
56- m_nNbSample = m_Image->numcomps ;
57- m_nNbBits = m_Image->comps [0 ].prec ;
56+ m_nNbSample = ( uint16_t ) m_Image->numcomps ;
57+ m_nNbBits = ( uint16_t ) m_Image->comps [0 ].prec ;
5858 if ((m_nNbBits > 8 ) && (m_nNbBits <= 16 ))
5959 m_nNbBits = 16 ;
6060
@@ -133,7 +133,7 @@ bool XOpenJp2Image::CreateCodec()
133133// -----------------------------------------------------------------------------
134134// Lecture d'une region
135135// -----------------------------------------------------------------------------
136- bool XOpenJp2Image::GetArea (XFile* file , uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t * area)
136+ bool XOpenJp2Image::GetArea (XFile* , uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t * area)
137137{
138138 if (!m_bValid)
139139 return false ;
@@ -164,7 +164,7 @@ bool XOpenJp2Image::GetArea(XFile* file, uint32_t x, uint32_t y, uint32_t w, uin
164164// -----------------------------------------------------------------------------
165165// Recuperation d'une zone de pixels avec zoom arriere
166166// -----------------------------------------------------------------------------
167- bool XOpenJp2Image::GetZoomArea (XFile* file , uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t * area, uint32_t factor)
167+ bool XOpenJp2Image::GetZoomArea (XFile* , uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t * area, uint32_t factor)
168168{
169169 if (!m_bValid)
170170 return false ;
@@ -185,7 +185,13 @@ bool XOpenJp2Image::GetZoomArea(XFile* file, uint32_t x, uint32_t y, uint32_t w,
185185 if (!CreateCodec ())
186186 return false ;
187187
188- if (!opj_set_decoded_resolution_factor (m_Codec, opj_factor))
188+ bool flag = false ;
189+ for (uint32_t i = 0 ; i < opj_factor; i++) {
190+ flag = opj_set_decoded_resolution_factor (m_Codec, opj_factor);
191+ if (flag) break ;// Le niveau de zoom existe bien
192+ opj_factor -= 1 ;
193+ }
194+ if (!flag)
189195 return false ;
190196 if (!opj_set_decode_area (m_Codec, m_Image, x, y, x + maxW, y + maxH))
191197 return false ;
0 commit comments