Exemple #1
0
        //生成按钮
        public async void Make(string filePath)
        {
            // Detect any faces in the image.
            faceList = await UploadAndDetectFaces(filePath);

            if (faceList.Count > 0)
            {
                LaterFace = AdjustFunction.Redraw(faceList, bitmapImage);
            }
        }
Exemple #2
0
        //生成小图
        public async void MakeSmall(string filePath)
        {
            // Detect any faces in the image.
            faceList = await UploadAndDetectFaces(filePath);

            faceListWD = faceList;
            if (faceList.Count > 0)
            {
                // Prepare to draw rectangles around the faces.
                DrawingVisual  visual         = new DrawingVisual();
                DrawingContext drawingContext = visual.RenderOpen();
                drawingContext.DrawImage(bitmapSource2,
                                         new Rect(0, 0, bitmapSource2.Width, bitmapSource2.Height));
                double dpi = bitmapSource2.DpiX;
                // Some images don't contain dpi info.
                resizeFactor     = (dpi == 0) ? 1 : 96 / dpi;
                faceDescriptions = new String[faceList.Count];

                for (int i = 0; i < faceList.Count; ++i)
                {
                    DetectedFace face = faceList[i];


                    //裁剪图片
                    Bitmap temp = AdjustFunction.BitmapImageToBitmap(bitmapSource2);
                    temp2 = img_tailor(temp, new Rectangle(
                                           (int)((face.FaceRectangle.Left + 10) * resizeFactor),
                                           (int)((face.FaceRectangle.Top + 25) * resizeFactor),
                                           (int)((face.FaceRectangle.Width * 0.8) * resizeFactor),
                                           (int)((face.FaceRectangle.Height * 0.7) * resizeFactor)
                                           ));
                    temp2 = AdjustFunction.BlackAndwhite(temp2);

                    bitmapImage = AdjustFunction.BitmapToBitmapImage(temp2);
                }

                drawingContext.Close();

                // Display the image with the rectangle around the face.
                RenderTargetBitmap faceWithRectBitmap = new RenderTargetBitmap(
                    (int)(bitmapSource2.PixelWidth * resizeFactor),
                    (int)(bitmapSource2.PixelHeight * resizeFactor),
                    96,
                    96,
                    PixelFormats.Pbgra32);

                faceWithRectBitmap.Render(visual);

                faceRectangle = faceWithRectBitmap;
            }
        }
Exemple #3
0
        //还原
        public void withdraw()
        {
            DetectedFace face = faceListWD[0];
            Bitmap       temp = AdjustFunction.BitmapImageToBitmap(bitmapSource2);

            original = img_tailor(temp, new Rectangle(
                                      (int)((face.FaceRectangle.Left + 10) * resizeFactor),
                                      (int)((face.FaceRectangle.Top + 25) * resizeFactor),
                                      (int)((face.FaceRectangle.Width * 0.8) * resizeFactor),
                                      (int)((face.FaceRectangle.Height * 0.7) * resizeFactor)
                                      ));
            original = AdjustFunction.BlackAndwhite(original);
            AdjustFunction.formattedText = null;
        }
Exemple #4
0
        //一键生成按钮
        public async void AutoMake(string filePath)
        {
            // Detect any faces in the image.
            faceList = await UploadAndDetectFaces(filePath);

            if (faceList.Count > 0)
            {
                Bitmap bitmap = AdjustFunction.BitmapImageToBitmap(bitmapImage);
                bitmapImage = AdjustFunction.BrightnessP(bitmap, 50);
                bitmapImage = AdjustFunction.SetTrans(bitmap, 50);
                bitmapImage = AdjustFunction.KiContrast(bitmap, 100);
                LaterFace   = AdjustFunction.Redraw(faceList, bitmapImage);
            }
        }