implement BitmapFactory.decodeStream() using gdk_pixbuf_new_from_stream

The java InputStream is wrapped into a custom GInputStream
implementation
This commit is contained in:
Julian Winkler
2023-09-01 13:09:04 +02:00
parent 30b990f60a
commit ceb5df9d39
7 changed files with 95 additions and 8 deletions

View File

@@ -136,7 +136,13 @@ public final class Bitmap {
mLayoutBounds = null;
}
Bitmap(long pixbuf) {
this();
this.pixbuf = pixbuf;
}
private native long native_bitmap_from_path(CharSequence path);
static native long native_copy(long src);
/**
* Private constructor that must received an already allocated native bitmap
@@ -784,7 +790,7 @@ public final class Bitmap {
return bitmap;
*/
return new Bitmap();
return new Bitmap(native_copy(source.pixbuf));
}
/**
@@ -1606,7 +1612,7 @@ public final class Bitmap {
int quality, OutputStream stream,
byte[] tempStorage);
private static native void nativeErase(int nativeBitmap, int color);
private static native int nativeRowBytes(int nativeBitmap);
private static native int nativeRowBytes(long nativeBitmap);
private static native int nativeConfig(int nativeBitmap);
private static native int nativeGetPixel(int nativeBitmap, int x, int y,

View File

@@ -596,7 +596,7 @@ public class BitmapFactory {
tempStorage = opts.inTempStorage;
if (tempStorage == null)
tempStorage = new byte[DECODE_BUFFER_SIZE];
return nativeDecodeStream(is, tempStorage, outPadding, opts);
return new Bitmap(nativeDecodeStream(is, tempStorage, outPadding, opts));
}
/**
@@ -669,7 +669,7 @@ public class BitmapFactory {
return decodeFileDescriptor(fd, null, null);
}
private static native Bitmap nativeDecodeStream(InputStream is, byte[] storage,
private static native long nativeDecodeStream(InputStream is, byte[] storage,
Rect padding, Options opts);
private static native Bitmap nativeDecodeFileDescriptor(FileDescriptor fd,
Rect padding, Options opts);