diff options
Diffstat (limited to 'graphics/java/android')
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 12 | ||||
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 06bfbcf..6c08ce5 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -90,6 +90,18 @@ public class Allocation extends BaseObj { subData1D(0, mType.getElementCount(), d); } + public void updateFromBitmap(Bitmap b) + throws IllegalArgumentException { + + mRS.validate(); + if(mType.getX() != b.getWidth() || + mType.getY() != b.getHeight()) { + throw new IllegalArgumentException("Cannot update allocation from bitmap, sizes mismatch"); + } + + mRS.nAllocationUpdateFromBitmap(mID, b); + } + public void subData(int xoff, FieldPacker fp) { int eSize = mType.mElement.getSizeBytes(); final byte[] data = fp.getData(); diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 8ad54c9..2774fea 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -186,6 +186,10 @@ public class RenderScript { synchronized int nAllocationCreateTyped(int type) { return rsnAllocationCreateTyped(mContext, type); } + native void rsnAllocationUpdateFromBitmap(int con, int alloc, Bitmap bmp); + synchronized void nAllocationUpdateFromBitmap(int alloc, Bitmap bmp) { + rsnAllocationUpdateFromBitmap(mContext, alloc, bmp); + } native int rsnAllocationCreateFromBitmap(int con, int dstFmt, boolean genMips, Bitmap bmp); synchronized int nAllocationCreateFromBitmap(int dstFmt, boolean genMips, Bitmap bmp) { return rsnAllocationCreateFromBitmap(mContext, dstFmt, genMips, bmp); |