예제 #1
0
 public virtual int getHeight()
 {
     return(mBitmap.getHeight());
 }
예제 #2
0
        private static android.graphics.Bitmap finishDecode(android.graphics.Bitmap bm, android.graphics.Rect
                                                            outPadding, android.graphics.BitmapFactory.Options opts)
        {
            if (bm == null || opts == null)
            {
                return(bm);
            }
            int density = opts.inDensity;

            if (density == 0)
            {
                return(bm);
            }
            bm.setDensity(density);
            int targetDensity = opts.inTargetDensity;

            if (targetDensity == 0 || density == targetDensity || density == opts.inScreenDensity)
            {
                return(bm);
            }
            byte[] np          = bm.getNinePatchChunk();
            bool   isNinePatch = np != null && android.graphics.NinePatch.isNinePatchChunk(np);

            if (opts.inScaled || isNinePatch)
            {
                float scale = targetDensity / (float)density;
                // TODO: This is very inefficient and should be done in native by Skia
                android.graphics.Bitmap oldBitmap = bm;
                bm = android.graphics.Bitmap.createScaledBitmap(oldBitmap, (int)(bm.getWidth() *
                                                                                 scale + 0.5f), (int)(bm.getHeight() * scale + 0.5f), true);
                oldBitmap.recycle();
                if (isNinePatch)
                {
                    np = nativeScaleNinePatch(np, scale, outPadding);
                    bm.setNinePatchChunk(np);
                }
                bm.setDensity(targetDensity);
            }
            return(bm);
        }