NAP
bitmapfilebuffer.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local includes
8 #include "bitmap.h"
9 
10 namespace nap
11 {
15  class NAPAPI BitmapFileBuffer final
16  {
17  public:
18 
22  enum class EImageFileFormat : int
23  {
24  PNG,
25  JPEG,
26  TIFF,
27  BMP
28  };
29 
34 
40  BitmapFileBuffer(const Bitmap& bitmap, bool copyData);
41 
48  BitmapFileBuffer(const SurfaceDescriptor& surfaceDescriptor, const void* data, bool copyData);
49 
54  BitmapFileBuffer(const SurfaceDescriptor& surfaceDescriptor);
55 
60 
64  BitmapFileBuffer(const BitmapFileBuffer& rhs) = delete;
65  BitmapFileBuffer& operator=(const BitmapFileBuffer& rhs) = delete;
66 
70  BitmapFileBuffer(BitmapFileBuffer&& rhs) = delete;
71  BitmapFileBuffer& operator=(BitmapFileBuffer&& rhs) = delete;
72 
79  bool load(const std::string& path, SurfaceDescriptor& outSurfaceDescriptor, utility::ErrorState& errorState);
80 
86  bool save(const std::string& path, utility::ErrorState& errorState);
87 
88 
93  void* getData();
94 
105  void* getHandle();
106 
107  private:
114  bool allocate(const SurfaceDescriptor& surfaceDescriptor, utility::ErrorState& errorState);
115 
124  bool setData(const SurfaceDescriptor& surfaceDescriptor, const void* data, bool copyData, utility::ErrorState& errorState);
125 
129  void release();
130 
134  void* mBitmapHandle = nullptr;
135  };
136 
137 }
nap::BitmapFileBuffer::EImageFileFormat
EImageFileFormat
Definition: bitmapfilebuffer.h:22
nap::BitmapFileBuffer
Definition: bitmapfilebuffer.h:15
nap::utility::ErrorState
Definition: errorstate.h:19
nap::SurfaceDescriptor
Definition: surfacedescriptor.h:46
nap::Bitmap
Definition: bitmap.h:31
nap
Definition: templateapp.h:17