2004/01/12 06:38:31
[org.ibex.core.git] / src / org / xwt / plat / GCJ.cc
index 4fe25f1..b140c60 100644 (file)
@@ -23,6 +23,7 @@ extern "C" {
 #include <org/xwt/plat/GCJ.h>
 #include <org/xwt/util/Log.h>
 
+#define TRUE 1
 using org::xwt::util::Log;
 
 #define TRUE 1
@@ -97,13 +98,10 @@ void skip_input_data (j_decompress_ptr cinfo, long num_bytes) {
     src->pub.bytes_in_buffer -= num_bytes;
 }
 
-org::xwt::Picture* org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, jstring name) {
+void org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, org::xwt::Picture* p) {
     struct jpeg_decompress_struct cinfo;
     my_error_mgr_t jerr;
     my_source_mgr_t src;
-    jintArray data;
-    jint width;
-    jint height;
     
     src.is = is;
     src.buf = JvNewByteArray(16384);
@@ -120,9 +118,9 @@ org::xwt::Picture* org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, j
         // FEATURE - we should handle errors better than this
         char msgbuf[JMSG_LENGTH_MAX];
         (jerr.pub.format_message)((j_common_ptr)&cinfo, msgbuf);
-        Log::log(&GCJ::class$,JvNewStringLatin1(msgbuf));
+        Log::info(&GCJ::class$,JvNewStringLatin1(msgbuf));
         jpeg_destroy_decompress(&cinfo);
-        return 0;
+        return;
     }
   
     jpeg_create_decompress(&cinfo);
@@ -134,21 +132,19 @@ org::xwt::Picture* org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, j
     jpeg_read_header(&cinfo,TRUE);
     jpeg_start_decompress(&cinfo);
     
-    width = cinfo.output_width;
-    height = cinfo.output_height;
-    data = JvNewIntArray(width * height);
+    p->width = cinfo.output_width;
+    p->height = cinfo.output_height;
+    p->data = JvNewIntArray(p->width * p->height);
     
     while (cinfo.output_scanline < cinfo.output_height) {
-        JSAMPLE *dest = (JSAMPLE*) (elements(data) + cinfo.output_scanline * width);
+        JSAMPLE *dest = (JSAMPLE*) (elements(p->data) + cinfo.output_scanline * p->width);
         jpeg_read_scanlines(&cinfo,&dest,1);
     }
     jpeg_finish_decompress(&cinfo);
     jpeg_destroy_decompress(&cinfo);
     
-    for(int i=0;i<data->length;i++)
-        elements(data)[i] |= 0xff000000; // alpha channel
-    
-    return org::xwt::Platform::createPicture(data, width, height);
+    for(int i=0;i<p->data->length;i++)
+        elements(p->data)[i] |= 0xff000000; // alpha channel
 }
 
 // C++ new/delete operators (JvMalloc never fails)