当前位置: 首页>>代码示例>>Java>>正文


Java Bitmap.getNinePatchChunk方法代码示例

本文整理汇总了Java中android.graphics.Bitmap.getNinePatchChunk方法的典型用法代码示例。如果您正苦于以下问题:Java Bitmap.getNinePatchChunk方法的具体用法?Java Bitmap.getNinePatchChunk怎么用?Java Bitmap.getNinePatchChunk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Bitmap的用法示例。


在下文中一共展示了Bitmap.getNinePatchChunk方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: a

import android.graphics.Bitmap; //导入方法依赖的package包/类
private Drawable a(String str, Context context) {
    IOException e;
    Drawable createFromStream;
    try {
        InputStream open = context.getApplicationContext().getAssets().open(str);
        if (open == null) {
            return null;
        }
        if (str.endsWith(".9.png")) {
            Bitmap decodeStream = BitmapFactory.decodeStream(open);
            if (decodeStream == null) {
                return null;
            }
            byte[] ninePatchChunk = decodeStream.getNinePatchChunk();
            NinePatch.isNinePatchChunk(ninePatchChunk);
            return new NinePatchDrawable(decodeStream, ninePatchChunk, new Rect(), null);
        }
        createFromStream = Drawable.createFromStream(open, str);
        try {
            open.close();
            return createFromStream;
        } catch (IOException e2) {
            e = e2;
            e.printStackTrace();
            return createFromStream;
        }
    } catch (IOException e3) {
        IOException iOException = e3;
        createFromStream = null;
        e = iOException;
        e.printStackTrace();
        return createFromStream;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:35,代码来源:AuthAgent.java

示例2: a

import android.graphics.Bitmap; //导入方法依赖的package包/类
private Drawable a(String str, Context context) {
    Drawable createFromStream;
    IOException e;
    try {
        InputStream open = context.getApplicationContext().getAssets().open(str);
        if (open == null) {
            return null;
        }
        if (str.endsWith(".9.png")) {
            Bitmap decodeStream = BitmapFactory.decodeStream(open);
            if (decodeStream == null) {
                return null;
            }
            byte[] ninePatchChunk = decodeStream.getNinePatchChunk();
            NinePatch.isNinePatchChunk(ninePatchChunk);
            return new NinePatchDrawable(decodeStream, ninePatchChunk, new Rect(), null);
        }
        createFromStream = Drawable.createFromStream(open, str);
        try {
            open.close();
            return createFromStream;
        } catch (IOException e2) {
            e = e2;
            e.printStackTrace();
            return createFromStream;
        }
    } catch (IOException e3) {
        IOException iOException = e3;
        createFromStream = null;
        e = iOException;
        e.printStackTrace();
        return createFromStream;
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:35,代码来源:AuthAgent.java

示例3: ArtworkFactory

import android.graphics.Bitmap; //导入方法依赖的package包/类
public ArtworkFactory( Context context, int width, int height) {

		mContext = context;
		mRes = mContext.getResources();
		mContentResolver =  context.getContentResolver();
		mLayoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		mWidth = width;
		mHeight = height;

        mContentLabelFontsize = mRes.getDimension(R.dimen.ContentLabel_fontsize);

		mBitmapOptions = new BitmapFactory.Options();
		// RGB565 is OK for the artwork, 888 will be needed only when we add the shadow
		// Also no need for dithering. OpenGL will do a good job at displaying it without.
		//TODO: check if using ARGB888 is not faster since it will be converted after anyway
		mBitmapOptions.inPreferredConfig = Bitmap.Config.RGB_565;
		mBitmapOptions.inDither = ARTWORK_BITMAP_DITHERING;
		mBitmapOptions.inSampleSize = 1; // no sub-sampling
		mBitmapOptions.inJustDecodeBounds = false;

		// Prepare a painter and enable filtering if showing large bitmaps to avoid ugly rendering of the rescaled bitmap
		mPaint = new Paint();
		mPaint.setFilterBitmap(ARTWORK_BITMAP_FILTERING);
		mPaint.setDither(ARTWORK_BITMAP_DITHERING);

		// ======== Now prepare the shadow stuff =========

		// Create the destination bitmap and associate a canvas to it
		// Require ARGB for the shadow effect
		mShadowBitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ARGB_8888 );
		mShadowBitmap.eraseColor(Color.TRANSPARENT);
		mCanvas = new Canvas(mShadowBitmap);

		// Decode the shadow bitmap
		int shadowId = ArchosFeatures.isAndroidTV(mContext)|| ArchosFeatures.isLUDO()?R.drawable.cover_shadow_512:(mWidth==128) ? R.drawable.cover_shadow_128 : R.drawable.cover_shadow_256;
		InputStream is = context.getResources().openRawResource(shadowId);
		mShadow9patchPadding = new Rect();

		// We must use this version of "decode" in order to get the nine-patch padding
		Bitmap shadowNinePatchBitmap = BitmapFactory.decodeStream(is, mShadow9patchPadding, null);
		try {
			is.close();
		} catch (IOException e) {}
		mShadow9patch = new NinePatch(shadowNinePatchBitmap, shadowNinePatchBitmap.getNinePatchChunk(), null);
	}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:47,代码来源:ArtworkFactory.java

示例4: drawNinePath

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 * 绘制 9Path
 * @param c
 * @param bmp
 * @param rect
 */
public void drawNinePath(Canvas c, Bitmap bmp, Rect rect){
    NinePatch patch = new NinePatch(bmp, bmp.getNinePatchChunk(), null);
    patch.draw(c, rect);
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:11,代码来源:RangeSeekBar.java


注:本文中的android.graphics.Bitmap.getNinePatchChunk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。