christian
christian

Reputation: 401

Imageloader.save to ByteArrayOutputStream is painfully slow

Is there anyway to speed up SWT's imageLoader.save()-method? I have to compress raw imagedata 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

Upvotes: 0

Views: 534

Answers (1)

jt.
jt.

Reputation: 7705

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.

Upvotes: 2

Related Questions