示例#1
0
        public static Drawable getDrawableWithNumber(Drawable baseDrawable, int number, int iconSize, Context context)
        {
            if (number < 0 || number > 9)
            {
                number = 0;
            }
            Drawable numberDrawable = context.Resources.getDrawable(R.drawable.number_round);

            if (numberDrawable == null)
            {
                return(baseDrawable);
            }
            int          appIconShift = context.Resources.getDimensionPixelOffset(R.dimen.ord_app_icon_shift);
            Bitmap       bitmap       = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888);
            Canvas       canvas       = new Canvas(bitmap);
            int          textSize     = context.Resources.getDimensionPixelSize(R.dimen.number_icon_text_size);
            int          textColor    = context.Resources.getColor(R.color.fc_app_icon_number_color);
            TextDrawable textDrawable = new TextDrawable(number.ToString(), textSize, textColor);


            baseDrawable.setBounds(0, 0, iconSize, iconSize);
            baseDrawable.draw(canvas);

            numberDrawable.setBounds(iconSize - (appIconShift + numberDrawable.IntrinsicWidth), appIconShift, iconSize - (appIconShift), appIconShift + numberDrawable.IntrinsicHeight);
            numberDrawable.draw(canvas);

            textDrawable.setBounds(iconSize - (appIconShift + numberDrawable.IntrinsicWidth), appIconShift, iconSize - (appIconShift), appIconShift + numberDrawable.IntrinsicHeight);
            textDrawable.draw(canvas);
            return(new BitmapDrawable(context.Resources, bitmap));
        }
示例#2
0
        private Bitmap captureBitmap(I420Frame i420Frame)
        {
            YuvImage yuvImage            = i420ToYuvImage(i420Frame);
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            Rect rect = new Rect(0, 0, yuvImage.Width, yuvImage.Height);

            // Compress YuvImage to jpeg
            yuvImage.compressToJpeg(rect, 100, stream);

            // Convert jpeg to Bitmap
            sbyte[] imageBytes = stream.toByteArray();
            Bitmap  bitmap     = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.Length);
            Matrix  matrix     = new Matrix();

            // Apply any needed rotation
            matrix.postRotate(i420Frame.rotationDegree);
            bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.Width, bitmap.Height, matrix, true);

            return(bitmap);
        }
示例#3
0
            public virtual void run()
            {
                if (outerInstance.capturing)
                {
                    int width  = outerInstance.contentView.Width;
                    int height = outerInstance.contentView.Height;

                    if (outerInstance.frame == null || outerInstance.width != width || outerInstance.height != height)
                    {
                        outerInstance.width  = width;
                        outerInstance.height = height;

                        if (outerInstance.bmp != null)
                        {
                            outerInstance.bmp.recycle();
                            outerInstance.bmp = null;
                        }

                        outerInstance.bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

                        outerInstance.canvas = new Canvas(outerInstance.bmp);
                        outerInstance.frame  = new int[width * height];
                    }
                    outerInstance.canvas.save(Canvas.MATRIX_SAVE_FLAG);
                    outerInstance.canvas.translate(-outerInstance.contentView.ScrollX, -outerInstance.contentView.ScrollY);
                    outerInstance.contentView.draw(outerInstance.canvas);

                    outerInstance.bmp.getPixels(outerInstance.frame, 0, width, 0, 0, width, height);

                    provideIntArrayFrame(outerInstance.frame, ARGB, width, height, 0, false);

                    outerInstance.canvas.restore();

                    outerInstance.mHandler.postDelayed(newFrame, 1000 / outerInstance.fps);
                }
            }
示例#4
0
 private ImageAndroid(int width, int height, int imageType)
 {
     bitmap = Bitmap.createBitmap(width, height, imageTypeToBitmapConfig(imageType));
 }
示例#5
0
 public virtual Image crop(int x1, int y1, int x2, int y2)
 {
     return(new ImageAndroid(Bitmap.createBitmap(bitmap, x1, y1, x2 - x1, y2 - y1)));
 }