#include <org/xwt/plat/GCJ.h>
#include <org/xwt/util/Log.h>
+#define TRUE 1
using org::xwt::util::Log;
+#define TRUE 1
+
// builtin.xwar /////////////////////////////////////////////////////////
extern unsigned char builtin_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);
// 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);
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)