Oxygine  1
2g game engine
Image.h
1 #pragma once
2 #include "oxygine-include.h"
3 #include "core/Texture.h"
4 #include "core/file.h"
5 
6 namespace oxygine
7 {
8  enum ImageType
9  {
10  IT_UNKNOWN,
11  IT_PNG,
12  IT_PKM,
13  IT_PVR2,
14  IT_PVR,
15  IT_TGA,
16  IT_JPEG
17  };
18 
19  bool getImageInfo(const void* data, size_t size, const char* name, ImageType& type, int& width, int& height);
20 
21  DECLARE_SMART(Image, spImage);
22 
23  class Image : public Texture
24  {
25  public:
26  Image();
27  ~Image();
28 
29  bool init(file::buffer& bf, bool premultiplied = false, TextureFormat format = TF_UNDEFINED);
30  void init(const ImageData& src);
31  void init(int w, int h, TextureFormat Format);
32 
33  void cleanup();
34  void convert(Image& dest, TextureFormat format);
35  //void convert2pot(MemoryTexture &dest);
36 
37  OXYGINE_DEPRECATED
38  void fill_zero();
39 
40  void fillZero() { fill(0); }
41  void fill(unsigned int val);
42 
43  unsigned int getSizeVRAM() const {return (unsigned int)_buffer.size();}
44  int getWidth() const;
45  int getHeight() const;
46  const Point& getSize() const;
47  TextureFormat getFormat() const;
48 
49  ImageData lock(lock_flags f = 0, const Rect* pRect = 0);
50  ImageData lock(const Rect* pRect);
51  ImageData lock(const Rect& pRect);
52  ImageData lock(int x, int y, int w, int h);
53  ImageData lock(int x, int y);
54 
55  void unlock();
56  void toPOT(Image& dest);
57 
58  void updateRegion(int x, int y, const ImageData& data);
59  void apply(const Rect*);
60 
61  void swap(Image& r);
62 
63  private:
64  ImageData _image;
65  size_t _offset;//buffer offset
66  std::vector<unsigned char> _buffer;
67  };
68 
69  typedef bool (*cbLoadImageFromBuffer)(Image& mt, void* data, int nSize, bool premultiplied, TextureFormat format);
70  void setJpegImageLoader(cbLoadImageFromBuffer);
71  void setPngImageLoader(cbLoadImageFromBuffer);
72  void setCustomImageLoader(cbLoadImageFromBuffer);
73 }
Definition: Image.h:23
Definition: Texture.h:24
Definition: ImageData.h:54
–oxgl-end–!
Definition: Actor.h:14
Definition: file.h:18