Skip to content

Commit

Permalink
Zoom OpenJpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
fbecir committed Jun 25, 2024
1 parent bf3ed61 commit bbbba7d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions IGNMap/Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,8 @@ void MainComponent::NewWindow()
//==============================================================================
void MainComponent::AboutIGNMap()
{
juce::String version = "0.0.5";
juce::String info = "06/06/2024";
juce::String version = "0.0.6";
juce::String info = "25/06/2024";
juce::String message = "IGNMap 3 Version : " + version + "\n" + info + "\n";
message += "JUCE Version : " + juce::String(JUCE_MAJOR_VERSION) + "."
+ juce::String(JUCE_MINOR_VERSION) + "." + juce::String(JUCE_BUILDNUMBER) + "\n";
Expand Down
3 changes: 3 additions & 0 deletions IGNMap/Source/MapThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,9 @@ bool MapThread::DrawRasterClass(XGeoClass* C)
continue;
if (!m_Frame.Intersect(image->Frame()))
continue;
const juce::MessageManagerLock mml(Thread::getCurrentThread());
if (!mml.lockWasGained()) // if something is trying to kill this job, the lock
continue;
GeoFileImage* fileImage = dynamic_cast<GeoFileImage*>(image);
if (fileImage != nullptr)
flag |= DrawFileRaster(fileImage);
Expand Down
22 changes: 14 additions & 8 deletions XToolImage/XOpenJp2Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
//-----------------------------------------------------------------------------

// sample error callback expecting a FILE* client object
static void error_callback(const char* msg, void* client_data)
static void error_callback(const char* /*msg*/, void* client_data)
{
(void)client_data;
//fprintf(stdout, "[ERROR] %s", msg);
}
// sample warning callback expecting a FILE* client object
static void warning_callback(const char* msg, void* client_data)
static void warning_callback(const char* /*msg*/, void* client_data)
{
(void)client_data;
//fprintf(stdout, "[WARNING] %s", msg);
}
// sample debug callback expecting no client object
static void info_callback(const char* msg, void* client_data)
static void info_callback(const char* /*msg*/, void* client_data)
{
(void)client_data;
//fprintf(stdout, "[INFO] %s", msg);
Expand All @@ -53,8 +53,8 @@ XOpenJp2Image::XOpenJp2Image(const char* filename)
m_nW = m_Image->x1 - m_Image->x0;
m_nH = m_Image->y1 - m_Image->y0;

m_nNbSample = m_Image->numcomps;
m_nNbBits = m_Image->comps[0].prec;
m_nNbSample = (uint16_t)m_Image->numcomps;
m_nNbBits = (uint16_t)m_Image->comps[0].prec;
if ((m_nNbBits > 8) && (m_nNbBits <= 16))
m_nNbBits = 16;

Expand Down Expand Up @@ -133,7 +133,7 @@ bool XOpenJp2Image::CreateCodec()
//-----------------------------------------------------------------------------
// Lecture d'une region
//-----------------------------------------------------------------------------
bool XOpenJp2Image::GetArea(XFile* file, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t* area)
bool XOpenJp2Image::GetArea(XFile* , uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t* area)
{
if (!m_bValid)
return false;
Expand Down Expand Up @@ -164,7 +164,7 @@ bool XOpenJp2Image::GetArea(XFile* file, uint32_t x, uint32_t y, uint32_t w, uin
//-----------------------------------------------------------------------------
// Recuperation d'une zone de pixels avec zoom arriere
//-----------------------------------------------------------------------------
bool XOpenJp2Image::GetZoomArea(XFile* file, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t* area, uint32_t factor)
bool XOpenJp2Image::GetZoomArea(XFile* , uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t* area, uint32_t factor)
{
if (!m_bValid)
return false;
Expand All @@ -185,7 +185,13 @@ bool XOpenJp2Image::GetZoomArea(XFile* file, uint32_t x, uint32_t y, uint32_t w,
if (!CreateCodec())
return false;

if (!opj_set_decoded_resolution_factor(m_Codec, opj_factor))
bool flag = false;
for (uint32_t i = 0; i < opj_factor; i++) {
flag = opj_set_decoded_resolution_factor(m_Codec, opj_factor);
if (flag) break;// Le niveau de zoom existe bien
opj_factor -= 1;
}
if (!flag)
return false;
if (!opj_set_decode_area(m_Codec, m_Image, x, y, x + maxW, y + maxH))
return false;
Expand Down

0 comments on commit bbbba7d

Please sign in to comment.