当前位置: 首页>>代码示例>>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;未经允许,请勿转载。