TDE base libraries and programs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5 KiB

  1. /* vi: ts=8 sts=4 sw=4
  2. * kate: space-indent on; tab-width 8; indent-width 4; indent-mode cstyle;
  3. *
  4. * This file is part of the KDE project, module kdesktop.
  5. * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org>
  6. *
  7. * You can Freely distribute this program under the GNU General Public
  8. * License. See the file "COPYING" for the exact licensing terms.
  9. */
  10. #ifndef __CROSSFADE_H__
  11. #define __CROSSFADE_H__
  12. #include <tqtimer.h>
  13. #include <tqpainter.h>
  14. #include <tqpixmap.h>
  15. #include <X11/X.h>
  16. #include <X11/Xlib.h>
  17. #include <X11/Xatom.h>
  18. #include <X11/extensions/Xrender.h>
  19. #include <kdebug.h>
  20. #include <unistd.h>
  21. inline TQPixmap crossFade(const TQPixmap &pix1, const TQPixmap &pix2, double r_alpha,
  22. bool sync = false){
  23. TQPixmap pix = TQPixmap(1,1,8);
  24. int mw,mh;
  25. mw = pix1.width();
  26. mh = pix1.height();
  27. short unsigned int alpha = 0xffff * (1-r_alpha);
  28. XRenderColor clr = { 0, 0, 0, alpha };
  29. XRenderPictureAttributes pa;
  30. pa.repeat = True;
  31. Picture pic = XRenderCreatePicture(pix.x11Display(), pix.handle(),
  32. XRenderFindStandardFormat (pix.x11Display(), PictStandardA8),
  33. CPRepeat, &pa);
  34. XRenderFillRectangle(pix.x11Display(), PictOpSrc, pic,
  35. &clr, 0, 0, 1, 1);
  36. TQPixmap dst(pix1);
  37. dst.detach();
  38. XRenderComposite(pix.x11Display(), PictOpOver, pix2.x11RenderHandle(),
  39. pic, dst.x11RenderHandle(),0,0, 0,0, 0,0, mw,mh);
  40. if (sync) {
  41. XSync(pix.x11Display(), false);
  42. }
  43. XRenderFreePicture(pix.x11Display(), pic);
  44. return dst;
  45. }
  46. #endif // __CROSSFADE_H__