Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

RREEncoder.cxx 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/OutStream.h>
  19. #include <rfb/encodings.h>
  20. #include <rfb/SMsgWriter.h>
  21. #include <rfb/SConnection.h>
  22. #include <rfb/PixelFormat.h>
  23. #include <rfb/PixelBuffer.h>
  24. #include <rfb/RREEncoder.h>
  25. using namespace rfb;
  26. #define BPP 8
  27. #include <rfb/rreEncode.h>
  28. #undef BPP
  29. #define BPP 16
  30. #include <rfb/rreEncode.h>
  31. #undef BPP
  32. #define BPP 32
  33. #include <rfb/rreEncode.h>
  34. #undef BPP
  35. RREEncoder::RREEncoder(SConnection* conn) : RawEncoder(conn)
  36. {
  37. }
  38. RREEncoder::~RREEncoder()
  39. {
  40. }
  41. void RREEncoder::writeRect(const Rect& r, PixelBuffer* pb)
  42. {
  43. int w = r.width();
  44. int h = r.height();
  45. rdr::U8* imageBuf = conn->writer()->getImageBuf(w*h);
  46. pb->getImage(conn->cp.pf(), imageBuf, r);
  47. mos.clear();
  48. int nSubrects = -1;
  49. switch (conn->cp.pf().bpp) {
  50. case 8: nSubrects = rreEncode8(imageBuf, w, h, &mos); break;
  51. case 16: nSubrects = rreEncode16(imageBuf, w, h, &mos); break;
  52. case 32: nSubrects = rreEncode32(imageBuf, w, h, &mos); break;
  53. }
  54. if (nSubrects < 0) {
  55. RawEncoder::writeRect(r, pb);
  56. return;
  57. }
  58. conn->writer()->startRect(r, encodingRRE);
  59. rdr::OutStream* os = conn->getOutStream();
  60. os->writeU32(nSubrects);
  61. os->writeBytes(mos.data(), mos.length());
  62. conn->writer()->endRect();
  63. }