2003/12/13 08:13:34
[org.ibex.core.git] / src / org / xwt / plat / GCJ.cc
index 474e640..a70c952 100644 (file)
@@ -98,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);
@@ -123,7 +120,7 @@ org::xwt::Picture* org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, j
         (jerr.pub.format_message)((j_common_ptr)&cinfo, msgbuf);
         Log::log(&GCJ::class$,JvNewStringLatin1(msgbuf));
         jpeg_destroy_decompress(&cinfo);
-        return 0;
+        return;
     }
   
     jpeg_create_decompress(&cinfo);
@@ -135,9 +132,9 @@ 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(width * height);
     
     while (cinfo.output_scanline < cinfo.output_height) {
         JSAMPLE *dest = (JSAMPLE*) (elements(data) + cinfo.output_scanline * width);
@@ -148,8 +145,6 @@ org::xwt::Picture* org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, j
     
     for(int i=0;i<data->length;i++)
         elements(data)[i] |= 0xff000000; // alpha channel
-    
-    return org::xwt::Platform::createPicture(data, width, height);
 }
 
 // C++ new/delete operators (JvMalloc never fails)