blob: 2c076b31fb529c9d48f7ae84eaaaf7a13295ac54 [file] [log] [blame]
Jason Samsb8c5a842009-07-31 20:40:47 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.renderscript;
18
Jason Samsb8c5a842009-07-31 20:40:47 -070019import java.io.IOException;
20import java.io.InputStream;
21
22import android.content.res.Resources;
Romain Guy650a3eb2009-08-31 14:06:43 -070023import android.content.res.AssetManager;
Jason Samsb8c5a842009-07-31 20:40:47 -070024import android.graphics.Bitmap;
25import android.graphics.BitmapFactory;
Jason Samsb8c5a842009-07-31 20:40:47 -070026import android.util.Log;
Romain Guy650a3eb2009-08-31 14:06:43 -070027import android.util.TypedValue;
Jason Samsb8c5a842009-07-31 20:40:47 -070028
29/**
30 * @hide
31 *
32 **/
33public class Allocation extends BaseObj {
Jason Sams43ee06852009-08-12 17:54:11 -070034 Type mType;
Jason Sams8a647432010-03-01 15:31:04 -080035 Bitmap mBitmap;
Jason Sams43ee06852009-08-12 17:54:11 -070036
37 Allocation(int id, RenderScript rs, Type t) {
Alex Sakhartchouk0de94442010-08-11 14:41:28 -070038 super(id, rs);
Jason Sams43ee06852009-08-12 17:54:11 -070039 mType = t;
Jason Samsb8c5a842009-07-31 20:40:47 -070040 }
41
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -070042 Allocation(int id, RenderScript rs) {
Alex Sakhartchouk0de94442010-08-11 14:41:28 -070043 super(id, rs);
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -070044 }
45
Alex Sakhartchoukdfac8142010-07-15 11:33:03 -070046 @Override
47 void updateFromNative() {
48 mRS.validate();
Alex Sakhartchoukfb10c162010-08-04 14:45:48 -070049 mName = mRS.nGetName(mID);
Alex Sakhartchoukdfac8142010-07-15 11:33:03 -070050 int typeID = mRS.nAllocationGetType(mID);
51 if(typeID != 0) {
52 mType = new Type(typeID, mRS);
53 mType.updateFromNative();
54 }
55 }
56
Jason Samsea87e962010-01-12 12:12:28 -080057 public Type getType() {
58 return mType;
59 }
60
Jason Samsb8c5a842009-07-31 20:40:47 -070061 public void uploadToTexture(int baseMipLevel) {
Jason Sams771bebb2009-12-07 12:40:12 -080062 mRS.validate();
Jason Samsc2908e62010-02-23 17:44:28 -080063 mRS.nAllocationUploadToTexture(mID, false, baseMipLevel);
64 }
65
66 public void uploadToTexture(boolean genMips, int baseMipLevel) {
67 mRS.validate();
68 mRS.nAllocationUploadToTexture(mID, genMips, baseMipLevel);
Jason Samsb8c5a842009-07-31 20:40:47 -070069 }
70
Jason Sams07ae4062009-08-27 20:23:34 -070071 public void uploadToBufferObject() {
Jason Sams771bebb2009-12-07 12:40:12 -080072 mRS.validate();
Jason Sams07ae4062009-08-27 20:23:34 -070073 mRS.nAllocationUploadToBufferObject(mID);
74 }
75
Jason Samsb8c5a842009-07-31 20:40:47 -070076 public void data(int[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -080077 mRS.validate();
Jason Sams768bc022009-09-21 19:41:04 -070078 subData1D(0, mType.getElementCount(), d);
79 }
80 public void data(short[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -080081 mRS.validate();
Jason Sams768bc022009-09-21 19:41:04 -070082 subData1D(0, mType.getElementCount(), d);
83 }
84 public void data(byte[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -080085 mRS.validate();
Jason Sams768bc022009-09-21 19:41:04 -070086 subData1D(0, mType.getElementCount(), d);
87 }
88 public void data(float[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -080089 mRS.validate();
Jason Sams768bc022009-09-21 19:41:04 -070090 subData1D(0, mType.getElementCount(), d);
Jason Samsb8c5a842009-07-31 20:40:47 -070091 }
92
Jason Sams49bdaf02010-08-31 13:50:42 -070093 public void subData(int xoff, FieldPacker fp) {
Jason Samsa70f4162010-03-26 15:33:42 -070094 int eSize = mType.mElement.getSizeBytes();
95 final byte[] data = fp.getData();
96
97 int count = data.length / eSize;
98 if ((eSize * count) != data.length) {
99 throw new IllegalArgumentException("Field packer length " + data.length +
100 " not divisible by element size " + eSize + ".");
101 }
Jason Sams49bdaf02010-08-31 13:50:42 -0700102 data1DChecks(xoff, count, data.length, data.length);
103 mRS.nAllocationSubData1D(mID, xoff, count, data, data.length);
104 }
105
106
107 public void subElementData(int xoff, int component_number, FieldPacker fp) {
108 if (component_number >= mType.mElement.mElements.length) {
109 throw new IllegalArgumentException("Component_number " + component_number + " out of range.");
110 }
111 if(xoff < 0) {
112 throw new IllegalArgumentException("Offset must be >= 0.");
113 }
114
115 final byte[] data = fp.getData();
116 int eSize = mType.mElement.mElements[component_number].getSizeBytes();
117
118 if (data.length != eSize) {
119 throw new IllegalArgumentException("Field packer sizelength " + data.length +
120 " does not match component size " + eSize + ".");
121 }
122
123 mRS.nAllocationSubElementData1D(mID, xoff, component_number, data, data.length);
Jason Samsa70f4162010-03-26 15:33:42 -0700124 }
125
Jason Sams768bc022009-09-21 19:41:04 -0700126 private void data1DChecks(int off, int count, int len, int dataSize) {
Jason Sams771bebb2009-12-07 12:40:12 -0800127 mRS.validate();
Jason Samsa70f4162010-03-26 15:33:42 -0700128 if(off < 0) {
129 throw new IllegalArgumentException("Offset must be >= 0.");
130 }
131 if(count < 1) {
132 throw new IllegalArgumentException("Count must be >= 1.");
133 }
134 if((off + count) > mType.getElementCount()) {
135 throw new IllegalArgumentException("Overflow, Available count " + mType.getElementCount() +
136 ", got " + count + " at offset " + off + ".");
Jason Sams07ae4062009-08-27 20:23:34 -0700137 }
Jason Sams768bc022009-09-21 19:41:04 -0700138 if((len) < dataSize) {
139 throw new IllegalArgumentException("Array too small for allocation type.");
140 }
Jason Samsb8c5a842009-07-31 20:40:47 -0700141 }
142
143 public void subData1D(int off, int count, int[] d) {
Jason Sams768bc022009-09-21 19:41:04 -0700144 int dataSize = mType.mElement.getSizeBytes() * count;
145 data1DChecks(off, count, d.length * 4, dataSize);
146 mRS.nAllocationSubData1D(mID, off, count, d, dataSize);
147 }
148 public void subData1D(int off, int count, short[] d) {
149 int dataSize = mType.mElement.getSizeBytes() * count;
150 data1DChecks(off, count, d.length * 2, dataSize);
151 mRS.nAllocationSubData1D(mID, off, count, d, dataSize);
152 }
153 public void subData1D(int off, int count, byte[] d) {
154 int dataSize = mType.mElement.getSizeBytes() * count;
155 data1DChecks(off, count, d.length, dataSize);
156 mRS.nAllocationSubData1D(mID, off, count, d, dataSize);
157 }
158 public void subData1D(int off, int count, float[] d) {
159 int dataSize = mType.mElement.getSizeBytes() * count;
160 data1DChecks(off, count, d.length * 4, dataSize);
161 mRS.nAllocationSubData1D(mID, off, count, d, dataSize);
Jason Samsb8c5a842009-07-31 20:40:47 -0700162 }
163
Jason Sams768bc022009-09-21 19:41:04 -0700164
Jason Samsb8c5a842009-07-31 20:40:47 -0700165 public void subData2D(int xoff, int yoff, int w, int h, int[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -0800166 mRS.validate();
Jason Sams07ae4062009-08-27 20:23:34 -0700167 mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d, d.length * 4);
Jason Samsb8c5a842009-07-31 20:40:47 -0700168 }
169
170 public void subData2D(int xoff, int yoff, int w, int h, float[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -0800171 mRS.validate();
Jason Sams07ae4062009-08-27 20:23:34 -0700172 mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d, d.length * 4);
Jason Samsb8c5a842009-07-31 20:40:47 -0700173 }
174
Jason Sams40a29e82009-08-10 14:55:26 -0700175 public void readData(int[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -0800176 mRS.validate();
Jason Sams40a29e82009-08-10 14:55:26 -0700177 mRS.nAllocationRead(mID, d);
178 }
179
180 public void readData(float[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -0800181 mRS.validate();
Jason Sams40a29e82009-08-10 14:55:26 -0700182 mRS.nAllocationRead(mID, d);
183 }
184
Jason Sams5edc6082010-10-05 13:32:49 -0700185 public void resize(int dimX) {
186 if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.getFaces() || mType.getLOD()) {
187 throw new IllegalStateException("Resize only support for 1D allocations at this time.");
188 }
189 mRS.nAllocationResize1D(mID, dimX);
190 }
191
192 /*
193 public void resize(int dimX, int dimY) {
194 if ((mType.getZ() > 0) || mType.getFaces() || mType.getLOD()) {
195 throw new IllegalStateException("Resize only support for 2D allocations at this time.");
196 }
197 if (mType.getY() == 0) {
198 throw new IllegalStateException("Resize only support for 2D allocations at this time.");
199 }
200 mRS.nAllocationResize2D(mID, dimX, dimY);
201 }
202 */
Jason Sams40a29e82009-08-10 14:55:26 -0700203
Jason Samsb8c5a842009-07-31 20:40:47 -0700204 public class Adapter1D extends BaseObj {
205 Adapter1D(int id, RenderScript rs) {
Alex Sakhartchouk0de94442010-08-11 14:41:28 -0700206 super(id, rs);
Jason Samsb8c5a842009-07-31 20:40:47 -0700207 }
208
Jason Samsb8c5a842009-07-31 20:40:47 -0700209 public void setConstraint(Dimension dim, int value) {
Jason Sams771bebb2009-12-07 12:40:12 -0800210 mRS.validate();
Jason Samsb8c5a842009-07-31 20:40:47 -0700211 mRS.nAdapter1DSetConstraint(mID, dim.mID, value);
212 }
213
214 public void data(int[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -0800215 mRS.validate();
Jason Samsb8c5a842009-07-31 20:40:47 -0700216 mRS.nAdapter1DData(mID, d);
217 }
218
Jason Samsb8c5a842009-07-31 20:40:47 -0700219 public void data(float[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -0800220 mRS.validate();
Jason Samsb8c5a842009-07-31 20:40:47 -0700221 mRS.nAdapter1DData(mID, d);
222 }
223
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700224 public void subData(int off, int count, int[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -0800225 mRS.validate();
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700226 mRS.nAdapter1DSubData(mID, off, count, d);
227 }
228
Jason Samsb8c5a842009-07-31 20:40:47 -0700229 public void subData(int off, int count, float[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -0800230 mRS.validate();
Jason Samsb8c5a842009-07-31 20:40:47 -0700231 mRS.nAdapter1DSubData(mID, off, count, d);
232 }
233 }
234
235 public Adapter1D createAdapter1D() {
Jason Sams771bebb2009-12-07 12:40:12 -0800236 mRS.validate();
Jason Samsb8c5a842009-07-31 20:40:47 -0700237 int id = mRS.nAdapter1DCreate();
Jason Sams718cd1f2009-12-23 14:35:29 -0800238 if(id == 0) {
239 throw new IllegalStateException("allocation failed.");
Jason Samsb8c5a842009-07-31 20:40:47 -0700240 }
Jason Sams718cd1f2009-12-23 14:35:29 -0800241 mRS.nAdapter1DBindAllocation(id, mID);
Jason Samsb8c5a842009-07-31 20:40:47 -0700242 return new Adapter1D(id, mRS);
243 }
244
245
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700246 public class Adapter2D extends BaseObj {
247 Adapter2D(int id, RenderScript rs) {
Alex Sakhartchouk0de94442010-08-11 14:41:28 -0700248 super(id, rs);
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700249 }
250
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700251 public void setConstraint(Dimension dim, int value) {
Jason Sams771bebb2009-12-07 12:40:12 -0800252 mRS.validate();
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700253 mRS.nAdapter2DSetConstraint(mID, dim.mID, value);
254 }
255
256 public void data(int[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -0800257 mRS.validate();
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700258 mRS.nAdapter2DData(mID, d);
259 }
260
261 public void data(float[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -0800262 mRS.validate();
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700263 mRS.nAdapter2DData(mID, d);
264 }
265
266 public void subData(int xoff, int yoff, int w, int h, int[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -0800267 mRS.validate();
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700268 mRS.nAdapter2DSubData(mID, xoff, yoff, w, h, d);
269 }
270
271 public void subData(int xoff, int yoff, int w, int h, float[] d) {
Jason Sams771bebb2009-12-07 12:40:12 -0800272 mRS.validate();
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700273 mRS.nAdapter2DSubData(mID, xoff, yoff, w, h, d);
274 }
275 }
276
277 public Adapter2D createAdapter2D() {
Jason Sams771bebb2009-12-07 12:40:12 -0800278 mRS.validate();
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700279 int id = mRS.nAdapter2DCreate();
Jason Sams718cd1f2009-12-23 14:35:29 -0800280 if(id == 0) {
281 throw new IllegalStateException("allocation failed.");
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700282 }
Jason Sams718cd1f2009-12-23 14:35:29 -0800283 mRS.nAdapter2DBindAllocation(id, mID);
Jason Samsbd1c3ad2009-08-03 16:03:08 -0700284 return new Adapter2D(id, mRS);
285 }
286
Jason Samsb8c5a842009-07-31 20:40:47 -0700287
288 // creation
289
290 private static BitmapFactory.Options mBitmapOptions = new BitmapFactory.Options();
291 static {
292 mBitmapOptions.inScaled = false;
293 }
294
Jason Sams1bada8c2009-08-09 17:01:55 -0700295 static public Allocation createTyped(RenderScript rs, Type type)
296 throws IllegalArgumentException {
297
Jason Sams771bebb2009-12-07 12:40:12 -0800298 rs.validate();
Jason Sams1bada8c2009-08-09 17:01:55 -0700299 if(type.mID == 0) {
300 throw new IllegalStateException("Bad Type");
301 }
Jason Samsb8c5a842009-07-31 20:40:47 -0700302 int id = rs.nAllocationCreateTyped(type.mID);
Jason Sams43ee06852009-08-12 17:54:11 -0700303 return new Allocation(id, rs, type);
Jason Samsb8c5a842009-07-31 20:40:47 -0700304 }
305
Jason Sams1bada8c2009-08-09 17:01:55 -0700306 static public Allocation createSized(RenderScript rs, Element e, int count)
307 throws IllegalArgumentException {
308
Jason Sams771bebb2009-12-07 12:40:12 -0800309 rs.validate();
Jason Sams768bc022009-09-21 19:41:04 -0700310 Type.Builder b = new Type.Builder(rs, e);
311 b.add(Dimension.X, count);
312 Type t = b.create();
313
314 int id = rs.nAllocationCreateTyped(t.mID);
Jason Samsea84a7c2009-09-04 14:42:41 -0700315 if(id == 0) {
316 throw new IllegalStateException("Bad element.");
Jason Samsb8c5a842009-07-31 20:40:47 -0700317 }
Jason Sams768bc022009-09-21 19:41:04 -0700318 return new Allocation(id, rs, t);
Jason Samsb8c5a842009-07-31 20:40:47 -0700319 }
320
Jason Sams8a647432010-03-01 15:31:04 -0800321 static private Element elementFromBitmap(RenderScript rs, Bitmap b) {
322 final Bitmap.Config bc = b.getConfig();
323 if (bc == Bitmap.Config.ALPHA_8) {
324 return Element.A_8(rs);
325 }
326 if (bc == Bitmap.Config.ARGB_4444) {
327 return Element.RGBA_4444(rs);
328 }
329 if (bc == Bitmap.Config.ARGB_8888) {
330 return Element.RGBA_8888(rs);
331 }
332 if (bc == Bitmap.Config.RGB_565) {
333 return Element.RGB_565(rs);
334 }
335 throw new IllegalStateException("Bad bitmap type.");
336 }
337
338 static private Type typeFromBitmap(RenderScript rs, Bitmap b) {
339 Element e = elementFromBitmap(rs, b);
340 Type.Builder tb = new Type.Builder(rs, e);
341 tb.add(Dimension.X, b.getWidth());
342 tb.add(Dimension.Y, b.getHeight());
343 return tb.create();
344 }
345
Jason Samsb8c5a842009-07-31 20:40:47 -0700346 static public Allocation createFromBitmap(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips)
347 throws IllegalArgumentException {
Jason Samsb8c5a842009-07-31 20:40:47 -0700348
Jason Sams771bebb2009-12-07 12:40:12 -0800349 rs.validate();
Jason Sams8a647432010-03-01 15:31:04 -0800350 Type t = typeFromBitmap(rs, b);
351
Jason Samsea84a7c2009-09-04 14:42:41 -0700352 int id = rs.nAllocationCreateFromBitmap(dstFmt.mID, genMips, b);
Jason Sams718cd1f2009-12-23 14:35:29 -0800353 if(id == 0) {
354 throw new IllegalStateException("Load failed.");
355 }
Jason Sams8a647432010-03-01 15:31:04 -0800356 return new Allocation(id, rs, t);
357 }
358
359 static public Allocation createBitmapRef(RenderScript rs, Bitmap b)
360 throws IllegalArgumentException {
361
362 rs.validate();
363 Type t = typeFromBitmap(rs, b);
364
365 int id = rs.nAllocationCreateBitmapRef(t.getID(), b);
366 if(id == 0) {
367 throw new IllegalStateException("Load failed.");
368 }
369
370 Allocation a = new Allocation(id, rs, t);
371 a.mBitmap = b;
372 return a;
Jason Samsb8c5a842009-07-31 20:40:47 -0700373 }
374
Jason Sams74e02ef2010-01-06 15:10:29 -0800375 static Allocation createFromBitmapBoxed(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips)
Jason Samsb8c5a842009-07-31 20:40:47 -0700376 throws IllegalArgumentException {
Jason Samsb8c5a842009-07-31 20:40:47 -0700377
Jason Sams771bebb2009-12-07 12:40:12 -0800378 rs.validate();
Jason Samsea84a7c2009-09-04 14:42:41 -0700379 int id = rs.nAllocationCreateFromBitmapBoxed(dstFmt.mID, genMips, b);
Jason Sams718cd1f2009-12-23 14:35:29 -0800380 if(id == 0) {
381 throw new IllegalStateException("Load failed.");
382 }
Jason Sams43ee06852009-08-12 17:54:11 -0700383 return new Allocation(id, rs, null);
Jason Samsb8c5a842009-07-31 20:40:47 -0700384 }
385
386 static public Allocation createFromBitmapResource(RenderScript rs, Resources res, int id, Element dstFmt, boolean genMips)
387 throws IllegalArgumentException {
388
Jason Sams771bebb2009-12-07 12:40:12 -0800389 rs.validate();
Romain Guy650a3eb2009-08-31 14:06:43 -0700390 InputStream is = null;
391 try {
392 final TypedValue value = new TypedValue();
393 is = res.openRawResource(id, value);
394
395 int asset = ((AssetManager.AssetInputStream) is).getAssetInt();
Jason Samsea84a7c2009-09-04 14:42:41 -0700396 int allocationId = rs.nAllocationCreateFromAssetStream(dstFmt.mID, genMips,
Romain Guy650a3eb2009-08-31 14:06:43 -0700397 asset);
398
Jason Sams718cd1f2009-12-23 14:35:29 -0800399 if(allocationId == 0) {
400 throw new IllegalStateException("Load failed.");
401 }
Jason Samsea84a7c2009-09-04 14:42:41 -0700402 return new Allocation(allocationId, rs, null);
Romain Guy650a3eb2009-08-31 14:06:43 -0700403 } catch (Exception e) {
404 // Ignore
405 } finally {
406 if (is != null) {
407 try {
408 is.close();
409 } catch (IOException e) {
410 // Ignore
411 }
412 }
413 }
414
415 return null;
Jason Samsb8c5a842009-07-31 20:40:47 -0700416 }
417
418 static public Allocation createFromBitmapResourceBoxed(RenderScript rs, Resources res, int id, Element dstFmt, boolean genMips)
419 throws IllegalArgumentException {
420
Romain Guyf92a0a62010-08-20 15:43:52 -0700421 mBitmapOptions.inPreferredConfig = null;
422 if (dstFmt == rs.mElement_RGBA_8888) {
423 mBitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
424 } else if (dstFmt == rs.mElement_RGB_888) {
425 mBitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
426 } else if (dstFmt == rs.mElement_RGBA_4444) {
427 mBitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_4444;
428 } else if (dstFmt == rs.mElement_RGB_565) {
429 mBitmapOptions.inPreferredConfig = Bitmap.Config.RGB_565;
430 }
431
Jason Samsb8c5a842009-07-31 20:40:47 -0700432 Bitmap b = BitmapFactory.decodeResource(res, id, mBitmapOptions);
433 return createFromBitmapBoxed(rs, b, dstFmt, genMips);
434 }
Alex Sakhartchouk9b949fc2010-06-24 17:15:34 -0700435
436 static public Allocation createFromString(RenderScript rs, String str)
437 throws IllegalArgumentException {
438 byte[] allocArray = null;
439 try {
440 allocArray = str.getBytes("UTF-8");
441 Allocation alloc = Allocation.createSized(rs, Element.U8(rs), allocArray.length);
442 alloc.data(allocArray);
443 return alloc;
444 }
445 catch (Exception e) {
446 Log.e("rs", "could not convert string to utf-8");
447 }
448 return null;
449 }
Jason Samsb8c5a842009-07-31 20:40:47 -0700450}
451
452