pixel_buffer.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Flexlay - A Generic 2D Game Editor
  2. // Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
  3. //
  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 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #ifndef HEADER_PIXEL_BUFFER_HPP
  17. #define HEADER_PIXEL_BUFFER_HPP
  18. #include <memory>
  19. #include <string>
  20. class PixelBufferImpl;
  21. class QImage;
  22. class PixelBuffer
  23. {
  24. public:
  25. static PixelBuffer from_file(const std::string& filename);
  26. public:
  27. PixelBuffer();
  28. PixelBuffer(int width, int height);
  29. #ifdef GRUMBEL
  30. CL_PixelFormat get_format() const { return m_pixelbuffer.get_format(); }
  31. CL_Palette get_palette() const { return m_pixelbuffer.get_palette(); }
  32. #endif
  33. void lock();
  34. void unlock();
  35. int get_width() const;
  36. int get_height() const;
  37. int get_pitch() const;
  38. int get_depth() const;
  39. void* get_data();
  40. explicit operator bool() { return static_cast<bool>(m_impl); }
  41. QImage& get_qimage();
  42. private:
  43. std::shared_ptr<PixelBufferImpl> m_impl;
  44. };
  45. #endif
  46. /* EOF */