1 package mhr.appcore.bitmap;
3 import mhr.appcore.bitmap.exceptions.BitmapAllocationException;
4 import mhr.appcore.bitmap.exceptions.UnsupportedBitmapException;
5 import mhr.appcore.exceptions.AlreadyDisposedException;
6 import mhr.appcore.interfaces.PDBitmap;
7 import mhr.appcore.utils.Rect;
17 protected native
long createTBitmap(
int nativeType,
int width,
int height,
int colorMode,
boolean premultiplied);
21 protected native
long wrapAsTBitmap(
int nativeType,
long adress,
int width,
int height,
int colorMode,
boolean premultiplied);
23 protected native
int premultiply(
int nativeType,
long adress);
25 protected native
int demultiply(
int nativeType,
long adress);
27 protected native
long getChannel(
int nativeType,
long adress,
int index);
29 protected native
int fill(
int nativeType,
long adress,
int tlx,
int tly,
int brx,
int bry,
int color);
31 protected native
int copyTo(
int nativeType,
long adress,
long dstAdress,
int tlx,
int tly,
int brx,
int bry,
int srcOrigX,
int srcOrigY);
33 protected native
int dispose(
int nativeType,
long adress);
35 protected native
int setPremultiplied(
int nativeType,
long adresss,
boolean premultiplied);
40 protected long adress = 0;
57 throw new AlreadyDisposedException(
"Bitmap is already disposed.");
69 throw new AlreadyDisposedException(
"Bitmap is already disposed.");
81 throw new AlreadyDisposedException(
"Bitmap is already disposed.");
93 throw new AlreadyDisposedException(
"Bitmap is already disposed.");
119 if (
info == null || adress == 0) {
123 throw new RuntimeException(
"Something went wrong.");
160 long wrapAdress = wrap.getAndLockData();
161 if (wrapAdress == 0) {
170 this.nativeType = tmpType;
182 if (other.adress != 0) {
183 adress =
createTBitmap(other.nativeType.getValue(), other.adress);
188 this.nativeType = other.nativeType;
204 throw new NullPointerException(
"Native adress could not be NULL");
245 throw new IllegalStateException(
"Cannot crop wrapped bitmap");
248 if (newAdress == 0) {
265 if (this.adress != 0) {
272 throw new AlreadyDisposedException(
"Bitmap is already disposed.");
282 if (this.adress != 0) {
289 throw new AlreadyDisposedException(
"Bitmap is already disposed.");
303 if (this.adress != 0) {
306 if (tmpAdress != 0) {
312 retVal.
adress = tmpAdress;
318 throw new IllegalArgumentException(
"Operation not applicable to single channel bitmap, make copy instead.");
337 if (this.adress == 0 || dst.adress == 0) {
340 if (this.nativeType != dst.nativeType) {
341 throw new IllegalArgumentException(
"Incompatible bitmaps.");
343 return copyTo(nativeType.getValue(),
adress, dst.adress, srcRect.tlx, srcRect.tly, srcRect.brx, srcRect.bry, srcOrigX, srcOrigY);
354 if (this.adress != 0) {
355 return fill(nativeType.getValue(),
adress, srcRect.tlx, srcRect.tly, srcRect.brx, srcRect.bry, color);