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


Java PixelFormat類代碼示例

本文整理匯總了Java中android.graphics.PixelFormat的典型用法代碼示例。如果您正苦於以下問題:Java PixelFormat類的具體用法?Java PixelFormat怎麽用?Java PixelFormat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: onCreate

import android.graphics.PixelFormat; //導入依賴的package包/類
@Override
public void onCreate() {

    myView = new MyFilterView(this);

    mParams = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                    | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
            PixelFormat.TRANSLUCENT);

    mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    mWindowManager.addView(myView, mParams);

    super.onCreate();
}
 
開發者ID:webianks,項目名稱:Crimson,代碼行數:20,代碼來源:ScreenFilterService.java

示例2: testGetOpacity

import android.graphics.PixelFormat; //導入依賴的package包/類
@Test
public void testGetOpacity() throws Exception {
  BorderDrawable opaque = new BorderDrawable();
  opaque.setColor(Color.GREEN);
  assertThat(opaque.getOpacity(), is(PixelFormat.OPAQUE));

  BorderDrawable transparent = new BorderDrawable();
  transparent.setColor(WXResourceUtils.getColor("#00ff0000"));
  assertThat(transparent.getOpacity(), is(PixelFormat.TRANSPARENT));

  BorderDrawable half = new BorderDrawable();
  half.setColor(WXResourceUtils.getColor("#aaff0000"));
  assertThat(half.getOpacity(), is(PixelFormat.TRANSLUCENT));

  BorderDrawable changeAlpha = new BorderDrawable();
  changeAlpha.setColor(Color.RED);
  changeAlpha.setAlpha(15);
  assertThat(changeAlpha.getOpacity(), is(PixelFormat.TRANSLUCENT));
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:20,代碼來源:BorderDrawableTest.java

示例3: showKeyguardView

import android.graphics.PixelFormat; //導入依賴的package包/類
@Nullable
private View showKeyguardView (boolean showSettings) {
    if (Build.VERSION.SDK_INT >= 23) {
        if (!Settings.canDrawOverlays(mContext)) {
            if (!showSettings)
                return null;
            Intent i = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
            mContext.startActivity(i);
            return null;
        }
    }
    View keyguardView = LayoutInflater.from(mContext).inflate(R.layout.layout_keyguard, null);
    WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams();
    wmParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    wmParams.format = PixelFormat.TRANSPARENT;
    wmParams.flags=WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
            | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
    wmParams.width=WindowManager.LayoutParams.MATCH_PARENT;
    wmParams.height= WindowManager.LayoutParams.MATCH_PARENT;
    mManager.addView(keyguardView, wmParams);
    mContext.startActivity(new Intent(mContext, KeyguardLiveActivity.class));
    return keyguardView;
}
 
開發者ID:TaRGroup,項目名稱:Keyguard,代碼行數:25,代碼來源:MaskWindowUtils.java

示例4: drawableToBitmap

import android.graphics.PixelFormat; //導入依賴的package包/類
public static Bitmap drawableToBitmap(Drawable drawable) {

        Bitmap bitmap = Bitmap
                        .createBitmap(
                            drawable.getIntrinsicWidth(),
                            drawable.getIntrinsicHeight(),
                            drawable.getOpacity() != PixelFormat.OPAQUE ? Config.ARGB_8888
                            : Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);

        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                           drawable.getIntrinsicHeight());
        drawable.draw(canvas);

        return bitmap;

    }
 
開發者ID:zqHero,項目名稱:rongyunDemo,代碼行數:18,代碼來源:BitmapUtils.java

示例5: buildLuminanceSource

import android.graphics.PixelFormat; //導入依賴的package包/類
/**
 * A factory method to build the appropriate LuminanceSource object based on the format
 * of the preview buffers, as described by Camera.Parameters.
 *
 * @param data A preview frame.
 * @param width The width of the image.
 * @param height The height of the image.
 * @return A PlanarYUVLuminanceSource instance.
 */
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) {
	Rect rect = getFramingRectInPreview();
	int previewFormat = configManager.getPreviewFormat();
	String previewFormatString = configManager.getPreviewFormatString();
	switch (previewFormat) {
	// This is the standard Android format which all devices are REQUIRED to support.
	// In theory, it's the only one we should ever care about.
	case PixelFormat.YCbCr_420_SP:
		// This format has never been seen in the wild, but is compatible as we only care
		// about the Y channel, so allow it.
	case PixelFormat.YCbCr_422_SP:
		return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
				rect.width(), rect.height());
	default:
		// The Samsung Moment incorrectly uses this variant instead of the 'sp' version.
		// Fortunately, it too has all the Y data up front, so we can read it.
		if ("yuv420p".equals(previewFormatString)) {
			return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
					rect.width(), rect.height());
		}
	}
	throw new IllegalArgumentException("Unsupported picture format: " +
			previewFormat + '/' + previewFormatString);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:34,代碼來源:CameraManager.java

示例6: drawable2Bitmap

import android.graphics.PixelFormat; //導入依賴的package包/類
private static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        if (bitmapDrawable.getBitmap() != null) {
            return bitmapDrawable.getBitmap();
        }
    }
    Bitmap bitmap;
    if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
        bitmap = Bitmap.createBitmap(1, 1,
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    } else {
        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    }
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
 
開發者ID:pan2yong22,項目名稱:AndroidUtilCode-master,代碼行數:21,代碼來源:CacheUtils.java

示例7: SurfaceViewTemplate

import android.graphics.PixelFormat; //導入依賴的package包/類
public SurfaceViewTemplate(Context context, AttributeSet attrs) {
    super(context, attrs);

    mHolder = getHolder();
    mHolder.addCallback(this);

    // 設置Surface在Window(普通視圖架構)之上
    setZOrderOnTop(true);
    // 設置色彩格式,半透明
    mHolder.setFormat(PixelFormat.TRANSLUCENT);

    // 設置可獲得焦點
    setFocusable(true);
    setFocusableInTouchMode(true);

    // 設置保持屏幕亮
    this.setKeepScreenOn(true);
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:19,代碼來源:SurfaceViewTemplate.java

示例8: drawable2Bitmap

import android.graphics.PixelFormat; //導入依賴的package包/類
private Bitmap drawable2Bitmap(final Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        if (bitmapDrawable.getBitmap() != null) {
            return bitmapDrawable.getBitmap();
        }
    }
    Bitmap bitmap;
    if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
        bitmap = Bitmap.createBitmap(1, 1,
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    } else {
        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    }
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:21,代碼來源:SpanUtils.java

示例9: drawable2Bitmap

import android.graphics.PixelFormat; //導入依賴的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:TaRGroup,項目名稱:CoolApk-Console,代碼行數:20,代碼來源:ACache.java

示例10: drawable2Bitmap

import android.graphics.PixelFormat; //導入依賴的package包/類
/**
 * drawable轉bitmap
 *
 * @param drawable drawable對象
 * @return bitmap
 */
public static Bitmap drawable2Bitmap(final Drawable drawable) {
	if (drawable instanceof BitmapDrawable) {
		BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
		if (bitmapDrawable.getBitmap() != null) {
			return bitmapDrawable.getBitmap();
		}
	}
	Bitmap bitmap;
	if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
		bitmap = Bitmap.createBitmap(1, 1,
				drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
	} else {
		bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
				drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
	}
	Canvas canvas = new Canvas(bitmap);
	drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
	drawable.draw(canvas);
	return bitmap;
}
 
開發者ID:MobClub,項目名稱:BBSSDK-for-Android,代碼行數:27,代碼來源:ImageUtils.java

示例11: setPreviewCallback

import android.graphics.PixelFormat; //導入依賴的package包/類
/** 設置回調 */
protected void setPreviewCallback() {
	Size size = mParameters.getPreviewSize();
	if (size != null) {
		PixelFormat pf = new PixelFormat();
		PixelFormat.getPixelFormatInfo(mParameters.getPreviewFormat(), pf);
		int buffSize = size.width * size.height * pf.bitsPerPixel / 8;
		try {
			camera.addCallbackBuffer(new byte[buffSize]);
			camera.addCallbackBuffer(new byte[buffSize]);
			camera.addCallbackBuffer(new byte[buffSize]);
			camera.setPreviewCallbackWithBuffer(this);
		} catch (OutOfMemoryError e) {
			Log.e("Yixia", "startPreview...setPreviewCallback...", e);
		}
		Log.e("Yixia", "startPreview...setPreviewCallbackWithBuffer...width:" + size.width + " height:" + size.height);
	} else {
		camera.setPreviewCallback(this);
	}
}
 
開發者ID:NullUsera,項目名稱:meipai-Android,代碼行數:21,代碼來源:MediaRecorderBase.java

示例12: drawable2Bitmap

import android.graphics.PixelFormat; //導入依賴的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

示例13: startCameraPreview

import android.graphics.PixelFormat; //導入依賴的package包/類
public boolean startCameraPreview(){
	try {
		Camera.Parameters parameters = camera.getParameters();
		parameters.setPictureFormat(PixelFormat.JPEG);
		//parameters.setPictureSize(surfaceView.getWidth(), surfaceView.getHeight());  // 部分定製手機,無法正常識別該方法。
		parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
		parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);//1連續對焦
		setDispaly(parameters, camera);
		camera.setParameters(parameters);
		camera.startPreview();
		camera.cancelAutoFocus();//隻有加上了這一句,才會自動對焦。
	}catch (RuntimeException e){
		Toast.makeText(context, "該手機不支持參數設定", Toast.LENGTH_LONG).show();
	}
	return true;
}
 
開發者ID:MarukoZ,項目名稱:FaceRecognition,代碼行數:17,代碼來源:CameraInterface.java

示例14: TooltipPopup

import android.graphics.PixelFormat; //導入依賴的package包/類
TooltipPopup(Context context) {
    mContext = context;

    mContentView = LayoutInflater.from(mContext).inflate(R.layout.appcompat_tooltip, null);
    mMessageView = (TextView) mContentView.findViewById(R.id.message);

    mLayoutParams.setTitle(getClass().getSimpleName());
    mLayoutParams.packageName = mContext.getPackageName();
    mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;
    mLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mLayoutParams.format = PixelFormat.TRANSLUCENT;
    mLayoutParams.windowAnimations = R.style.Animation_CrossPort_Tooltip;
    mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
}
 
開發者ID:commonsguy,項目名稱:cwac-crossport,代碼行數:17,代碼來源:TooltipPopup.java

示例15: addToWindowManager

import android.graphics.PixelFormat; //導入依賴的package包/類
public void addToWindowManager() {
    WindowManager.LayoutParams windowLayoutParams = new WindowManager.LayoutParams(
            CANVAS_WIDTH,
            CANVAS_HEIGHT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);
    windowLayoutParams.gravity = Gravity.BOTTOM | Gravity.END;

    mLinearLayout = new LinearLayout(mContext);
    mLinearLayout.setBackgroundColor(Color.BLACK);
    mWindowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    mWindowManager.addView(mLinearLayout, windowLayoutParams);

    TextView textView = new TextView(mContext);
    textView.setTextColor(Color.RED);
    textView.setText(
            String.format("Name: %s \n Code: %s",
                    mPackageInfo.versionName,
                    mPackageInfo.versionCode)
    );
    mLinearLayout.addView(textView);
}
 
開發者ID:tatocaster,項目名稱:BuildNumberOverlay,代碼行數:24,代碼來源:OverlayView.java


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