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.

rreDecode.h 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. //
  19. // RRE decoding function.
  20. //
  21. // This file is #included after having set the following macro:
  22. // BPP - 8, 16 or 32
  23. #include <rdr/InStream.h>
  24. namespace rfb {
  25. // CONCAT2E concatenates its arguments, expanding them if they are macros
  26. #ifndef CONCAT2E
  27. #define CONCAT2(a,b) a##b
  28. #define CONCAT2E(a,b) CONCAT2(a,b)
  29. #endif
  30. #define PIXEL_T rdr::CONCAT2E(U,BPP)
  31. #define READ_PIXEL CONCAT2E(readOpaque,BPP)
  32. #define RRE_DECODE CONCAT2E(rreDecode,BPP)
  33. void RRE_DECODE (const Rect& r, rdr::InStream* is,
  34. const PixelFormat& pf, ModifiablePixelBuffer* pb)
  35. {
  36. int nSubrects = is->readU32();
  37. PIXEL_T bg = is->READ_PIXEL();
  38. pb->fillRect(pf, r, bg);
  39. for (int i = 0; i < nSubrects; i++) {
  40. PIXEL_T pix = is->READ_PIXEL();
  41. int x = is->readU16();
  42. int y = is->readU16();
  43. int w = is->readU16();
  44. int h = is->readU16();
  45. pb->fillRect(pf, Rect(r.tl.x+x, r.tl.y+y, r.tl.x+x+w, r.tl.y+y+h), pix);
  46. }
  47. }
  48. #undef PIXEL_T
  49. #undef READ_PIXEL
  50. #undef RRE_DECODE
  51. }