summaryrefslogtreecommitdiff
path: root/common/image.h
blob: 8bff6c53cf1c45729f053dd88c0c7fecb5b1fd83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef _IMAGE_H_
#define _IMAGE_H_

class File;

#include "typedefs.h"

class Image
{
public:
  Image ();
  virtual ~Image ();

  bool FileSave (File& file, LC_IMAGE_OPTS* opts) const;
  bool FileSave (const char* filename, LC_IMAGE_OPTS* opts) const;
  bool FileLoad (File& file);
  bool FileLoad (const char* filename);

  void Resize (int width, int height);
  void ResizePow2 ();
  void FromOpenGL (int width, int height);
  void Allocate (int width, int height, bool alpha);

  int Width () const
    { return m_nWidth; }
  int Height () const
    { return m_nHeight; }
  int Alpha () const
    { return m_bAlpha; }
  unsigned char* GetData () const
    { return m_pData; }

protected:
  void FreeData ();

  bool LoadJPG (File& file);
  bool LoadBMP (File& file);
  bool LoadPNG (File& file);
  bool LoadGIF (File& file);

  bool SaveJPG (File& file, int quality, bool progressive) const;
  bool SaveBMP (File& file, bool quantize) const;
  bool SavePNG (File& file, bool transparent, bool interlaced, unsigned char* background) const;
  bool SaveGIF (File& file, bool transparent, bool interlaced, unsigned char* background) const;

  int m_nWidth;
  int m_nHeight;
  bool m_bAlpha;
  unsigned char* m_pData;
};

void SaveVideo(char* filename, Image *images, int count, float fps);

#endif // _IMAGE_H_