App

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

mhr_appcore_bitmap_NBitmap.cpp
Go to the documentation of this file.
1 #include "mhr_appcore_bitmap_NBitmap.hpp"
2 #include "../app/app_all.hpp"
3
4 using namespace app;
5
9 JNIEXPORT jlong JNICALL Java_mhr_appcore_bitmap_NBitmap_createTBitmap__IIIIZ(JNIEnv * pEnv, jobject pThis, jint nativeType, jint width, jint height, jint colorMode,
10 jboolean premultiplied) {
11 void * vPtr = NULL;
12 switch ((BitmapNativeType) nativeType) {
13 case mono_8_bit:
14 vPtr = new mono_8bit_bitmap(width, height, (ColorMode) colorMode, premultiplied);
15 if (vPtr == NULL) {
16 return 0;
17 }
18 if (((mono_8bit_bitmap*) vPtr)->getData() == NULL) {
19 delete (mono_8bit_bitmap*) vPtr;
20 return 0;
21 }
22 break;
23 case rgba_8_bit:
24 vPtr = new rgba_8bit_bitmap(width, height, (ColorMode) colorMode, premultiplied);
25 if (vPtr == NULL) {
26 return 0;
27 }
28 if (((rgba_8bit_bitmap*) vPtr)->getData() == NULL) {
29 delete (rgba_8bit_bitmap*) vPtr;
30 return 0;
31 }
32 break;
33 default:
34 break;
35 }
36 return (long long) vPtr;
37 }
38
42 JNIEXPORT jlong JNICALL Java_mhr_appcore_bitmap_NBitmap_createTBitmap__IJ(JNIEnv * pEnv, jobject pThis, jint nativeType, jlong adress) {
43 void * vPtr = NULL;
44 switch ((BitmapNativeType) nativeType) {
45 case mono_8_bit:
46 vPtr = new mono_8bit_bitmap(*((mono_8bit_bitmap *) adress));
47 if (vPtr == NULL) {
48 return 0;
49 }
50 if (((mono_8bit_bitmap*) vPtr)->getData() == NULL) {
51 delete (mono_8bit_bitmap*) vPtr;
52 return 0;
53 }
54 break;
55 case rgba_8_bit:
56 vPtr = new rgba_8bit_bitmap(*((rgba_8bit_bitmap *) adress));
57 if (vPtr == NULL) {
58 return 0;
59 }
60 if (((rgba_8bit_bitmap*) vPtr)->getData() == NULL) {
61 delete (rgba_8bit_bitmap*) vPtr;
62 return 0;
63 }
64 break;
65 default:
66 break;
67 }
68 return (long long) vPtr;
69 }
70
74 JNIEXPORT jlong JNICALL Java_mhr_appcore_bitmap_NBitmap_wrapAsTBitmap(JNIEnv * pEnv, jobject pThis, jint nativeType, jlong adress, jint width, jint height, jint colorMode,
75 jboolean premultiplied) {
76 void * vPtr = NULL;
77 switch ((BitmapNativeType) nativeType) {
78 case mono_8_bit:
79 vPtr = new mono_8bit_bitmap((void *) adress, width, height, (ColorMode) colorMode, premultiplied);
80 if (vPtr == NULL) {
81 return 0;
82 }
83 // Testovat data na NULL nema vyznam, o alokaci se stara nekdo jiny
84 break;
85 case rgba_8_bit:
86 vPtr = new rgba_8bit_bitmap((void *) adress, width, height, (ColorMode) colorMode, premultiplied);
87 if (vPtr == NULL) {
88 return 0;
89 }
90 break;
91 default:
92 break;
93 }
94 return (long long) vPtr;
95 }
96
100 JNIEXPORT jint JNICALL Java_mhr_appcore_bitmap_NBitmap_premultiply(JNIEnv * pEnv, jobject pThis, jint nativeType, jlong adress) {
101 int retVal = 0;
102 switch ((BitmapNativeType) nativeType) {
103 case mono_8_bit: {
104 retVal = -1;
105 break;
106 }
107 case rgba_8_bit: {
108 rgba_8bit_bitmap * b = (rgba_8bit_bitmap *) adress;
109 retVal = b->premultiply();
110 break;
111 }
112 default:
113 retVal = -1;
114 break;
115 }
116 return retVal;
117 }
118
122 JNIEXPORT jint JNICALL Java_mhr_appcore_bitmap_NBitmap_demultiply(JNIEnv * pEnv, jobject pThis, jint nativeType, jlong adress) {
123 int retVal = 0;
124 switch ((BitmapNativeType) nativeType) {
125 case mono_8_bit: {
126 retVal = -1;
127 break;
128 }
129 case rgba_8_bit: {
130 rgba_8bit_bitmap * b = (rgba_8bit_bitmap *) adress;
131 retVal = b->demultiply();
132 break;
133 }
134 default:
135 retVal = -1;
136 break;
137 }
138 return retVal;
139 }
140
144 JNIEXPORT jlong JNICALL Java_mhr_appcore_bitmap_NBitmap_getChannel(JNIEnv * pEnv, jobject pThis, jint nativeType, jlong adress, jint index) {
145 void * vPtr = NULL;
146 switch ((BitmapNativeType) nativeType) {
147 case mono_8_bit:
148 vPtr = ((mono_8bit_bitmap *) adress)->getChannel(index);
149 if (vPtr == NULL) {
150 return 0;
151 }
152 if (((mono_8bit_bitmap*) vPtr)->getData() == NULL) {
153 delete (mono_8bit_bitmap*) vPtr;
154 return 0;
155 }
156 break;
157 case rgba_8_bit:
158 vPtr = ((rgba_8bit_bitmap *) adress)->getChannel(index);
159 if (vPtr == NULL) {
160 return 0;
161 }
162 if (((rgba_8bit_bitmap*) vPtr)->getData() == NULL) {
163 delete (rgba_8bit_bitmap*) vPtr;
164 return 0;
165 }
166 break;
167 default:
168 break;
169 }
170 return (long long) vPtr;
171 }
172
177 JNIEXPORT jint JNICALL Java_mhr_appcore_bitmap_NBitmap_fill(JNIEnv * pEnv, jobject pThis, jint nativeType, jlong adress, jint tlx, jint tly, jint brx, jint bry, jint color) {
178 int retVal = 0;
179 switch ((BitmapNativeType) nativeType) {
180 case mono_8_bit: {
181 mono_8bit_bitmap * b = (mono_8bit_bitmap *) adress;
182 px_1x8bit fill = color;
183 retVal = b->fill(Rect(tlx, tly, brx, bry), &fill);
184 break;
185 }
186 case rgba_8_bit: {
187 rgba_8bit_bitmap * b = (rgba_8bit_bitmap *) adress;
188 px_4x8bit fill = color;
189 retVal = b->fill(Rect(tlx, tly, brx, bry), &fill);
190 break;
191 }
192 default:
193 retVal = -1;
194 break;
195 }
196 return retVal;
197 }
198
202 JNIEXPORT jint JNICALL Java_mhr_appcore_bitmap_NBitmap_copyTo(JNIEnv * pEnv, jobject pThis, jint nativeType, jlong adress, jlong dstAdress, jint tlx, jint tly, jint brx, jint bry,
203 jint srcOrigX, jint srcOrigY) {
204 int retVal = 0;
205 switch ((BitmapNativeType) nativeType) {
206 case mono_8_bit: {
207 retVal = ((mono_8bit_bitmap *) adress)->copyTo(*(mono_8bit_bitmap *) dstAdress, Rect(tlx, tly, brx, bry), Point(srcOrigX, srcOrigY));
208 break;
209 }
210 case rgba_8_bit: {
211 retVal = ((rgba_8bit_bitmap *) adress)->copyTo(*(rgba_8bit_bitmap *) dstAdress, Rect(tlx, tly, brx, bry), Point(srcOrigX, srcOrigY));
212 break;
213 }
214 default:
215 retVal = -1;
216 break;
217 }
218 return retVal;
219 }
220
224 JNIEXPORT jint JNICALL Java_mhr_appcore_bitmap_NBitmap_dispose(JNIEnv * pEnv, jobject pThis, jint nativeType, jlong adress) {
225 switch ((BitmapNativeType) nativeType) {
226 case mono_8_bit: {
227 delete (mono_8bit_bitmap *) adress;
228 break;
229 }
230 case rgba_8_bit: {
231 delete (rgba_8bit_bitmap *) adress;
232 break;
233 }
234 default:
235 break;
236 }
237 return 0;
238 }
239
240 JNIEXPORT jint JNICALL Java_mhr_appcore_bitmap_NBitmap_setPremultiplied(JNIEnv * pEnv, jobject pThis, jint nativeType, jlong adress, jboolean premultiplied) {
241 int retVal = 0;
242 switch ((BitmapNativeType) nativeType) {
243 case rgba_8_bit: {
244 ((rgba_8bit_bitmap *) adress)->setPremultiplied(premultiplied);
245 break;
246 }
247 default:
248 retVal = -1;
249 break;
250 }
251 return retVal;
252 }