Henrik Guschov
Henrik Guschov

Reputation: 327

Loading images (graphics) with VisualWorks very slow

I am trying to load image files like jpeg into vw as part of an application. This seems to take very long and sometimes even crashes vw. The image has roughly 3.5MB and is a simple jpeg picture. This is what causes the problem:

ImageReader fromFile:'pic.jpg'.

This operation takes about 5-10 seconds to complete. It happens in both 32 and 64 bit projects alike.

Any ideas or suggestions as to how I can solve this problem? Same thing in pharo seems to work okay.

Thanks!

Upvotes: 1

Views: 239

Answers (2)

Karsten
Karsten

Reputation: 2423

ImageReader will automatically choose the correct subclass, like JPEGImageReader. Picking the subclass is not the slow part; decoding the JPG data is.

A jpeg file, unlike PNG doesn't use zip compression but instead uses discrete-cosine-transforms (see https://en.wikipedia.org/wiki/JPG#JPEG_compression). This compression requires a lot of number crunching, which is slower in VisualWorks than it would be in C. The PNG reader on the other hand uses Zlib to have the number-crunching part done in C, which is why it is so much faster.

You could use Cairo or GDI or whatever other C-API you have at hand to speed this up.

Upvotes: 1

David Buck
David Buck

Reputation: 2847

Try calling the JPEGImageReader directly:

JPEGImageReader fromFile:'pic.jpg'

If that's fast, then the slowdown is in finding the proper image reader to use for the file. What ImageReaders do you have installed and how do they implement the class method canRead:?

If the JPEGImageReader is still slow, then we can investigate from there.

Upvotes: 0

Related Questions