Openholo  v2.1
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 
5 #include <atlbase.h>
6 
7 
8 #ifdef OPH_EXPORT
9 #define OPH_DLL __declspec(dllexport)
10 #else
11 #define OPH_DLL __declspec(dllimport)
12 #endif
13 namespace oph
14 {
15  enum FLIP
16  {
17  NONE,
18  VERTICAL,
19  HORIZONTAL,
20  BOTH
21  };
22 
23  enum TYPE
24  {
25  BMP,
26  JPG,
27  PNG,
28  TIFF,
29  GIF
30  };
31 
32  class OPH_DLL ImgControl
33  {
34  private:
35  ImgControl();
36  ~ImgControl();
37  static ImgControl *instance;
38  static void Destroy() {
39  delete instance;
40  }
41  public:
42  static ImgControl* getInstance() {
43  if (instance == nullptr) {
44  instance = new ImgControl();
45  atexit(Destroy);
46  }
47  return instance;
48  }
49 
50  bool Save(const char *path, BYTE *pBuf, UINT len, int quality = 100);
51  int CalcBitmapSize(int w, int h, int ch) { return (((w * ch) + 3) & ~3) * h; }
52  bool GetSize(const char* path, unsigned int *size);
53  void Resize(unsigned char* src, unsigned char* dst, int w, int h, int neww, int newh, int ch);
54  bool Rotate(double rotate, unsigned char *src, unsigned char *dst, int w, int h, int neww, int newh, int ch);
55  bool Flip(FLIP mode, unsigned char *src, unsigned char *dst, int w, int h, int ch);
56  bool Crop(unsigned char *src, unsigned char *dst, int w, int h, int ch, int x, int y, int neww, int newh);
57 
58 
59  private:
60  int GetEncoderClsid(const WCHAR *format, CLSID *pClsid);
61  char* GetExtension(const char *path);
62  };
63 }
64 #endif
#define OPH_DLL
Definition: ImgControl.h:11
int CalcBitmapSize(int w, int h, int ch)
Definition: ImgControl.h:51
TYPE
Definition: ImgControl.h:23
FLIP
Definition: ImgControl.h:15
static ImgControl * getInstance()
Definition: ImgControl.h:42
Definition: Bitmap.h:49