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.

FLTKPixelBuffer.cxx 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Copyright 2011-2014 Pierre Ossman for Cendio AB
  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 <FL/fl_draw.H>
  19. #include <rfb/Exception.h>
  20. #include "i18n.h"
  21. #include "FLTKPixelBuffer.h"
  22. FLTKPixelBuffer::FLTKPixelBuffer(int width, int height) :
  23. PlatformPixelBuffer(rfb::PixelFormat(32, 24, false, true,
  24. 255, 255, 255, 0, 8, 16),
  25. width, height, NULL, width)
  26. {
  27. data = new rdr::U8[width * height * format.bpp/8];
  28. if (data == NULL)
  29. throw rfb::Exception(_("Not enough memory for framebuffer"));
  30. }
  31. FLTKPixelBuffer::~FLTKPixelBuffer()
  32. {
  33. delete [] data;
  34. }
  35. void FLTKPixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h)
  36. {
  37. int pixel_bytes, stride_bytes;
  38. const uchar *buf_start;
  39. pixel_bytes = format.bpp/8;
  40. stride_bytes = pixel_bytes * stride;
  41. buf_start = data +
  42. pixel_bytes * src_x +
  43. stride_bytes * src_y;
  44. fl_draw_image(buf_start, x, y, w, h, pixel_bytes, stride_bytes);
  45. }