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.

RREDecoder.cxx 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #include <rdr/InStream.h>
  19. #include <rdr/MemInStream.h>
  20. #include <rdr/OutStream.h>
  21. #include <rfb/ServerParams.h>
  22. #include <rfb/PixelBuffer.h>
  23. #include <rfb/RREDecoder.h>
  24. using namespace rfb;
  25. #define BPP 8
  26. #include <rfb/rreDecode.h>
  27. #undef BPP
  28. #define BPP 16
  29. #include <rfb/rreDecode.h>
  30. #undef BPP
  31. #define BPP 32
  32. #include <rfb/rreDecode.h>
  33. #undef BPP
  34. RREDecoder::RREDecoder() : Decoder(DecoderPlain)
  35. {
  36. }
  37. RREDecoder::~RREDecoder()
  38. {
  39. }
  40. void RREDecoder::readRect(const Rect& r, rdr::InStream* is,
  41. const ServerParams& server, rdr::OutStream* os)
  42. {
  43. rdr::U32 numRects;
  44. numRects = is->readU32();
  45. os->writeU32(numRects);
  46. os->copyBytes(is, server.pf().bpp/8 + numRects * (server.pf().bpp/8 + 8));
  47. }
  48. void RREDecoder::decodeRect(const Rect& r, const void* buffer,
  49. size_t buflen, const ServerParams& server,
  50. ModifiablePixelBuffer* pb)
  51. {
  52. rdr::MemInStream is(buffer, buflen);
  53. const PixelFormat& pf = server.pf();
  54. switch (pf.bpp) {
  55. case 8: rreDecode8 (r, &is, pf, pb); break;
  56. case 16: rreDecode16(r, &is, pf, pb); break;
  57. case 32: rreDecode32(r, &is, pf, pb); break;
  58. }
  59. }