summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-01-22 00:13:42 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-01-22 00:13:42 -0800
commitf1e484acb594a726fb57ad0ae4cfe902c7f35858 (patch)
tree99d2b34512f0dc2ae67666e756c1cfcd331e5fe3 /graphics/java
parent22f7dfd23490a3de2f21ff96949ba47003aac8f8 (diff)
downloadframeworks_base-f1e484acb594a726fb57ad0ae4cfe902c7f35858.zip
frameworks_base-f1e484acb594a726fb57ad0ae4cfe902c7f35858.tar.gz
frameworks_base-f1e484acb594a726fb57ad0ae4cfe902c7f35858.tar.bz2
auto import from //branches/cupcake/...@127436
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/Bitmap.java32
-rw-r--r--graphics/java/android/graphics/BitmapFactory.java5
-rw-r--r--graphics/java/android/graphics/drawable/LayerDrawable.java8
3 files changed, 36 insertions, 9 deletions
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 501c99f..dc16c39 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -184,6 +184,37 @@ public final class Bitmap implements Parcelable {
}
/**
+ * Copy the pixels from the buffer, beginning at the current position,
+ * overwriting the bitmap's pixels. The data in the buffer is not changed
+ * in any way (unlike setPixels(), which converts from unpremultipled 32bit
+ * to whatever the bitmap's native format is.
+ */
+ public void copyPixelsFromBuffer(Buffer src) {
+ checkRecycled("copyPixelsFromBuffer called on recycled bitmap");
+
+ int elements = src.remaining();
+ int shift;
+ if (src instanceof ByteBuffer) {
+ shift = 0;
+ } else if (src instanceof ShortBuffer) {
+ shift = 1;
+ } else if (src instanceof IntBuffer) {
+ shift = 2;
+ } else {
+ throw new RuntimeException("unsupported Buffer subclass");
+ }
+
+ long bufferBytes = (long)elements << shift;
+ long bitmapBytes = (long)getRowBytes() * getHeight();
+
+ if (bufferBytes < bitmapBytes) {
+ throw new RuntimeException("Buffer not large enough for pixels");
+ }
+
+ nativeCopyPixelsFromBuffer(mNativeBitmap, src);
+ }
+
+ /**
* Tries to make a new bitmap based on the dimensions of this bitmap,
* setting the new bitmap's config to the one specified, and then copying
* this bitmap's pixels into the new bitmap. If the conversion is not
@@ -794,6 +825,7 @@ public final class Bitmap implements Parcelable {
int y, int width, int height);
private static native void nativeCopyPixelsToBuffer(int nativeBitmap,
Buffer dst);
+ private static native void nativeCopyPixelsFromBuffer(int nb, Buffer src);
private static native Bitmap nativeCreateFromParcel(Parcel p);
// returns true on success
diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java
index d1e6090..2c3f543 100644
--- a/graphics/java/android/graphics/BitmapFactory.java
+++ b/graphics/java/android/graphics/BitmapFactory.java
@@ -304,11 +304,6 @@ public class BitmapFactory {
bm = nativeDecodeStream(is, tempStorage, outPadding, opts);
}
- try {
- is.reset();
- } catch (IOException ex) {
- // ignore
- }
return bm;
}
diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java
index fa5ed0a..59dfbd4 100644
--- a/graphics/java/android/graphics/drawable/LayerDrawable.java
+++ b/graphics/java/android/graphics/drawable/LayerDrawable.java
@@ -340,10 +340,10 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
final int N = mLayerState.mNum;
for (int i=0; i<N; i++) {
reapplyPadding(i, array[i]);
- padding.left = Math.max(padding.left, mPaddingL[i]);
- padding.top = Math.max(padding.top, mPaddingT[i]);
- padding.right = Math.max(padding.right, mPaddingR[i]);
- padding.bottom = Math.max(padding.bottom, mPaddingB[i]);
+ padding.left += mPaddingL[i];
+ padding.top += mPaddingT[i];
+ padding.right += mPaddingR[i];
+ padding.bottom += mPaddingB[i];
}
return true;
}