-
Notifications
You must be signed in to change notification settings - Fork 1
/
img.h
50 lines (43 loc) · 1.36 KB
/
img.h
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
/* Copyright 2011 Pyarelal Knowles, under GNU LGPL (see LICENCE.txt) */
#ifndef QI_IMG_H
#define QI_IMG_H
#include <string>
#ifdef _WIN32
#include <memory>
#else
#include <tr1/memory>
#endif
#include "util.h"
namespace QI
{
struct RCByteArray : public std::tr1::shared_ptr<unsigned char>
{
RCByteArray() : std::tr1::shared_ptr<unsigned char>() {}
RCByteArray(unsigned char* o) : std::tr1::shared_ptr<unsigned char>(o, my_array_deleter<unsigned char>()) {}
void operator()(unsigned char* todelete) const {delete[] todelete;}
operator unsigned char*() {return get();}
};
struct Image
{
bool repeat;
bool mipmap;
bool nearest;
int anisotropy;
int channels;
int width, height;
RCByteArray data;
Image();
Image(const Image& other);
virtual ~Image();
virtual bool loadImage(std::string filename);
virtual bool saveImage(std::string filename);
void generateNoise();
void generateChecker(unsigned char a = 0, unsigned char b = 255);
unsigned int bufferTexture(); //returns new GL texture
void bufferTexture(unsigned int object, unsigned long target = -1); //buffers to object
void readTexture(unsigned int id, int mipLevel = 0);
void resize(int w, int h, int nchannels = 0); //clears old image!
void genHostMipmap(const Image& src); //generates an image based on the src image
};
}
#endif