forked from octalmage/robotjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio.h
55 lines (41 loc) · 1.44 KB
/
io.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
51
52
53
54
55
#pragma once
#ifndef IO_H
#define IO_H
#include "MMBitmap.h"
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
enum _MMImageType {
kInvalidImageType = 0,
kPNGImageType,
kBMPImageType /* Currently only PNG and BMP are supported. */
};
typedef uint16_t MMImageType;
enum _MMIOError {
kMMIOUnsupportedTypeError = 0
};
typedef uint16_t MMIOError;
const char *getExtension(const char *fname, size_t len);
/* Returns best guess at the MMImageType based on a file extension, or
* |kInvalidImageType| if no matching type was found. */
MMImageType imageTypeFromExtension(const char *ext);
/* Attempts to parse the file of the given type at the given path.
* |filepath| is an ASCII string describing the absolute POSIX path.
* Returns new bitmap (to be destroy()'d by caller) on success, NULL on error.
* If |error| is non-NULL, it will be set to the error code on return.
*/
MMBitmapRef newMMBitmapFromFile(const char *path, MMImageType type, MMIOError *err);
/* Saves |bitmap| to a file of the given type at the given path.
* |filepath| is an ASCII string describing the absolute POSIX path.
* Returns 0 on success, -1 on error. */
int saveMMBitmapToFile(MMBitmapRef bitmap, const char *path, MMImageType type);
/* Returns description of given error code.
* Returned string is constant and hence should not be freed. */
const char *MMIOErrorString(MMImageType type, MMIOError error);
#ifdef __cplusplus
}
#endif
#endif /* IO_H */