forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpnmFileTypeAndroid.h
More file actions
88 lines (68 loc) · 2.05 KB
/
pnmFileTypeAndroid.h
File metadata and controls
88 lines (68 loc) · 2.05 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file pnmFileTypeAndroid.h
* @author rdb
* @date 2013-01-11
*/
#ifndef PNMFILETYPEANDROID_H
#define PNMFILETYPEANDROID_H
#ifdef ANDROID
#include "pandabase.h"
#include "pnmFileType.h"
#include "pnmReader.h"
#include "pnmWriter.h"
#include <jni.h>
/**
* Wrapper class around the Android Bitmap mechanism to allow loading images
* on Android without needing libpng or libjpeg.
*/
class PNMFileTypeAndroid : public PNMFileType {
public:
enum CompressFormat : jint {
CF_jpeg = 0,
CF_png = 1,
CF_webp = 2,
};
PNMFileTypeAndroid(CompressFormat format);
virtual std::string get_name() const;
virtual int get_num_extensions() const;
virtual std::string get_extension(int n) const;
virtual bool has_magic_number() const;
virtual PNMReader *make_reader(std::istream *file, bool owns_file = true,
const std::string &magic_number = std::string());
virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true);
public:
class Reader : public PNMReader {
public:
Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number);
virtual ~Reader();
virtual void prepare_read();
virtual int read_data(xel *array, xelval *alpha);
private:
// It is assumed that the Reader is only used within a single thread.
JNIEnv *_env;
jobject _bitmap;
int _sample_size;
uint32_t _stride;
int32_t _format;
};
class Writer : public PNMWriter {
public:
Writer(PNMFileType *type, std::ostream *file, bool owns_file,
CompressFormat format);
virtual int write_data(xel *array, xelval *alpha);
virtual bool supports_grayscale() const;
private:
CompressFormat _format;
};
private:
CompressFormat _format;
};
#endif // ANDROID
#endif