Revision 701804

Go back to digest for 26th August 2007

Features in Graphics

Daniel M. Duley committed changes in /trunk/kdesupport/blitz:

More gradient work, mostly to support 8bpp grayscale gradients but some other cleanups as well.

Some of you are probably wondering why I'm spending effort on the gradient code now that Qt supports them. The most important reason is the unbalanced gradients. In this case "unbalanced" refers to the line of the gradient, not it's color transition, and can't be replicated with Qt gradients. For example, if you make a diagonal gradient with a positive unbalance factor it will appear to curve to the bottom-right. This can be used for emulating a shadow or highlight and other neat stuff. You can't do this with QLinearGradient, which will always draw the gradient on a line.

The other reason is also the reason for this commit. Some applications blend two images, or an image and a color, using a gradient. That's what most of those blend() methods in KImageEffect were for. Now you can get 8bpp grayscale gradients by calling grayGradient() or grayUnbalancedGradient() and use them for an image's alpha channel. These are drawn natively and don't create a 32bpp temporary image. This is far more efficent than what you would otherwise do with Qt.

The other reasons are minor. The gradients should be slightly faster but that really matters only if your doing something like using them as a background for a resizable widget and need to recalculate them often. Another reason is the oddball gradient types like Pyramid that some applications use, but probably can be depreciated. I'm not gonna suggest that, tho... I already unintentionally started one flamewar suggesting we depreciate things >:)

Anyways, this commit adds grayGradient() and grayUnbalancedGradient(), moves the gradients to their own source file to be better organized, and has a few minor cleanups.

File Changes

Added 1 files
  • /trunk/kdesupport/blitz/blitz/gradient.cpp
Modified 5 files
  • /trunk/kdesupport/blitz
  •   /blitz/blitz.cpp
  •   /blitz/blitz.h
  •   /blitz/CMakeLists.txt
  •   /test/mainwindow.cpp
  •   /test/mainwindow.h
6 files changed in total