package android.graphics;public final class Bitmap extends _Original_Bitmap可是我再源码中并没有找到Original_Bitmap这个类,请问大家,这个类在哪里?是不是从C库中调用的???

解决方案 »

  1.   

    我也同问。
    要是看源码,网站上能查到。
    http://www.girlcoding.com/2011/07/android-_original_bitmap/
      

  2.   

    package android.graphics; import android.os.Parcel;import android.os.Parcelable;import android.os.Parcelable.Creator;import android.util.DisplayMetrics;import com.android.tools.layoutlib.create.OverrideMethod;import java.io.OutputStream;import java.nio.Buffer;import java.nio.ByteBuffer;import java.nio.IntBuffer;import java.nio.ShortBuffer; public class _Original_Bitmap implements Parcelable {    public static final int DENSITY_NONE = 0;    public final int mNativeBitmap;    public final boolean mIsMutable;    public byte[] mNinePatchChunk;    public int mWidth = -1;    public int mHeight = -1;    public boolean mRecycled;    public int mDensity = _Original_Bitmap.sDefaultDensity = getDefaultDensity();    public static volatile Matrix sScaleMatrix;    public static volatile int sDefaultDensity = -1;    public static final int WORKING_COMPRESS_STORAGE = 4096;    public static final Parcelable.Creator<_Original_Bitmap> CREATOR = new _Original_Bitmap.1();     public static void setDefaultDensity(int density){        sDefaultDensity = density;    }     public static int getDefaultDensity() {        if (sDefaultDensity >= 0) {            return sDefaultDensity;        }        sDefaultDensity = DisplayMetrics.DENSITY_DEVICE;        return sDefaultDensity;    }        public _Original_Bitmap(int nativeBitmap, boolean isMutable, byte[] ninePatchChunk) {        if (nativeBitmap == 0) {            throw new RuntimeException("internal error: native bitmap is 0");        }        this.mNativeBitmap = nativeBitmap;        this.mIsMutable = isMutable;        this.mNinePatchChunk = ninePatchChunk;    }        public int getDensity() {        return this.mDensity;    }     public void setDensity(int density) {        this.mDensity = density;    }        public void setNinePatchChunk(byte[] chunk) {        this.mNinePatchChunk = chunk;    }        public void recycle() {        if (!this.mRecycled) {            nativeRecycle(this.mNativeBitmap);            this.mNinePatchChunk = null;            this.mRecycled = true;        }    }     public boolean isRecycled() {        return this.mRecycled;    }        public void checkRecycled(String errorMessage) {        if (this.mRecycled)            throw new IllegalStateException(errorMessage);    }     public static void checkXYSign(int x, int y) {        if (x < 0) {            throw new IllegalArgumentException("x must be >= 0");        }        if (y < 0)            throw new IllegalArgumentException("y must be >= 0");    }        public static void checkWidthHeight(int width, int height) {        if (width <= 0) {            throw new IllegalArgumentException("width must be > 0");        }                if (height <= 0)            throw new IllegalArgumentException("height must be > 0");    }     public void copyPixelsToBuffer(Buffer dst) {        int elements = dst.remaining();        int shift;                if ((dst instanceof ByteBuffer)) {            shift = 0;        } else {            if ((dst instanceof ShortBuffer)) {                shift = 1;            } else {                if ((dst instanceof IntBuffer))                    shift = 2;                else                    throw new RuntimeException("unsupported Buffer subclass");            }        }            long bufferSize = elements << shift;        long pixelSize = getRowBytes() * getHeight();         if (bufferSize < pixelSize) {            throw new RuntimeException("Buffer not large enough for pixels");        }         nativeCopyPixelsToBuffer(this.mNativeBitmap, dst);         int position = dst.position();        position = (int)(position + (pixelSize >> shift));        dst.position(position);    }     public void copyPixelsFromBuffer(Buffer src) {        super.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 = elements << shift;        long bitmapBytes = getRowBytes() * getHeight();         if (bufferBytes < bitmapBytes) {            throw new RuntimeException("Buffer not large enough for pixels");        }                nativeCopyPixelsFromBuffer(this.mNativeBitmap, src);    }     public _Original_Bitmap copy(_Original_Bitmap.Config config, boolean isMutable) {        super.checkRecycled("Can't copy a recycled bitmap");                _Original_Bitmap b = nativeCopy(this.mNativeBitmap, config.nativeInt, isMutable);        if (b != null) {            b.mDensity = this.mDensity;        }        return b;    }     public static _Original_Bitmap createScaledBitmap(_Original_Bitmap src, int dstWidth, int dstHeight, boolean filter) {        Matrix m;                synchronized (_Original_Bitmap.class) {            m = sScaleMatrix;            sScaleMatrix = null;        }                if (m == null) {            m = new Matrix();        }         int width = src.getWidth();        int height = src.getHeight();        float sx = dstWidth / width;        float sy = dstHeight / height;        m.setScale(sx, sy);        _Original_Bitmap b = createBitmap(src, 0, 0, width, height, m, filter);         synchronized (_Original_Bitmap.class) {            if (sScaleMatrix == null) {                sScaleMatrix = m;            }        }        return b;    }     public static _Original_Bitmap createBitmap(_Original_Bitmap src) {        return createBitmap(src, 0, 0, src.getWidth(), src.getHeight());    }     public static _Original_Bitmap createBitmap(_Original_Bitmap source, int x, int y, int width, int height) {        return createBitmap(source, x, y, width, height, null, false);    }