Krita and scaling

Michael Thaler michael.thaler at ph.tum.de
Thu Aug 19 23:27:57 CEST 2004


Hi,

o.k., I cleaned up the code a little bit. It is stil far from perfect, but I 
will not have access to my computer at the weekend, so I post the patch now.

TODO:
- replace calloc and free by new and delete.
- check if memory allocations fail and free the resources if they fail.
- replace the structs CONTRIB and CLIST by some STL or Qt container.
- mode the code to a visitor class.
- Add progressinfo
- Add a widget to the scale dialog to chose a scaling filter (the code is 
actually there, right now it can only be changed in the source)
- There is still a bug. The rightmost pixels in the scaled image are wrong. 
Actually it is not really a bug in the scaling code, if you draw a one pixel 
line at the rightmost edge of the image and scale it, the line is still 
there, there is just an addition line right of it. So the image is not scaled 
to the actual target width
- use iterators to access pixels.

How is memory handling done in Krita? Actually I have to allocate a temporary 
area which holds the pixel data for one column and I have to allocate memory 
for some container classes which hold temporary data. And then I have to 
allocate memory for the destination image. What should be done if we run out 
of memory? How can we make sure that all memory the scaling code allocated, 
is freed correctly?

I think it would be a good idea to use smart pointers to allocate at least the 
structs (or containers that will replace it). If I understand correctly, they 
are freed automatically, if we leave the scaling code? Can someone implement 
this? (I have no clue how smart pointers work and how they are used).

I tested the code and I think it works as well as the Gimp scaling code (I 
tested the Mitchell filter, it is the bicubic one).

I attached the diff, so have fun with it

Greetings,
Michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mydiff
Type: text/x-diff
Size: 17475 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kimageshop/attachments/20040819/45310ac1/mydiff-0001.bin


More information about the kimageshop mailing list