Openholo  v4.2
Open Source Digital Holographic Library
ImgControl.h
Go to the documentation of this file.
1 #pragma once
2 #ifndef __ImgControl_h
3 #define __ImgControl_h
4 #include <stdlib.h>
5 #include <stdint.h>
6 
7 #ifdef _WIN32
8 #ifdef OPH_EXPORT
9 #define OPH_DLL __declspec(dllexport)
10 #else
11 #define OPH_DLL __declspec(dllimport)
12 #endif
13 #else
14 #ifdef OPH_EXPORT
15 #define OPH_DLL __attribute__((visibility("default")))
16 #else
17 #define OPH_DLL
18 #endif
19 #endif
20 
21 namespace oph
22 {
23  enum OPH_DLL FLIP
24  {
26  VERTICAL,
27  HORIZONTAL,
28  BOTH
29  };
30 
31  enum OPH_DLL TYPE
32  {
33  BMP,
34  JPG,
35  PNG,
36  TIFF,
37  GIF
38  };
39 
40  class OPH_DLL ImgControl
41  {
42  private:
43  ImgControl();
44  ~ImgControl();
45  static ImgControl *instance;
46  static void Destroy() {
47  delete instance;
48  }
49  public:
50  static ImgControl* getInstance() {
51  if (instance == nullptr) {
52  instance = new ImgControl();
53  atexit(Destroy);
54  }
55  return instance;
56  }
57 
58  // Get file size
59  bool GetSize(const char* path, uint32_t *size);
60  // Resize the bitmap
61  bool Resize(const uint8_t* src, uint8_t* dst, const uint32_t w, const uint32_t h,
62  const uint32_t neww, const uint32_t newh, const uint8_t ch);
63  // Rotate the bitmap
64  bool Rotate(const double rotate, const uint8_t* src, uint8_t* dst, const uint32_t w, const uint32_t h,
65  const uint32_t neww, const uint32_t newh, const uint8_t ch);
66  // Flip the bitmap
67  bool Flip(FLIP mode, const uint8_t* src, uint8_t* dst, const uint32_t w, const uint32_t h,
68  const uint8_t ch);
69  // Crop the bitmap
70  bool Crop(const uint8_t* src, uint8_t* dst, const uint32_t w, const uint32_t h, const uint8_t ch,
71  const uint32_t start_x, const uint32_t start_y, const uint32_t end_x, const uint32_t end_y);
72 
73  private:
74  // Get bitmap pixel size.
75  uint64_t GetPixelSize(const uint32_t width, const uint32_t height, const uint8_t channel);
76  };
77 }
78 #endif
w
Definition: Openholo.cpp:429
#define OPH_DLL
Definition: ImgControl.h:17
TYPE
Definition: ImgEncoder.h:13
TIFF
Definition: ImgControl.h:33
HORIZONTAL
Definition: ImgControl.h:25
NONE
Definition: ImgControl.h:25
BMP
Definition: ImgControl.h:33
PNG
Definition: ImgControl.h:33
h
Definition: Openholo.cpp:430
VERTICAL
Definition: ImgControl.h:25
JPG
Definition: ImgControl.h:33
FLIP
Definition: ImgEncoder.h:6
static ImgControl * getInstance()
Definition: ImgControl.h:50
Definition: Bitmap.h:49
Definition: ImgEncoder.h:19