开发者

Imageloader.save to ByteArrayOutputStream is painfully slow

开发者 https://www.devze.com 2023-02-08 15:38 出处:网络
Is there anyway to speed up SWT\'s imageLoader.save()-method? I have to compress raw ima开发者_StackOverflow中文版gedata into JPEG. It takes 130 - 250 ms to compress a 1680 x 1050 pixel large image.

Is there anyway to speed up SWT's imageLoader.save()-method? I have to compress raw ima开发者_StackOverflow中文版gedata into JPEG. It takes 130 - 250 ms to compress a 1680 x 1050 pixel large image.

I'm only benchmarking imageLoader.save(bos, SWT.IMAGE_JPEG);.

- Am i missing something?

- Is there another, faster way to compress large byte-Arrays / Images?

Any help would be appreciated


Are you initializing the ByteArrayOutputStream with the default constructor? The default size for the internal buffer is only 1024 bytes, so the object would be constantly adding new buffers each time you exceed its size. You should be able to come up with some basic upper limit on the image size and initialize the BAOS to that. This might reduce some of the wait time you are experiencing.

0

精彩评论

暂无评论...
验证码 换一张
取 消