image.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* SLiM - Simple Login Manager
  2. Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
  3. Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. The following code has been adapted and extended from
  9. xplanet 1.0.1, Copyright (C) 2002-04 Hari Nair <hari@alumni.caltech.edu>
  10. */
  11. #ifndef _IMAGE_H_
  12. #define _IMAGE_H_
  13. #include <X11/Xlib.h>
  14. #include <X11/Xmu/WinUtil.h>
  15. class Image {
  16. public:
  17. Image();
  18. Image(const int w, const int h, const unsigned char *rgb,
  19. const unsigned char *alpha);
  20. ~Image();
  21. const unsigned char * getPNGAlpha() const {
  22. return(png_alpha);
  23. };
  24. const unsigned char * getRGBData() const {
  25. return(rgb_data);
  26. };
  27. void getPixel(double px, double py, unsigned char *pixel);
  28. void getPixel(double px, double py, unsigned char *pixel,
  29. unsigned char *alpha);
  30. int Width() const {
  31. return(width);
  32. };
  33. int Height() const {
  34. return(height);
  35. };
  36. void Quality(const int q) {
  37. quality_ = q;
  38. };
  39. bool Read(const char *filename);
  40. void Reduce(const int factor);
  41. void Resize(const int w, const int h);
  42. void Merge(Image* background, const int x, const int y);
  43. void Crop(const int x, const int y, const int w, const int h);
  44. void Tile(const int w, const int h);
  45. void Center(const int w, const int h, const char *hex);
  46. void Plain(const int w, const int h, const char *hex);
  47. void computeShift(unsigned long mask, unsigned char &left_shift,
  48. unsigned char &right_shift);
  49. Pixmap createPixmap(Display* dpy, int scr, Window win);
  50. private:
  51. int width, height, area;
  52. unsigned char *rgb_data;
  53. unsigned char *png_alpha;
  54. int quality_;
  55. };
  56. #endif