-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_load_internal.h
38 lines (34 loc) · 969 Bytes
/
image_load_internal.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
#ifndef IMAGE_LOAD_INTERNAL_H_INCLUDED
#define IMAGE_LOAD_INTERNAL_H_INCLUDED
#include <string>
#include <cstdint>
using namespace std;
namespace ImageLoadInternal
{
struct ImageLoaderResult
{
uint8_t *data;
size_t w, h;
ImageLoaderResult(uint8_t *data, size_t w, size_t h)
: data(data), w(w), h(h)
{
}
ImageLoaderResult(ImageLoaderResult &&rt)
: data(rt.data), w(rt.w), h(rt.h)
{
rt.data = nullptr;
}
ImageLoaderResult(const ImageLoaderResult &) = delete;
void operator =(const ImageLoaderResult &) = delete;
~ImageLoaderResult()
{
delete []data;
}
const uint8_t *getPixelPtr(size_t x, size_t y) const
{
return data + 4 * x + 4 * w * y;
}
};
ImageLoaderResult load(string fileName, void (*throwErrorFn)(string msg));
}
#endif // IMAGE_LOAD_INTERNAL_H_INCLUDED