微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.graphics.PixelFormat的实例源码

项目:Crimson    文件ScreenFilterService.java   
@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();
}
项目:ucar-weex-core    文件BorderDrawableTest.java   
@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));
}
项目:Keyguard    文件MaskWindowUtils.java   
@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;
}
项目:rongyunDemo    文件BitmapUtils.java   
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,drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight());
        drawable.draw(canvas);

        return bitmap;

    }
项目:GitHub    文件CameraManager.java   
/**
 * 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,rect.height());
        }
    }
    throw new IllegalArgumentException("Unsupported picture format: " +
            previewFormat + '/' + previewFormatString);
}
项目:AndroidUtilCode-master    文件CacheUtils.java   
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.getopacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    }
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0,canvas.getWidth(),canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
项目:decoy    文件SurfaceViewTemplate.java   
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);
}
项目:HeadlineNews    文件SpanUtils.java   
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,canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
项目:CoolApk-Console    文件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,w,h);
    // 把 drawable 内容画到画布中
    drawable.draw(canvas);
    return bitmap;
}
项目:BBSSDK-for-Android    文件ImageUtils.java   
/**
 * 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,canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
项目:meipai-Android    文件MediaRecorderBase.java   
/** 设置回调 */
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);
    }
}
项目:AndroidBasicLibs    文件ACache.java   
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,config);

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

    drawable.draw(canvas);
    return bitmap;
}
项目:FaceRecognition    文件CameraInterface.java   
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;
}
项目:cwac-crossport    文件TooltipPopup.java   
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;
}
项目:BuildNumberOverlay    文件OverlayView.java   
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);
}
项目:mao-android    文件BaseCameraview.java   
private void init() {
    setEGLContextClientVersion(2);
    setEGLConfigChooser(8,8,16,0);
    getHolder().setFormat(PixelFormat.RGBA_8888);
    setRenderer(this);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

    float[] cube = Openglutils.CUBE;
    mCubeBuffer = ByteBuffer.allocateDirect(cube.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
    mCubeBuffer.put(cube);

    float[] textureCords = Openglutils.getTextureCords(90,mCameraId == CameraInfo.CAMERA_FACING_FRONT,true);
    mTextureBuffer = ByteBuffer.allocateDirect(textureCords.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
    mTextureBuffer.put(textureCords);

    List<CameraFilter> filters = new ArrayList<>();
    filters.add(mCameraInputFilter);
    filters.addAll(initFilters());
    mCameraFilterGroup = new CameraFilterGroup(filters);
}
项目:Mobike    文件CameraManager.java   
/**
 * 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 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,rect.height());
        default:
            // The Samsung Moment incorrectly uses this variant instead of the 'sp' version.
            // Fortunately,so we can read it.
            if ("yuv420p".equals(previewFormatString)) {
                return new PlanarYUVluminanceSource(data,rect.height());
            }
    }
    throw new IllegalArgumentException("Unsupported picture format: " +
            previewFormat + '/' + previewFormatString);
}
项目:EVideoRecorder    文件ERecorderActivity.java   
@Override
protected void initView() {

    mSurfaceview = (SurfaceView) findViewById(R.id.surfaceview);
    mRlTakeVedio = (RelativeLayout) findViewById(R.id.rl_take_vedio);
    mIvCancel = (ImageView) findViewById(R.id.iv_cancel);
    mTrpbController = (TimeRoundProgressBar) findViewById(R.id.trpb_controller);
    mRlConfrmVedio = (RelativeLayout) findViewById(R.id.rl_confrm_vedio);
    mIvDelete = (ImageView) findViewById(R.id.iv_delete);
    mIvConfirm = (ImageView) findViewById(R.id.iv_confirm);


    mDialog = ERecorderActivityImpl.getCreateVedioDialog(getActivity());
    mTrpbController.setMax(mRecordTime);

    SurfaceHolder holder = mSurfaceview.getHolder();// 取得holder
    holder.setFormat(PixelFormat.TRANSPARENT);
    holder.setKeepScreenOn(true);
    holder.addCallback(this); // holder加入回调接口
}
项目:RLibrary    文件Bmputil.java   
/**
 * Drawable转换为Bitmap
 *
 * @param drawable the drawable
 * @return bitmap
 */
public static Bitmap getBitmap(Drawable drawable) {
    if (drawable == null)
        return null;

    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else {
        Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),drawable.getopacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0,drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    }
}
项目:RoadLab-Pro    文件CustomMapView.java   
private int detectBestPixelFormat() {

        //Skip check if this is a new device as it will be RGBA_8888 by default.
        if (isRGBA_8888ByDefault) {
            return PixelFormat.RGBA_8888;
        }

        Context context = getContext();
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        display display = wm.getDefaultdisplay();

        //Get display pixel format
        int displayFormat = display.getPixelFormat();

        if ( PixelFormat.formatHasAlpha(displayFormat) ) {
            return displayFormat;
        } else {
            return PixelFormat.RGB_565;//Fallback for those who don't support Alpha
        }
    }
项目:XposednavigationBar    文件LightAndVolumeController.java   
protected void showDialog(Context context) {
    final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    int h = getNavbarHeight(context);
    int w = WindowManager.LayoutParams.MATCH_PARENT;
    WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(w,WindowManager.LayoutParams.TYPE_TOAST,PixelFormat.TRANSLUCENT);
    layoutParams.gravity = Gravity.BottOM;

    ViewGroup viewGroup;
    if (mType == LIGHT) {
        viewGroup = getLightPanel(context);
    } else {
        viewGroup = getVolumePanel(context);
    }

    if (lightPanel != null && lightPanel.isAttachedToWindow()) {
        wm.removeView(lightPanel);
    }
    if (volumePanel != null && volumePanel.isAttachedToWindow()) {
        wm.removeView(volumePanel);
    }

    wm.addView(viewGroup,layoutParams);
}
项目:AndroidUtilCode-master    文件ImageUtils.java   
/**
 * drawable转bitmap
 *
 * @param drawable drawable对象
 * @return bitmap
 */
public 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,canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
项目:OSchina_resources_android    文件KJDragGridView.java   
/**
 * 创建拖动的镜像
 *
 * @param bitmap
 * @param downX  按下的点相对父控件的X坐标
 * @param downY  按下的点相对父控件的X坐标
 */
private void createDragImage(Bitmap bitmap,int downX,int downY) {
    mWindowLayoutParams = new WindowManager.LayoutParams();
    mWindowLayoutParams.format = PixelFormat.TRANSLUCENT; // 图片之外的其他地方透明

    mWindowLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    mWindowLayoutParams.x = downX - mPoint2ItemLeft + mOffset2Left;
    mWindowLayoutParams.y = downY - mPoint2ItemTop + mOffset2Top
            - mStatusHeight;
    mWindowLayoutParams.alpha = 0.55f; // 透明度

    mWindowLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;

    mDragImageView = new ImageView(getContext());
    mDragImageView.setimageBitmap(bitmap);
    mWindowManager.addView(mDragImageView,mWindowLayoutParams);
}
项目:MyFire    文件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);
    // 把 drawable 内容画到画布中
    drawable.draw(canvas);
    return bitmap;
}
项目:RLibrary    文件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);
    // 把 drawable 内容画到画布中
    drawable.draw(canvas);
    return bitmap;
}
项目:Accessibility    文件BitmapUtils.java   
public static Bitmap drawabletoBitamp(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = ((BitmapDrawable) drawable);
        return bitmapDrawable.getBitmap();
    } else {
        Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),drawable.getopacity() != PixelFormat.OPAQUE ? Config.ARGB_8888 : Config.RGB_565);

        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0,drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    }
}
项目:ucar-weex-core    文件WXViewUtils.java   
@Opacity
public static int getopacityFromColor(int color) {
  int colorAlpha = color >>> 24;
  if (colorAlpha == 255) {
    return PixelFormat.OPAQUE;
  } else if (colorAlpha == 0) {
    return PixelFormat.TRANSPARENT;
  } else {
    return PixelFormat.TRANSLUCENT;
  }
}
项目:Widgets    文件SquareImageView.java   
/**
 * 将Drawable转换为Bitmap
 *
 * @param drawable 要转换的Drawable
 * @return 转换后的Bitmap
 */
private Bitmap d2b(Drawable drawable) {
    if (null != drawable) {
        if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();
        } else {
            Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),drawable.getopacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
            Canvas canvas = new Canvas(bitmap);
            drawable.setBounds(0,drawable.getIntrinsicHeight());
            drawable.draw(canvas);
            return bitmap;
        }
    }
    return null;
}
项目:Zxing    文件CameraManager.java   
/**
 * 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.
 */
@SuppressWarnings("deprecation")
public PlanarYUVluminanceSource buildluminanceSource(byte[] data,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,but is compatible as
        // we only care
        // about the Y channel,rect.height());
    default:
        // The Samsung Moment incorrectly uses this variant instead of the
        // 'sp' version.
        // Fortunately,so we can read
        // it.
        if ("yuv420p".equals(previewFormatString)) {
            return new PlanarYUVluminanceSource(data,rect.height());
        }
    }
    throw new IllegalArgumentException("Unsupported picture format: "
            + previewFormat + '/' + previewFormatString);
}
项目:RX_Demo    文件ResideLayout.java   
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;
}
项目:tvConnect_android    文件ImageSurfaceView.java   
public ImageSurfaceView(Context context,attrs);
    mSurHolder = getHolder();
    mSurHolder.addCallback(this);
    this.setonTouchListener(this);
    setZOrderOnTop(true);//使surfaceview放到最顶层
    getHolder().setFormat(PixelFormat.TRANSLUCENT);
}
项目:trascendentAR    文件ARLauncher.java   
@Override
public void initialize(ApplicationListener listener,AndroidApplicationConfiguration config){
    //Las siguientes dos lines son necesaria para poder añadir markers de la manera que artoolkit lo maneja
    AssetHelper assetHelper = new AssetHelper(getAssets());
    assetHelper.cacheAssetFolder(this,"Data");

    mainLayout = new FrameLayout(this);
    config.r = 8;
    config.g = 8;
    config.b = 8;
    config.a = 8;

    //Configuraciones basicas
    requestwindowFeature(Window.FEATURE_NO_TITLE);
    getwindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getwindow().setFormat(PixelFormat.TRANSLUCENT);
    getwindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    gameView = initializeforView(listener,config);

    if(graphics.getView() instanceof SurfaceView){
        SurfaceView glView = (SurfaceView)graphics.getView();
        glView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    }

    setContentView(mainLayout);
}
项目:screenfilter    文件PopupIndicator.java   
private WindowManager.LayoutParams createPopupLayout(IBinder token) {
    WindowManager.LayoutParams p = new WindowManager.LayoutParams();
    p.gravity = Gravity.START | Gravity.TOP;
    p.width = ViewGroup.LayoutParams.MATCH_PARENT;
    p.height = ViewGroup.LayoutParams.MATCH_PARENT;
    p.format = PixelFormat.TRANSLUCENT;
    p.flags = computeFlags(p.flags);
    p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
    p.token = token;
    p.softInputMode = WindowManager.LayoutParams.soFT_INPUT_STATE_ALWAYS_HIDDEN;
    p.setTitle("discreteSeekBar Indicator:" + Integer.toHexString(hashCode()));

    return p;
}
项目:GitHub    文件DrawableutilsTest.java   
@Test
public void testGetopacityFromColor() {
  assertEquals(PixelFormat.TRANSPARENT,Drawableutils.getopacityFromColor(0x00000000));
  assertEquals(PixelFormat.TRANSPARENT,Drawableutils.getopacityFromColor(0x00123456));
  assertEquals(PixelFormat.TRANSPARENT,Drawableutils.getopacityFromColor(0x00FFFFFF));
  assertEquals(PixelFormat.TRANSLUCENT,Drawableutils.getopacityFromColor(0xC0000000));
  assertEquals(PixelFormat.TRANSLUCENT,Drawableutils.getopacityFromColor(0xC0123456));
  assertEquals(PixelFormat.TRANSLUCENT,Drawableutils.getopacityFromColor(0xC0FFFFFF));
  assertEquals(PixelFormat.OPAQUE,Drawableutils.getopacityFromColor(0xFF000000));
  assertEquals(PixelFormat.OPAQUE,Drawableutils.getopacityFromColor(0xFF123456));
  assertEquals(PixelFormat.OPAQUE,Drawableutils.getopacityFromColor(0xFFFFFFFF));
}
项目:RLibrary    文件StyleActivity.java   
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        L.e(getClass().getSimpleName() + " 任务栈:" + getTaskId());
        getwindow().setFormat(PixelFormat.TRANSLUCENT);//TBS X5

        loadActivityStyle();
        initwindow();
        initUIActivity();

//        onCreateView();
    }
项目:EasyOne    文件OverlayService.java   
@Override
public void onCreate() {
    super.onCreate();

    FrameLayout frameLayout = new FrameLayout(this);

    frameLayout.setBackgroundColor(getResources().getColor(R.color.colorPhoneDark,getTheme()));
    WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);


    //change this through preferences
    int dragWidth = 20;

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(dragWidth,WindowManager.LayoutParams.TYPE_SYstem_ALERT,WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,PixelFormat.TRANSLUCENT);

    //change this through preferences
    params.gravity = Gravity.START;

    params.x = 0;
    params.y = 0;

    frameLayout.setonTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view,MotionEvent motionEvent) {
            Toast.makeText(OverlayService.this,"yo",Toast.LENGTH_SHORT)
                    .show();
            return false;
        }
    });

    if (windowManager != null) {
        windowManager.addView(frameLayout,params);
    }
}
项目:grafika    文件ColorBaractivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_color_bar);

    mSurfaceView = (SurfaceView) findViewById(R.id.colorBarSurfaceView);
    mSurfaceView.getHolder().addCallback(this);
    mSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);
}
项目:Markwon    文件AsyncDrawable.java   
@Override
public int getopacity() {
    final int opacity;
    if (hasResult()) {
        opacity = result.getopacity();
    } else {
        opacity = PixelFormat.TRANSPARENT;
    }
    return opacity;
}
项目:accelerator-core-android    文件screensharingFragment.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setUpVirtualdisplay() {

    mScreen = (ViewGroup) getActivity().getwindow().getDecorView().getRootView();

    // display metrics
    displayMetrics metrics = getResources().getdisplayMetrics();
    mDensity = metrics.densityDpi;
    display mdisplay = getActivity().getwindowManager().getDefaultdisplay();

    Point size = new Point();
    mdisplay.getRealSize(size);
    mWidth = size.x;
    mHeight = size.y;

    // start capture reader
    mImageReader = ImageReader.newInstance(mWidth,mHeight,PixelFormat.RGBA_8888,2);
    int flags = displayManager.VIRTUAL_disPLAY_FLAG_AUTO_MIRROR;

    mVirtualdisplay = mMediaProjection.createVirtualdisplay("ScreenCapture",mWidth,mDensity,flags,mImageReader.getSurface(),null,null);

    size.set(mWidth,mHeight);

    //create ScreenCapturer
    mScreenCapturer = new screensharingCapturer(getActivity(),mScreen,mImageReader);

    mListener.onScreenCapturerReady();
}
项目:FloatingWidget    文件FloatingWidgetService.java   
private void initPosition() {
    mParams = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.WRAP_CONTENT,PixelFormat.TRANSLUCENT);

    mParams.gravity = Gravity.TOP | Gravity.LEFT;
    mParams.x = 0;
    mParams.y = 150;

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。