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


Java BitmapFactory.decodeResource方法代码示例

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


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

示例1: showNotification

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
private void showNotification(String title, String description, Intent intent) {
    String channelID = getNotificationChannelID();

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    Bitmap largeNotificationImage = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelID)
            .setContentIntent(pendingIntent)
            .setContentTitle(title)
            .setContentText(description)
            .setDefaults(Notification.DEFAULT_ALL)
            .setLargeIcon(largeNotificationImage)
            .setSmallIcon(R.drawable.ic_logo);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        builder.setColor(ContextCompat.getColor(this, R.color.colorPrimary));

    Notification notification = builder.build();
    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    // Get the notification manager & publish the notification
    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(Constants.ID_NOTIFICATION_BROADCAST, notification);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:26,代码来源:MessagingService.java

示例2: decodeSampledBitmapFromResource

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
/**
 * Decode and sample down a bitmap from resources to the requested width and
 * height.
 * 
 * @param res
 *            The resources object containing the image data
 * @param resId
 *            The resource id of the image data
 * @param reqWidth
 *            The requested width of the resulting bitmap
 * @param reqHeight
 *            The requested height of the resulting bitmap
 * @param cache
 *            The ImageCache used to find candidate bitmaps for use with
 *            inBitmap
 * @return A bitmap sampled down from the original with the same aspect
 *         ratio and dimensions that are equal to or greater than the
 *         requested width and height
 */
public static Bitmap decodeSampledBitmapFromResource(Resources res,
		int resId, int reqWidth, int reqHeight, ImageCache cache) {

	// BEGIN_INCLUDE (read_bitmap_dimensions)
	// First decode with inJustDecodeBounds=true to check dimensions
	final BitmapFactory.Options options = new BitmapFactory.Options();
	options.inJustDecodeBounds = true;
	BitmapFactory.decodeResource(res, resId, options);

	// Calculate inSampleSize
	options.inSampleSize = calculateInSampleSize(options, reqWidth,
			reqHeight);
	// END_INCLUDE (read_bitmap_dimensions)

	// If we're running on Honeycomb or newer, try to use inBitmap
	if (Utils.hasHoneycomb()) {
		addInBitmapOptions(options, cache);
	}

	// Decode bitmap with inSampleSize set
	options.inJustDecodeBounds = false;
	return BitmapFactory.decodeResource(res, resId, options);
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:43,代码来源:ImageResizer.java

示例3: initialize

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
public void initialize()	{
	// mcontext should be always not null.
	mcfgImage_24 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.setting_gear_24);
	mcfgImage_32 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.setting_gear_32);
	mcfgImage_48 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.setting_gear_48);
	mcfgImage_64 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.setting_gear_64);
	mzoomInImage_24 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_in_24);
	mzoomInImage_32 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_in_32);
	mzoomInImage_48 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_in_48);
	mzoomInImage_64 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_in_64);
	mzoomOutImage_24 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_out_24);
	mzoomOutImage_32 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_out_32);
	mzoomOutImage_48 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_out_48);
	mzoomOutImage_64 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_out_64);
	mxy1To1ZoomImage_24 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_1_24);
	mxy1To1ZoomImage_32 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_1_32);
	mxy1To1ZoomImage_48 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_1_48);
	mxy1To1ZoomImage_64 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_1_64);
	mfitZoomImage_24 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_fit_24);
	mfitZoomImage_32 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_fit_32);
	mfitZoomImage_48 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_fit_48);
	mfitZoomImage_64 = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.zoom_fit_64);
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:24,代码来源:FlatChart.java

示例4: getPlatLogo

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
private Bitmap getPlatLogo(Platform plat) {
	if (plat == null) {
		return null;
	}

	String name = plat.getName();
	if (name == null) {
		return null;
	}

	String resName = "logo_" + plat.getName();
	int resId = getBitmapRes(activity, resName);
	if(resId > 0) {
		return BitmapFactory.decodeResource(activity.getResources(), resId);
	}
	return null;
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:18,代码来源:EditPage.java

示例5: setIcon

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
@Override
public void setIcon(Uri uri) {
    if (mIconUri != null && mIconUri.equals(uri)) {
        return;
    }

    mIconUri = uri;
    if (mFetchBitmapTask != null) {
        mFetchBitmapTask.cancel(true);
    }
    mFetchBitmapTask = new FetchBitmapTask() {
        @Override
        protected void onPostExecute(Bitmap bitmap) {
            if (bitmap == null) {
                bitmap = BitmapFactory.decodeResource(getResources(),
                        R.drawable.album_art_placeholder);
            }
            setIcon(bitmap);
            if (this == mFetchBitmapTask) {
                mFetchBitmapTask = null;
            }
        }
    };

    mFetchBitmapTask.execute(uri);
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:27,代码来源:MiniController.java

示例6: initView

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
private void initView() {
        //模糊化背景图片
        int w = windowManager.getDefaultDisplay().getWidth();
        int h = windowManager.getDefaultDisplay().getHeight();
//        Bitmap bitmap = BitmapFactory.decodeFile(music.getAlbumImgUrl());
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), bcpic[random.nextInt(5)]);
        BlurBitmap blurBitmap = new BlurBitmap();
        bitmap = blurBitmap.blur(bitmap, w, h);
        BGrRelativeLayout.setBackground(new BitmapDrawable(getResources(), bitmap));

        //歌词名
        toolbar_tv.setText(music.getMusicName());

        circleSeekBar.setHan(0);
        //歌词作者
        circleSeekBar.setsingername(music.getSinger());

        lrcTextView.setVisibility(View.INVISIBLE);

        Loadlrc.setVisibility(View.VISIBLE);
        Loadlrc.setText("加载歌词......");

        InitExPlayer();
    }
 
开发者ID:fikyair,项目名称:musicplayer,代码行数:25,代码来源:MusicPlayerActivity.java

示例7: decodeSampledBitmapFromResource

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
public static Bitmap decodeSampledBitmapFromResource(Resources res,
		int resId, int reqWidth, int reqHeight) {

	// First decode with inJustDecodeBounds=true to check dimensions
	final BitmapFactory.Options options = new BitmapFactory.Options();
	options.inJustDecodeBounds = true;
	BitmapFactory.decodeResource(res, resId, options);

	// Calculate inSampleSize
	options.inSampleSize = calculateInSampleSize(options, reqWidth,
			reqHeight);

	// Decode bitmap with inSampleSize set
	options.inJustDecodeBounds = false;
	return BitmapFactory.decodeResource(res, resId, options);
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:17,代码来源:BitmapUtils.java

示例8: getPlatLogo

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
private Bitmap getPlatLogo(Platform plat) {
    if (plat == null || plat.getName() == null) {
        return null;
    }
    int resId = R.getBitmapRes(this.activity, ("logo_" + plat.getName()).toLowerCase());
    if (resId > 0) {
        return BitmapFactory.decodeResource(this.activity.getResources(), resId);
    }
    return null;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:EditPage.java

示例9: initEndAnimationBitmaps

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
/**
 * 初始化最后的爆炸动画
 */
private void initEndAnimationBitmaps() {
    mDataBean.mBitmapsExplodes = new Bitmap[5];
    for (int i = 0; i < 5; i++) {
        int identifier = getContext().getResources().getIdentifier("burst_" + (i + 1), "drawable", getContext().getPackageName());
        Bitmap bitmap = BitmapFactory.decodeResource(getContext().getResources(), identifier);
        mDataBean.mBitmapsExplodes[i] = bitmap;
    }
}
 
开发者ID:halohoop,项目名称:UsoppBubble,代码行数:12,代码来源:UsoppFrameLayout.java

示例10: onPostExecute

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
@Override
protected void onPostExecute(Bitmap result) {
	super.onPostExecute(result);
	pb.setVisibility(View.INVISIBLE);
	photoView.setVisibility(View.VISIBLE);
	if (result != null)
		EaseImageCache.getInstance().put(path, result);
	else
		result = BitmapFactory.decodeResource(context.getResources(),
				R.drawable.ease_default_image);
	photoView.setImageBitmap(result);
}
 
开发者ID:turoDog,项目名称:KTalk,代码行数:13,代码来源:EaseLoadLocalBigImgTask.java

示例11: FriendListItem

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
public FriendListItem(Context context, float ratio) {
	super(context);
	int itemPadding = (int) (ratio * DESIGN_ITEM_PADDING);
	setPadding(itemPadding, 0, itemPadding, 0);
	setMinimumHeight((int) (ratio * DESIGN_ITEM_HEIGHT));
	setBackgroundColor(0xffffffff);

	ivCheck = new ImageView(context);
	LayoutParams lp = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	addView(ivCheck, lp);

	aivIcon = new AsyncImageView(context);
	int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
	lp = new LayoutParams(avatarWidth, avatarWidth);
	lp.gravity = Gravity.CENTER_VERTICAL;
	int avatarMargin = (int) (ratio * DESIGN_AVATAR_PADDING);
	lp.setMargins(avatarMargin, 0, avatarMargin, 0);
	addView(aivIcon, lp);

	tvName = new TextView(context);
	tvName.setTextColor(0xff000000);
	tvName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvName.setSingleLine();
	lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	lp.weight = 1;
	addView(tvName, lp);

	int resId = ResHelper.getBitmapRes(context, "ssdk_oks_classic_check_checked");
	if (resId > 0) {
		bmChd = BitmapFactory.decodeResource(context.getResources(), resId);
	}
	resId = ResHelper.getBitmapRes(getContext(), "ssdk_oks_classic_check_default");
	if (resId > 0) {
		bmUnch = BitmapFactory.decodeResource(context.getResources(), resId);
	}
}
 
开发者ID:android-jian,项目名称:topnews,代码行数:40,代码来源:FriendListItem.java

示例12: onCreateInit

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
@Override
protected void onCreateInit() {
    BitmapFactory.Options opts = new BitmapFactory.Options();
    opts.inSampleSize = 6;    //这个的值压缩的倍数(2的整数倍),数值越小,压缩率越小,图片越清晰
    mBgBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.login_bg,opts);
    //模糊
    Bitmap mFinalMap= BlurBitmap.blur(this,mBgBitmap);
    mLoginBackgroundView.setImageBitmap(mFinalMap);
    popCurrentActivity();
    initPresenter();
    initListener();
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:13,代码来源:LoginActivity.java

示例13: loadTexture

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
public static int loadTexture(Context context, int resourceId) {
    final int[] textureObjectId = new int[1];
    glGenTextures(1, textureObjectId, 0);
    if (textureObjectId[0] == 0) {
        Log.d(TAG, "can't generate a new opengl texture");
        return 0;
    }

    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inScaled = false;
    final Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId, options);
    if (bitmap == null) {
        Log.d(TAG, "resource id" + resourceId + " can't be decoded");
        glDeleteTextures(1, textureObjectId, 0);
        return 0;
    }

    glBindTexture(GL_TEXTURE_2D, textureObjectId[0]);


    //下面是设置图片放大缩小后如何选择像素点进行优化处理来让图片尽量保持清晰
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
    bitmap.recycle();
    glGenerateMipmap(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, 0);
    return textureObjectId[0];
}
 
开发者ID:yjp123456,项目名称:3D_Wallpaper,代码行数:31,代码来源:TextureHelper.java

示例14: shareToWechat

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
private void shareToWechat(boolean timeline) {
    if (isPkgInstalled("com.tencent.mm")) {
        // 初始化一个WXTextObject对象
        Bitmap bmp = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_launcher);
        //WXImageObject imgObj = new WXImageObject(bmp);

        WXWebpageObject webObj = new WXWebpageObject();
        webObj.webpageUrl = shareLink;


        WXMediaMessage msg = new WXMediaMessage();
        msg.mediaObject = webObj;

        Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, 150, 150, true);
        bmp.recycle();
        msg.thumbData = Util.bmpToByteArray(thumbBmp, true);  // 设置缩略图
        msg.description = mContext.getResources().getString(R.string.shareDescription);
        msg.title = shareText;

        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.transaction = buildTransaction("webpage");
        req.message = msg;

        req.scene = timeline ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession;

        // 调用api接口发送数据到微信
        wAPI.sendReq(req);
    } else {
        new CommonDialog(getActivity(), "温馨提示", "未检测到“微信”应用", "确定").show();
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:32,代码来源:BaseDialog.java

示例15: generateIconBitmaps

import android.graphics.BitmapFactory; //导入方法依赖的package包/类
private Bitmap[] generateIconBitmaps(@DrawableRes int origin) {
  if (origin == -1) {
    return null;
  }
  BitmapFactory.Options options = new BitmapFactory.Options();
  options.inJustDecodeBounds = true;
  BitmapFactory.decodeResource(getResources(), origin, options);
  int size = Math.max(options.outWidth, options.outHeight);
  options.inSampleSize = size > iconSize ? size / iconSize : 1;
  options.inJustDecodeBounds = false;
  return generateIconBitmaps(BitmapFactory.decodeResource(getResources(), origin, options));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:MaterialAutoCompleteTextView.java


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