當前位置: 首頁>>代碼示例>>Java>>正文


Java Drawable.getOpacity方法代碼示例

本文整理匯總了Java中android.graphics.drawable.Drawable.getOpacity方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.getOpacity方法的具體用法?Java Drawable.getOpacity怎麽用?Java Drawable.getOpacity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.Drawable的用法示例。


在下文中一共展示了Drawable.getOpacity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawable2Bitmap

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
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;
}
 
開發者ID:Mrqinlei,項目名稱:ImitateZHRB,代碼行數:20,代碼來源:ACache.java

示例2: drawable2Bitmap

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
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;
}
 
開發者ID:shenhuanet,項目名稱:OpenEyesReading-android,代碼行數:20,代碼來源:ACache.java

示例3: createBitmapFromDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private Bitmap createBitmapFromDrawable(final Drawable drawable) {
    if (drawable == null) {
        return null;
    }
    Bitmap bitmap = null;
    final int intrinsicWidth = drawable.getIntrinsicWidth();
    final int intrinsicHeight = drawable.getIntrinsicHeight();
    try {
        Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
                : Bitmap.Config.RGB_565;
        bitmap = Bitmap.createBitmap(intrinsicWidth, intrinsicHeight,
                config);
    } catch (OutOfMemoryError e) {
        return null;
    }
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, intrinsicWidth, intrinsicHeight);
    drawable.draw(canvas);
    canvas = null;
    return bitmap;
}
 
開發者ID:mangestudio,項目名稱:GCSApp,代碼行數:22,代碼來源:FloatView.java

示例4: drawable2Bitmap

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable == null) {
        return null;
    }

    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;
}
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:20,代碼來源:ACache.java

示例5: drawable2Bitmap

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
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;
}
 
開發者ID:mangestudio,項目名稱:GCSApp,代碼行數:19,代碼來源:ACache.java

示例6: drawable2Bitmap

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Drawable → Bitmap
 */
private static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable == null) {
        return null;
    }
    // Take the length and width of drawable
    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();
    // Take the color format for drawable
    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
    // Establishing corresponding bitmap
    Bitmap bitmap = Bitmap.createBitmap(w, h, config);
    // Create a canvas corresponding to bitmap
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);
    // The content of the drawable to the canvas
    drawable.draw(canvas);
    return bitmap;
}
 
開發者ID:Jusenr,項目名稱:androidtools,代碼行數:22,代碼來源:DiskFileCacheHelper.java

示例7: toBitmap2

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * drawable 轉換為 Bitmap.
 *
 * @param drawable Drawable
 * @return Bitmap
 */
private static Bitmap toBitmap2(Drawable drawable)
{
    Bitmap bitmap;
    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.createBitmap(w, h, config);
    //注意,下麵三行代碼要用到,否在在View或者surfaceview裏的canvas.drawBitmap會看不到圖
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);
    drawable.draw(canvas);
    return bitmap;
}
 
開發者ID:Ayvytr,項目名稱:EasyAndroid,代碼行數:22,代碼來源:BitmapTool.java

示例8: viewIsOpaque

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private static boolean viewIsOpaque(View v) {
    if (ViewCompat.isOpaque(v)) {
        return true;
    }
    if (VERSION.SDK_INT >= 18) {
        return false;
    }
    Drawable bg = v.getBackground();
    if (bg == null) {
        return false;
    }
    if (bg.getOpacity() != -1) {
        return false;
    }
    return true;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:17,代碼來源:SlidingPaneLayout.java

示例9: drawableToBitmap

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
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;
}
 
開發者ID:EggUncle,項目名稱:XposedNavigationBar,代碼行數:14,代碼來源:ImageUtil.java

示例10: drawableToBitamp

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private static Bitmap drawableToBitamp(Drawable drawable) {
    Bitmap bitmap;
    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.createBitmap(w, h, config);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);
    drawable.draw(canvas);
    return bitmap;
}
 
開發者ID:vitaviva,項目名稱:MultipleTheme,代碼行數:14,代碼來源:ThemedImageView.java

示例11: drawableToBitmap

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
static Bitmap drawableToBitmap(Drawable drawable) // drawable 轉換成bitmap
{
    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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:WaveView.java

示例12: viewIsOpaque

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private static boolean viewIsOpaque(View v) {
    if (ViewCompat.isOpaque(v)) return true;

    // View#isOpaque didn't take all valid opaque scrollbar modes into account
    // before API 18 (JB-MR2). On newer devices rely solely on isOpaque above and return false
    // here. On older devices, check the view's background drawable directly as a fallback.
    if (Build.VERSION.SDK_INT >= 18) return false;

    final Drawable bg = v.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }
    return false;
}
 
開發者ID:Jusenr,項目名稱:AppFirCloud,代碼行數:15,代碼來源:ResideLayout.java

示例13: drawable2Bitmap

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Drawable 轉 Bitmap
 *
 * @param drawable Drawable
 * @return Bitmap
 */
private Bitmap drawable2Bitmap(Drawable drawable) {
    // 取 drawable 的長寬
    int width = drawable.getIntrinsicWidth();
    int height = drawable.getIntrinsicHeight();
    // 取 drawable 的顏色格式
    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
    // 建立對應 bitmap
    Bitmap bitmap = Bitmap.createBitmap(width, height, config);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, width, height);
    drawable.draw(canvas);
    return bitmap;
}
 
開發者ID:ZhouKanZ,項目名稱:SweepRobot,代碼行數:20,代碼來源:RockerView.java

示例14: hasOpaqueBackground

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private static boolean hasOpaqueBackground(View v) {
	final Drawable bg = v.getBackground();
	return bg != null && bg.getOpacity() == PixelFormat.OPAQUE;
}
 
開發者ID:dibakarece,項目名稱:DMAudioStreamer,代碼行數:5,代碼來源:SlidingUpPanelLayout.java

示例15: hasOpaqueBackground

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private static boolean hasOpaqueBackground(View v) {
    final Drawable bg = v.getBackground();
    return bg != null && bg.getOpacity() == PixelFormat.OPAQUE;
}
 
開發者ID:eventtus,項目名稱:photo-editor-android,代碼行數:5,代碼來源:SlidingUpPanelLayout.java


注:本文中的android.graphics.drawable.Drawable.getOpacity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。