android.graphics.PixelFormat#OPAQUE源码实例Demo

下面列出了android.graphics.PixelFormat#OPAQUE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ZhihuDaily   文件: BitmapUtil.java
public static Bitmap drawableToBitmap(Drawable drawable) {
   // 取 drawable 的长宽
   int w = drawable.getIntrinsicWidth();
   int h = drawable.getIntrinsicHeight();

   // 取 drawable 的颜色格式
   Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
           : Bitmap.Config.RGB_565;
   // 建立对应 bitmap
    Bitmap bitmap = Bitmap.createBitmap(w, h, config);
    // 建立对应 bitmap 的画布
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);
    // 把 drawable 内容画到画布中
    drawable.draw(canvas);
    return bitmap;
}
 
源代码2 项目: fangzhuishushenqi   文件: ACache.java
private static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable == null) {
        return null;
    }
    // 取 drawable 的长宽
    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();
    // 取 drawable 的颜色格式
    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE
            ? Bitmap.Config.ARGB_8888
            : Bitmap.Config.RGB_565;
    // 建立对应 bitmap
    Bitmap bitmap = Bitmap.createBitmap(w, h, config);
    // 建立对应 bitmap 的画布
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);
    // 把 drawable 内容画到画布中
    drawable.draw(canvas);
    return bitmap;
}
 
源代码3 项目: MyUtil   文件: CacheUtils.java
private static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable == null) {
        return null;
    }
    // 取 drawable 的长宽
    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();
    // 取 drawable 的颜色格式
    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
            : Bitmap.Config.RGB_565;
    // 建立对应 bitmap
    Bitmap bitmap = Bitmap.createBitmap(w, h, config);
    // 建立对应 bitmap 的画布
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);
    // 把 drawable 内容画到画布中
    drawable.draw(canvas);
    return bitmap;
}
 
源代码4 项目: AndroidBase   文件: Utils.java
/**
 * Drawable → Bitmap
 */
public static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable == null) {
        return null;
    }
    // 取 drawable 的长宽
    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();
    // 取 drawable 的颜色格式
    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
    // 建立对应 bitmap
    Bitmap bitmap = Bitmap.createBitmap(w, h, config);
    // 建立对应 bitmap 的画布
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);
    // 把 drawable 内容画到画布中
    drawable.draw(canvas);
    return bitmap;
}
 
源代码5 项目: RxTools-master   文件: RxImageTool.java
/**
 * drawable转bitmap
 *
 * @param drawable drawable对象
 * @return bitmap对象
 */
public static Bitmap drawable2Bitmap(Drawable drawable) {
    // 取 drawable 的长宽
    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();

    // 取 drawable 的颜色格式
    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
            : Bitmap.Config.RGB_565;
    // 建立对应 bitmap
    Bitmap bitmap = Bitmap.createBitmap(w, h, config);
    // 建立对应 bitmap 的画布
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);
    // 把 drawable 内容画到画布中
    drawable.draw(canvas);
    return bitmap;
}
 
源代码6 项目: ZrcListView   文件: ZrcListView.java
public void setDivider(Drawable divider) {
    if (divider != null) {
        mDividerHeight = divider.getIntrinsicHeight();
    } else {
        mDividerHeight = 0;
    }
    mDivider = divider;
    mDividerIsOpaque = divider == null || divider.getOpacity() == PixelFormat.OPAQUE;
    requestLayout();
    invalidate();
}
 
源代码7 项目: RefreshNow   文件: RefreshNowProgressIndicator.java
@Override
public int getOpacity() {
	final int alpha = paint.getAlpha();
	if (alpha == 0) return PixelFormat.TRANSPARENT;
	if (alpha == 0xff) return PixelFormat.OPAQUE;
	return PixelFormat.TRANSLUCENT;
}
 
源代码8 项目: android_9.0.0_r45   文件: SurfaceView.java
@Override
public void setFormat(int format) {
    // for backward compatibility reason, OPAQUE always
    // means 565 for SurfaceView
    if (format == PixelFormat.OPAQUE)
        format = PixelFormat.RGB_565;

    mRequestedFormat = format;
    if (mSurfaceControl != null) {
        updateSurface();
    }
}
 
源代码9 项目: VideoOS-Android-SDK   文件: DrawableUtil.java
public static Bitmap drawableToBitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else {
        int width = drawable.getIntrinsicWidth();// 取drawable的长宽
        int height = drawable.getIntrinsicHeight();
        Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;// 取drawable的颜色格式
        Bitmap bitmap = Bitmap.createBitmap(width, height, config);// 建立对应bitmap
        Canvas canvas = new Canvas(bitmap);// 建立对应bitmap的画布
        drawable.setBounds(0, 0, width, height);
        drawable.draw(canvas);// 把drawable内容画到画布中
        return bitmap;
    }
}
 
源代码10 项目: Roid-Library   文件: RLImgUtil.java
/**
 * @param drawable
 * @return
 */
public static Bitmap drawableToBitmap(Drawable drawable) {
    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();
    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
            : Bitmap.Config.RGB_565;
    Bitmap bitmap = Bitmap.createBitmap(w, h, config);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);
    drawable.draw(canvas);
    return bitmap;
}
 
源代码11 项目: debugdrawer   文件: DebugDrawerLayout.java
private static boolean hasOpaqueBackground(View v) {
	final Drawable bg = v.getBackground();
	if (bg != null) {
		return bg.getOpacity() == PixelFormat.OPAQUE;
	}
	return false;
}
 
源代码12 项目: android_9.0.0_r45   文件: ImageView.java
@Override
public boolean isOpaque() {
    return super.isOpaque() || mDrawable != null && mXfermode == null
            && mDrawable.getOpacity() == PixelFormat.OPAQUE
            && mAlpha * mViewAlphaScale >> 8 == 255
            && isFilledByImage();
}
 
源代码13 项目: FlyRefresh   文件: MountainSceneDrawable.java
@Override
public int getOpacity() {
    return PixelFormat.OPAQUE;
}
 
源代码14 项目: BlackLight   文件: SlidingUpPanelLayout.java
private static boolean hasOpaqueBackground(View v) {
    final Drawable bg = v.getBackground();
    return bg != null && bg.getOpacity() == PixelFormat.OPAQUE;
}
 
源代码15 项目: toktok-android   文件: SlidingUpPanelLayout.java
private static boolean hasOpaqueBackground(@NonNull View v) {
    final Drawable bg = v.getBackground();
    return bg != null && bg.getOpacity() == PixelFormat.OPAQUE;
}
 
源代码16 项目: Bitocle   文件: DefaultHeaderTransformer.java
private void setupViewsFromStyles(Activity activity, View headerView) {
    final TypedArray styleAttrs = obtainStyledAttrsFromThemeAttr(activity,
            R.attr.ptrHeaderStyle, R.styleable.PullToRefreshHeader);

    // Retrieve the Action Bar size from the app theme or the Action Bar's style
    if (mContentLayout != null) {
        final int height = styleAttrs.getDimensionPixelSize(
                R.styleable.PullToRefreshHeader_ptrHeaderHeight, getActionBarSize(activity));
        mContentLayout.getLayoutParams().height = height;
        mContentLayout.requestLayout();
    }

    // Retrieve the Action Bar background from the app theme or the Action Bar's style (see #93)
    Drawable bg = styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrHeaderBackground)
            ? styleAttrs.getDrawable(R.styleable.PullToRefreshHeader_ptrHeaderBackground)
            : getActionBarBackground(activity);
    if (bg != null) {
        mHeaderTextView.setBackgroundDrawable(bg);

        // If we have an opaque background we can remove the background from the content layout
        if (mContentLayout != null && bg.getOpacity() == PixelFormat.OPAQUE) {
            mContentLayout.setBackgroundResource(0);
        }
    }

    // Retrieve the Action Bar Title Style from the app theme or the Action Bar's style
    Context abContext = headerView.getContext();
    final int titleTextStyle = styleAttrs
            .getResourceId(R.styleable.PullToRefreshHeader_ptrHeaderTitleTextAppearance,
                    getActionBarTitleStyle(abContext));
    if (titleTextStyle != 0) {
        mHeaderTextView.setTextAppearance(abContext, titleTextStyle);
    }

    // Retrieve the Progress Bar Color the style
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrProgressBarColor)) {
        mProgressDrawableColor = styleAttrs.getColor(
                R.styleable.PullToRefreshHeader_ptrProgressBarColor, mProgressDrawableColor);
    }

    mProgressBarStyle = styleAttrs.getInt(
            R.styleable.PullToRefreshHeader_ptrProgressBarStyle, PROGRESS_BAR_STYLE_OUTSIDE);

    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrProgressBarHeight)) {
        mProgressBarHeight = styleAttrs.getDimensionPixelSize(
                R.styleable.PullToRefreshHeader_ptrProgressBarHeight, mProgressBarHeight);
    }

    // Retrieve the text strings from the style (if they're set)
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrPullText)) {
        mPullRefreshLabel = styleAttrs.getString(R.styleable.PullToRefreshHeader_ptrPullText);
    }
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrRefreshingText)) {
        mRefreshingLabel = styleAttrs
                .getString(R.styleable.PullToRefreshHeader_ptrRefreshingText);
    }
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrReleaseText)) {
        mReleaseLabel = styleAttrs.getString(R.styleable.PullToRefreshHeader_ptrReleaseText);
    }

    //SmoothProgressBar Style
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrSmoothProgressBarStyle)) {
        int spbStyleRes = styleAttrs.getResourceId(R.styleable.PullToRefreshHeader_ptrSmoothProgressBarStyle, 0);
        if (spbStyleRes != 0)
            mHeaderProgressBar.applyStyle(spbStyleRes);

    }

    styleAttrs.recycle();
}
 
源代码17 项目: ALLGO   文件: DefaultHeaderTransformer.java
private void setupViewsFromStyles(Activity activity, View headerView) {
    final TypedArray styleAttrs = obtainStyledAttrsFromThemeAttr(activity,
            R.attr.ptrHeaderStyle, R.styleable.PullToRefreshHeader);

    // Retrieve the Action Bar size from the app theme or the Action Bar's style
    if (mContentLayout != null) {
        final int height = styleAttrs
                .getDimensionPixelSize(R.styleable.PullToRefreshHeader_ptrHeaderHeight,
                        getActionBarSize(activity));
        mContentLayout.getLayoutParams().height = height;
        mContentLayout.requestLayout();
    }

    // Retrieve the Action Bar background from the app theme or the Action Bar's style (see #93)
    Drawable bg = styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrHeaderBackground)
            ? styleAttrs.getDrawable(R.styleable.PullToRefreshHeader_ptrHeaderBackground)
            : getActionBarBackground(activity);
    if (bg != null) {
        mHeaderTextView.setBackgroundDrawable(bg);

        // If we have an opaque background we can remove the background from the content layout
        if (mContentLayout != null && bg.getOpacity() == PixelFormat.OPAQUE) {
            mContentLayout.setBackgroundResource(0);
        }
    }

    // Retrieve the Action Bar Title Style from the app theme or the Action Bar's style
    Context abContext = headerView.getContext();
    final int titleTextStyle = styleAttrs
            .getResourceId(R.styleable.PullToRefreshHeader_ptrHeaderTitleTextAppearance,
                    getActionBarTitleStyle(abContext));
    if (titleTextStyle != 0) {
        mHeaderTextView.setTextAppearance(abContext, titleTextStyle);
    }

    // Retrieve the Progress Bar Color the style
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrProgressBarColor)) {
        mUseCustomProgressColor = true;
        mProgressDrawableColor = styleAttrs
                .getColor(R.styleable.PullToRefreshHeader_ptrProgressBarColor, 0);
    }

    // Retrieve the text strings from the style (if they're set)
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrPullText)) {
        mPullRefreshLabel = styleAttrs.getString(R.styleable.PullToRefreshHeader_ptrPullText);
    }
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrRefreshingText)) {
        mRefreshingLabel = styleAttrs
                .getString(R.styleable.PullToRefreshHeader_ptrRefreshingText);
    }
    if (styleAttrs.hasValue(R.styleable.PullToRefreshHeader_ptrReleaseText)) {
        mReleaseLabel = styleAttrs.getString(R.styleable.PullToRefreshHeader_ptrReleaseText);
    }

    styleAttrs.recycle();
}
 
private static boolean hasOpaqueBackground(View v) {
    final Drawable bg = v.getBackground();
    return bg != null && bg.getOpacity() == PixelFormat.OPAQUE;
}
 
源代码19 项目: FileManager   文件: BitmapUtil.java
public static Bitmap drawableToBitmap(Drawable drawable) {

        int w = drawable.getIntrinsicWidth();
        int h = drawable.getIntrinsicHeight();

        Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;

        Bitmap bitmap = Bitmap.createBitmap(w, h, config);

        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, w, h);

        drawable.draw(canvas);
        return bitmap;

    }
 
源代码20 项目: recent-images   文件: ReplaceableBitmapDrawable.java
@Override
public int getOpacity() {
	return PixelFormat.OPAQUE;
}