summaryrefslogtreecommitdiff
path: root/OPJViewer/source/imagmj2.cpp
diff options
context:
space:
mode:
authorGiuseppe Baruffa <gbaruffa@users.noreply.github.com>2007-06-03 17:34:46 +0000
committerGiuseppe Baruffa <gbaruffa@users.noreply.github.com>2007-06-03 17:34:46 +0000
commitadc1aacb600419d6ce8427d652da4f53efc5e408 (patch)
treee7fc5870fb2cc0e6b9c37e7fb1a9e7c7f68b9e35 /OPJViewer/source/imagmj2.cpp
parent814bab690015913c4cad6b713871296e29205272 (diff)
OPJViewer opens now BMP, PNG, GIF, PNM, TIFF (with wxWidgets internals); added an encoder settings tab, for future integration with "save file as..." in JPEG 2000 format
Diffstat (limited to 'OPJViewer/source/imagmj2.cpp')
-rw-r--r--OPJViewer/source/imagmj2.cpp79
1 files changed, 19 insertions, 60 deletions
diff --git a/OPJViewer/source/imagmj2.cpp b/OPJViewer/source/imagmj2.cpp
index ad637aab..e0fa2d4e 100644
--- a/OPJViewer/source/imagmj2.cpp
+++ b/OPJViewer/source/imagmj2.cpp
@@ -89,27 +89,41 @@ void mj2_error_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
- wxMutexGuiEnter();
+#ifndef __WXGTK__
+ wxMutexGuiEnter();
+#endif /* __WXGTK__ */
wxLogMessage(wxT("[ERROR] %.*s"), message_len, msg);
+#ifndef __WXGTK__
wxMutexGuiLeave();
+#endif /* __WXGTK__ */
}
+
/* sample warning callback expecting a FILE* client object */
void mj2_warning_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
- wxMutexGuiEnter();
+#ifndef __WXGTK__
+ wxMutexGuiEnter();
+#endif /* __WXGTK__ */
wxLogMessage(wxT("[WARNING] %.*s"), message_len, msg);
+#ifndef __WXGTK__
wxMutexGuiLeave();
+#endif /* __WXGTK__ */
}
+
/* sample debug callback expecting no client object */
void mj2_info_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
- wxMutexGuiEnter();
+#ifndef __WXGTK__
+ wxMutexGuiEnter();
+#endif /* __WXGTK__ */
wxLogMessage(wxT("[INFO] %.*s"), message_len, msg);
+#ifndef __WXGTK__
wxMutexGuiLeave();
+#endif /* __WXGTK__ */
}
/* macro functions */
@@ -691,63 +705,8 @@ bool wxMJ2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
/* close the byte stream */
opj_cio_close(cio);
- // check image size
- if ((opjimage->numcomps != 1) && (opjimage->numcomps != 3)) {
- wxMutexGuiEnter();
- wxLogError(wxT("MJ2: weird number of components"));
- wxMutexGuiLeave();
- opj_destroy_decompress(dinfo);
- free(src);
- return false;
- }
-
- // prepare image size
- image->Create(opjimage->comps[0].w, opjimage->comps[0].h, true );
-
- // access image raw data
- image->SetMask( false );
- ptr = image->GetData();
-
- // RGB color picture
- // does not handle comps. subsampling,
- // so simply render the first component
- if (opjimage->numcomps == 3) {
- int row, col;
- int *r = opjimage->comps[0].data;
- /*
- int *g = opjimage->comps[1].data;
- int *b = opjimage->comps[2].data;
- */
- for (row = 0; row < opjimage->comps[0].h; row++) {
- for (col = 0; col < opjimage->comps[0].w; col++) {
-
- /*
- *(ptr++) = *(r++);
- *(ptr++) = *(g++);
- *(ptr++) = *(b++);
- */
- *(ptr++) = *(r);
- *(ptr++) = *(r);
- *(ptr++) = *(r++);
-
- }
- }
- }
-
- // B/W picture
- if (opjimage->numcomps == 1) {
- int row, col;
- int *y = opjimage->comps[0].data;
- for (row = 0; row < opjimage->comps[0].h; row++) {
- for (col = 0; col < opjimage->comps[0].w; col++) {
-
- *(ptr++) = *(y);
- *(ptr++) = *(y);
- *(ptr++) = *(y++);
-
- }
- }
- }
+ /* common rendering method */
+#include "imagjpeg2000.cpp"
wxMutexGuiEnter();
wxLogMessage(wxT("MJ2: image loaded."));