@@ -0,0 +1,2084 @@
+package me.majiajie.https;%0D%0A%0D%0Aimport android.annotation.TargetApi;%0D%0Aimport android.graphics.Bitmap;%0D%0Aimport android.os.Build;%0D%0A%0D%0A/**%0D%0A * Bitmap%E5%B7%A5%E5%85%B7%E7%B1%BB%0D%0A */%0D%0Apublic class BitmapUtil%0D%0A%7B%0D%0A    /**%0D%0A     * %E8%8E%B7%E5%8F%96%7B@link Bitmap%7D%E5%9C%A8%E5%86%85%E5%AD%98%E4%B8%AD%E5%8D%A0%E7%94%A8%E7%9A%84%E5%AD%97%E8%8A%82%E5%A4%A7%E5%B0%8F%0D%0A     */%0D%0A    @TargetApi(Build.VERSION_CODES.KITKAT)%0D%0A    public static int getBitmapByteSize(Bitmap bitmap) %7B%0D%0A        // The return value of getAllocationByteCount silently changes for recycled bitmaps from the%0D%0A        // internal buffer size to row bytes * height. To avoid random inconsistencies in caches, we%0D%0A        // instead assert here.%0D%0A        if (bitmap.isRecycled()) %7B%0D%0A            throw new IllegalStateException(%22Cannot obtain size for recycled Bitmap: %22 + bitmap%0D%0A                    + %22%5B%22 + bitmap.getWidth() + %22x%22 + bitmap.getHeight() + %22%5D %22 + bitmap.getConfig());%0D%0A        %7D%0D%0A        if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.KITKAT) %7B%0D%0A            // Workaround for KitKat initial release NPE in Bitmap, fixed in MR1. See issue #148.%0D%0A            try %7B%0D%0A                return bitmap.getAllocationByteCount();%0D%0A            %7D catch (NullPointerException e) %7B%0D%0A                // Do nothing.%0D%0A            %7D%0D%0A        %7D%0D%0A        return bitmap.getHeight() * bitmap.getRowBytes();%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * %E8%8E%B7%E5%8F%96%7B@link Bitmap%7D%E5%9C%A8%E5%86%85%E5%AD%98%E4%B8%AD%E5%8D%A0%E7%94%A8%E7%9A%84%E5%AD%97%E8%8A%82%E5%A4%A7%E5%B0%8F%0D%0A     */%0D%0A    public static int getBitmapByteSize(int width, int height, Bitmap.Config config) %7B%0D%0A        return width * height * getBytesPerPixel(config);%0D%0A    %7D%0D%0A%0D%0A    private static int getBytesPerPixel(Bitmap.Config config) %7B%0D%0A        // A bitmap by decoding a gif has null %22config%22 in certain environments.%0D%0A        if (config == null) %7B%0D%0A            config = Bitmap.Config.ARGB_8888;%0D%0A        %7D%0D%0A%0D%0A        int bytesPerPixel;%0D%0A        switch (config) %7B%0D%0A            case ALPHA_8:%0D%0A                bytesPerPixel = 1;%0D%0A                break;%0D%0A            case RGB_565:%0D%0A            case ARGB_4444:%0D%0A                bytesPerPixel = 2;%0D%0A                break;%0D%0A            case ARGB_8888:%0D%0A            default:%0D%0A                bytesPerPixel = 4;%0D%0A        %7D%0D%0A        return bytesPerPixel;%0D%0A    %7D%0D%0A%7D%0D%0A

add BitmapUtil