summaryrefslogtreecommitdiff
path: root/graphics/java/android/renderscript/Allocation.java
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/java/android/renderscript/Allocation.java')
-rw-r--r--graphics/java/android/renderscript/Allocation.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index d32a0b599344..ddb2abf7d7a4 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -386,6 +386,21 @@ public class Allocation extends BaseObj {
Bitmap b = BitmapFactory.decodeResource(res, id, mBitmapOptions);
return createFromBitmapBoxed(rs, b, dstFmt, genMips);
}
+
+ static public Allocation createFromString(RenderScript rs, String str)
+ throws IllegalArgumentException {
+ byte[] allocArray = null;
+ try {
+ allocArray = str.getBytes("UTF-8");
+ Allocation alloc = Allocation.createSized(rs, Element.U8(rs), allocArray.length);
+ alloc.data(allocArray);
+ return alloc;
+ }
+ catch (Exception e) {
+ Log.e("rs", "could not convert string to utf-8");
+ }
+ return null;
+ }
}