Skip to content

Commit bbbba7d

Browse files
committed
Zoom OpenJpeg
1 parent bf3ed61 commit bbbba7d

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

IGNMap/Source/MainComponent.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,8 @@ void MainComponent::NewWindow()
793793
//==============================================================================
794794
void MainComponent::AboutIGNMap()
795795
{
796-
juce::String version = "0.0.5";
797-
juce::String info = "06/06/2024";
796+
juce::String version = "0.0.6";
797+
juce::String info = "25/06/2024";
798798
juce::String message = "IGNMap 3 Version : " + version + "\n" + info + "\n";
799799
message += "JUCE Version : " + juce::String(JUCE_MAJOR_VERSION) + "."
800800
+ juce::String(JUCE_MINOR_VERSION) + "." + juce::String(JUCE_BUILDNUMBER) + "\n";

IGNMap/Source/MapThread.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,9 @@ bool MapThread::DrawRasterClass(XGeoClass* C)
613613
continue;
614614
if (!m_Frame.Intersect(image->Frame()))
615615
continue;
616+
const juce::MessageManagerLock mml(Thread::getCurrentThread());
617+
if (!mml.lockWasGained()) // if something is trying to kill this job, the lock
618+
continue;
616619
GeoFileImage* fileImage = dynamic_cast<GeoFileImage*>(image);
617620
if (fileImage != nullptr)
618621
flag |= DrawFileRaster(fileImage);

XToolImage/XOpenJp2Image.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@
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

Comments
 (0)