Loading api/current.xml +11 −0 Original line number Original line Diff line number Diff line Loading @@ -76371,6 +76371,17 @@ <parameter name="offsetXY" type="int[]"> <parameter name="offsetXY" type="int[]"> </parameter> </parameter> </method> </method> <method name="getByteCount" return="int" abstract="false" native="false" synchronized="false" static="false" final="true" deprecated="not deprecated" visibility="public" > </method> <method name="getConfig" <method name="getConfig" return="android.graphics.Bitmap.Config" return="android.graphics.Bitmap.Config" abstract="false" abstract="false" graphics/java/android/graphics/Bitmap.java +10 −3 Original line number Original line Diff line number Diff line Loading @@ -19,7 +19,6 @@ package android.graphics; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import java.io.OutputStream; import java.io.OutputStream; import java.nio.Buffer; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteBuffer; Loading Loading @@ -342,7 +341,7 @@ public final class Bitmap implements Parcelable { } } long bufferSize = (long)elements << shift; long bufferSize = (long)elements << shift; long pixelSize = (long)getRowBytes() * getHeight(); long pixelSize = getByteCount(); if (bufferSize < pixelSize) { if (bufferSize < pixelSize) { throw new RuntimeException("Buffer not large enough for pixels"); throw new RuntimeException("Buffer not large enough for pixels"); Loading Loading @@ -378,7 +377,7 @@ public final class Bitmap implements Parcelable { } } long bufferBytes = (long)elements << shift; long bufferBytes = (long)elements << shift; long bitmapBytes = (long)getRowBytes() * getHeight(); long bitmapBytes = getByteCount(); if (bufferBytes < bitmapBytes) { if (bufferBytes < bitmapBytes) { throw new RuntimeException("Buffer not large enough for pixels"); throw new RuntimeException("Buffer not large enough for pixels"); Loading Loading @@ -821,6 +820,14 @@ public final class Bitmap implements Parcelable { return nativeRowBytes(mNativeBitmap); return nativeRowBytes(mNativeBitmap); } } /** * Returns the number of bytes used to store this bitmap's pixels. */ public final int getByteCount() { // int result permits bitmaps up to 46,340 x 46,340 return getRowBytes() * getHeight(); } /** /** * If the bitmap's internal config is in one of the public formats, return * If the bitmap's internal config is in one of the public formats, return * that config, otherwise return null. * that config, otherwise return null. Loading graphics/tests/graphicstests/src/android/graphics/BitmapTest.java +4 −2 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,6 @@ package android.graphics; package android.graphics; import android.graphics.Bitmap; import android.graphics.Color; import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest; import junit.framework.TestCase; import junit.framework.TestCase; Loading @@ -42,6 +40,10 @@ public class BitmapTest extends TestCase { assertEquals("rowbytes", 200, bm2.getRowBytes()); assertEquals("rowbytes", 200, bm2.getRowBytes()); assertEquals("rowbytes", 200, bm3.getRowBytes()); assertEquals("rowbytes", 200, bm3.getRowBytes()); assertEquals("byteCount", 80000, bm1.getByteCount()); assertEquals("byteCount", 40000, bm2.getByteCount()); assertEquals("byteCount", 40000, bm3.getByteCount()); assertEquals("height", 200, bm1.getHeight()); assertEquals("height", 200, bm1.getHeight()); assertEquals("height", 200, bm2.getHeight()); assertEquals("height", 200, bm2.getHeight()); assertEquals("height", 200, bm3.getHeight()); assertEquals("height", 200, bm3.getHeight()); Loading Loading
api/current.xml +11 −0 Original line number Original line Diff line number Diff line Loading @@ -76371,6 +76371,17 @@ <parameter name="offsetXY" type="int[]"> <parameter name="offsetXY" type="int[]"> </parameter> </parameter> </method> </method> <method name="getByteCount" return="int" abstract="false" native="false" synchronized="false" static="false" final="true" deprecated="not deprecated" visibility="public" > </method> <method name="getConfig" <method name="getConfig" return="android.graphics.Bitmap.Config" return="android.graphics.Bitmap.Config" abstract="false" abstract="false"
graphics/java/android/graphics/Bitmap.java +10 −3 Original line number Original line Diff line number Diff line Loading @@ -19,7 +19,6 @@ package android.graphics; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import java.io.OutputStream; import java.io.OutputStream; import java.nio.Buffer; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteBuffer; Loading Loading @@ -342,7 +341,7 @@ public final class Bitmap implements Parcelable { } } long bufferSize = (long)elements << shift; long bufferSize = (long)elements << shift; long pixelSize = (long)getRowBytes() * getHeight(); long pixelSize = getByteCount(); if (bufferSize < pixelSize) { if (bufferSize < pixelSize) { throw new RuntimeException("Buffer not large enough for pixels"); throw new RuntimeException("Buffer not large enough for pixels"); Loading Loading @@ -378,7 +377,7 @@ public final class Bitmap implements Parcelable { } } long bufferBytes = (long)elements << shift; long bufferBytes = (long)elements << shift; long bitmapBytes = (long)getRowBytes() * getHeight(); long bitmapBytes = getByteCount(); if (bufferBytes < bitmapBytes) { if (bufferBytes < bitmapBytes) { throw new RuntimeException("Buffer not large enough for pixels"); throw new RuntimeException("Buffer not large enough for pixels"); Loading Loading @@ -821,6 +820,14 @@ public final class Bitmap implements Parcelable { return nativeRowBytes(mNativeBitmap); return nativeRowBytes(mNativeBitmap); } } /** * Returns the number of bytes used to store this bitmap's pixels. */ public final int getByteCount() { // int result permits bitmaps up to 46,340 x 46,340 return getRowBytes() * getHeight(); } /** /** * If the bitmap's internal config is in one of the public formats, return * If the bitmap's internal config is in one of the public formats, return * that config, otherwise return null. * that config, otherwise return null. Loading
graphics/tests/graphicstests/src/android/graphics/BitmapTest.java +4 −2 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,6 @@ package android.graphics; package android.graphics; import android.graphics.Bitmap; import android.graphics.Color; import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest; import junit.framework.TestCase; import junit.framework.TestCase; Loading @@ -42,6 +40,10 @@ public class BitmapTest extends TestCase { assertEquals("rowbytes", 200, bm2.getRowBytes()); assertEquals("rowbytes", 200, bm2.getRowBytes()); assertEquals("rowbytes", 200, bm3.getRowBytes()); assertEquals("rowbytes", 200, bm3.getRowBytes()); assertEquals("byteCount", 80000, bm1.getByteCount()); assertEquals("byteCount", 40000, bm2.getByteCount()); assertEquals("byteCount", 40000, bm3.getByteCount()); assertEquals("height", 200, bm1.getHeight()); assertEquals("height", 200, bm1.getHeight()); assertEquals("height", 200, bm2.getHeight()); assertEquals("height", 200, bm2.getHeight()); assertEquals("height", 200, bm3.getHeight()); assertEquals("height", 200, bm3.getHeight()); Loading