[Kde-games-devel] SVG and MainWindow resize handling

Mauricio Piacentini piacentini at kde.org
Sat Jan 19 23:15:52 CET 2008


Andreas Pakulat wrote:
> I highly suspect this last one, as QPixmap doesn't let you specify the
> format of the image wrt. alpha channels.

Cool, probably the reason why it was not used in my tests, as mahjongg 
tilefaces and other elements (runners) need to have an alpha to be 
composed properly.

> However, the cardcache I've written on top of KPixmapCache still renders
> svg's itself (because KPixmapCache has no way of defining the element in
> the svg when letting it load the svg) and thus still uses a QImage as
> "first" image source. The same happens for pngs, which are read into a
> QImage and that one is then transformed to fit the requested size. Only
> after that the image is converted into a pixmap and stored in the cache.

Similar to what is implemented (in a very simple manner) in 
libkmahjongg. We render the pixmap, and store it in cache with a name 
that is something like theme_elementid_width_height. When I want an 
element, I try to get it from the cache. If it is not there, then render 
and store. See the tileset or background class for the methods.

> OMG, I really need to stop being sucked into all kinds of things :) As I
> said, I'll try to add the pixmap caching to kpat tomorrow and see
> wether/how that improves speed at startup, changing decks and resizing.

IMO KPat is the game that experimented with caching earlier, so it maybe 
has not benefited as much from what we learned, and changes in kdelibs 
and Qt. It is our most important/popular game as well, so any 
improvement you can make to it is a huge bonus to the module.

> Next time I'll leave the question innocent as it was, before I added the
> rest of the paragraph :)

Sorry for the outbreak, it was out of line. Apologies.

Regards,
Mauricio Piacentini


More information about the kde-games-devel mailing list