Pictures in your KOffice apps

Having a picture in your text document is one of the simplest things you should expect a word processor to do. Having good looking images in your presentations, same thing. You should expect that to just work.
The fun begins when you take a look at that "just works" means. For instance, I can have a 1000 page document with one or more photos on each page. Those photos easilly take some 10Mb in memory if they are meant for printing. So obviously the simple solution of just having QImage objects is out.
Another problem that we see is when a user inserts a photo from his camera into the KPresenter presentation. Then scales it down to only be half the screen width. This means that we'll effectively be showing the picture at some 15% of its original size. If we want to keep the viewing and moving of things around very nice and snappy, we can't just scale the image on every repaint, that would be way to slow.

After a couple of weeks of coding we have a quite nice solution in KOffice. I added a KoImageData class which stores the actual image data and is able to dynamically create a scaled down version of that. The actual data we store is in many cases stored in a temporary file on the filesystem and transparently loaded when needed.
This has the directly noticeable effect that if you load a document with loads of images it will be much faster done, and with less memory used. The KOffice applications will no longer parse the image data on load. That will happen later.

My personal usecase is this; I would love to make a collage of loads of pictures of my friends and holidays. And I'd like to do that digitally. Now, when I create a new document in Krita or the Gimp that is full printing resolution of an A4. Then start loading the pictures as layers, it very quickly makes them crash or just get unusably slow.
My ideal solution is that I just start a KWord document where I insert a lot of these images into and I can scale, rotate and move them around very quickly. With hardly any suggestion that I'm manipulating huge amounts of data.
At printing time I'm printing actually to high-resolution images and the resulting PDF can be shown to the printer whom can print it at wanted resolution.
Expect this work work just fine in KOffice2.1 :)

Likely I won't make my second favorite feature for 2.1, this is to allow me to select an image and monitor it. So if I have an image in my KWord document that is using a file in my homedir called "photo.jpg" I can start my favorite application and change the image to be, for example, more saturated. On saving the image KWord would automatically show the updated image. Should be easy enough to add ;)

Blog Topics: