当前位置: 首页>>代码示例>>C#>>正文


C# Image.Resize方法代码示例

本文整理汇总了C#中System.Image.Resize方法的典型用法代码示例。如果您正苦于以下问题:C# Image.Resize方法的具体用法?C# Image.Resize怎么用?C# Image.Resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Image的用法示例。


在下文中一共展示了Image.Resize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Show

 public static void Show(ref Image<Bgr, byte> image, string name)
 {
     if (!Suppressed)
         if (viewerDict.ContainsKey(name))
             viewerDict[name].Image = image.Resize(2d, Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR);
         else
         {
             viewerDict.Add(name, new ImageViewer(image.Resize(2d, Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR)));
             viewerDict[name].Show();
         }
 }
开发者ID:sohguodong,项目名称:HandsFree,代码行数:11,代码来源:OmniViewer.cs

示例2: predict

        static int predict(Image<Gray, Byte> inputImage)
        {
            try
            {
                int imageSize = 64;
                Image<Gray, byte> testImage = inputImage.Resize(imageSize, imageSize, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
                testImage._EqualizeHist();
                FaceRecognizer.PredictionResult result = faceRecognizer.Predict(testImage);
                return result.Label;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return -1;
        }
开发者ID:piyushkp,项目名称:PeopleTracking,代码行数:17,代码来源:GenderDetection.cs

示例3: IdentifyAsync

        public async Task<IList<IdScore>> IdentifyAsync(Image<Bgr, Byte> image)
        {
            var reducedImage = image.Resize(_settings.IdentifierImageSize, _settings.IdentifierImageSize, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
            var encoded = Convert.ToBase64String(reducedImage.Bytes);

            encoded = WebUtility.UrlEncode(encoded);
            var data = "img=" + encoded;

            using (var wc = new HttpClient())
            {
                try
                {
                    var json = await wc.PostAsync(_settings.IdentifierUrl, new StringContent(data, new UTF8Encoding(), "application/x-www-form-urlencoded"));
                    var result = JsonConvert.DeserializeObject<List<IdentifyResult>>(await json.Content.ReadAsStringAsync());
                    return result.Select(ir => new IdScore{Id = ir.result, Score = ir.p}).ToList();
                }
                catch (Exception ex)
                {
                    Log.Error("Exception calling identifier: ", ex);
                }
            }
            return null;  
        }
开发者ID:spdjudd,项目名称:BirdTracker,代码行数:23,代码来源:ImageIdentifier.cs

示例4: Resize

        private static void Resize(string filePath, Image image, Size newSize)
        {
            var dir = Path.GetDirectoryName(filePath);
            if (dir == null)
                throw new DirectoryNotFoundException();

            var file = Path.GetFileNameWithoutExtension(filePath);
            var extension = Path.GetExtension(filePath);
            var newFileName = $"{file}-{newSize.Width:D4}{extension}";
            var newPath = Path.Combine(dir, newFileName);
            if (File.Exists(newPath))
                return;

            Console.WriteLine(newFileName);

            var resized = image.Resize(newSize.Width, newSize.Height);

            using (var output = File.OpenWrite(newPath))
            {
                resized.CurrentImageFormat.Encoder.Quality = 256;
                resized.Save(output);
            }
        }
开发者ID:stevedesmond-ca,项目名称:ImageResizer,代码行数:23,代码来源:Resizer.cs

示例5: InsertFace

        public static async Task<AddedFaceData> InsertFace(Image<Bgr, byte> original, Image<Gray, byte> grayframe, string username)
        {
            var size = Properties.Settings.Default.RecognitionImageSize;

            original = original.Resize(size, size, Inter.Cubic);
            grayframe = grayframe.Resize(size, size, Inter.Cubic);

            var userId = await DatabaseHandler.InsertAsync("INSERT INTO users (username) VALUES (@username)", new SQLiteParameter("@username", username));

            var faceId = await DatabaseHandler.InsertAsync("INSERT INTO faces (original, grayframe, userID, width, height) VALUES (@original, @grayframe, @userId, @width, @height)",
                new SQLiteParameter("@original", DbType.Binary)
                {
                    Value = original.Bytes
                },
                new SQLiteParameter("@grayframe", DbType.Binary)
                {
                    Value = grayframe.Bytes
                },
                new SQLiteParameter("@userId", userId),
                new SQLiteParameter("@width", original.Width),
                new SQLiteParameter("@height", original.Height)
            );

            AllFaces.Add(new Face(original, grayframe, (int)faceId, username, (int)userId));

            AllUsers.Add(new User((int)userId, username));

            return new AddedFaceData(userId, faceId);
        }
开发者ID:PkInfRemi,项目名称:FaceDetectionApp,代码行数:29,代码来源:RecognitionData.cs

示例6: Invoke

        public async Task Invoke(HttpContext context)
        {
            if (!IsImageRequest(context))
            {
                // move to the next request here?
                await _next.Invoke(context);
                return;
            }

            try
            {
                var sb = new StringBuilder();
                sb.AppendLine("=====================================================================================================");
                sb.AppendLine("Date/Time: " + DateTime.UtcNow.ToString("M/d/yyyy hh:mm tt"));

                int width = 0;
                int.TryParse(context.Request.Query["width"], out width);
                int height = 0;
                int.TryParse(context.Request.Query["height"], out height);

                var inputPath = _appEnvironment.ApplicationBasePath + "/wwwroot" + context.Request.Path;
                using (var inputStream = File.OpenRead(inputPath))
                {
                    sb.AppendLine("Input Path: " + inputPath);
                    sb.AppendLine("Querystring Dimensions: " + width.ToString() + "x" + height.ToString());

                    var sw = new Stopwatch();
                    sw.Start();
                    var image = new Image(inputStream);
                    if (image.Width > image.Height && width != 0)
                        height = (125 * image.Height) / image.Width;
                    if (image.Height > image.Width && height != 0)
                        width = (125 * image.Width) / image.Height;
                    sw.Stop();

                    sb.AppendLine("Original Dimensions: " + image.Width.ToString() + "x" + image.Height.ToString());
                    sb.AppendLine("Output Dimensions: " + width.ToString() + "x" + height.ToString());
                    sb.AppendLine("Image Read Time in Seconds: " + sw.Elapsed.TotalSeconds.ToString());

                    // write directly to the body output stream
                    using (var outputStream = new MemoryStream())
                    {
                        sw.Restart();
                        image.Resize(width, height)
                            .Save(outputStream);
                        var bytes = outputStream.ToArray();
                        sw.Stop();
                        sb.AppendLine("Image Processing Time in Seconds: " + sw.Elapsed.TotalSeconds.ToString());

                        //context.Response.Body.Write(bytes, 0, bytes.Length);
                        await context.Response.Body.WriteAsync(bytes, 0, bytes.Length);
                    }

                    //// the following approach will write to disk then serve the image
                    ////var inputPath = _appEnvironment.ApplicationBasePath + "/wwwroot" + context.Request.Path;
                    //var outputPath = _appEnvironment.ApplicationBasePath + "/Uploads/" + Path.GetFileName(context.Request.Path);
                    //using (var outputStream = File.OpenWrite(outputPath))
                    //{
                    //    image.Resize(width, height)
                    //        .Save(outputStream);
                    //}
                    //var bytes = File.ReadAllBytes(outputPath);
                    //await context.Response.Body.WriteAsync(bytes, 0, bytes.Length);
                }

                //var logFilePath = _appEnvironment.ApplicationBasePath + "/Logs/ThumbnailLog-" + DateTime.UtcNow.ToString("yyyy-MM-dd-hh-mm-ss") + ".txt";
                var logFilePath = _appEnvironment.ApplicationBasePath + "/Logs/ThumbnailLog.txt";
                var logWriter = new LogWriter(logFilePath);
                logWriter.Write(sb.ToString());
            }
            catch (Exception ex)
            {
                var logFilePath = _appEnvironment.ApplicationBasePath + "/Logs/Exceptions.txt";
                var logWriter = new LogWriter(logFilePath);
                logWriter.WriteLine("=====================================================================================================");
                logWriter.WriteLine(ex.ToString());
            }

            //await _next.Invoke(context);
        }
开发者ID:Quintinon,项目名称:AspnetCoreFileManager,代码行数:80,代码来源:ThumbnailMiddleware.cs

示例7: btnStudent_Click

        private void btnStudent_Click(object sender, RoutedEventArgs e)
        {
            try
            {

                //Trained face counter
                ContTrain = ContTrain + 1;

                //Get a gray frame from capture device
                gray = grabber.QueryGrayFrame().Resize(320, 240, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);

                //Face Detector
                MCvAvgComp[][] facesDetected = gray.DetectHaarCascade(
                face,
                1.2,
                10,
                Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                new System.Drawing.Size(20, 20));

                if (facesDetected == null || facesDetected.Length <= 0)
                {
                    MessageBox.Show("Not able detect any face, try again");
                    dispatcherTimer.Start();
                }

                //Action for each element detected
                foreach (MCvAvgComp f in facesDetected[0])
                {
                    t = t + 1;
                    result = currentFrame.Copy(f.rect).Convert<Gray, byte>().Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
                    //draw the face detected in the 0th (gray) channel with blue color
                    currentFrame.Draw(f.rect, new Bgr(System.Drawing.Color.Red), 2);
                    dispatcherTimer.Stop();
                    break;
                }

                TrainedFace = result.Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
                trainingImages.Add(TrainedFace);
                //labels.Add(textBox1.Text);

                ImageSourceConverter c = new ImageSourceConverter();
                ImageSource srcImage = c.ConvertFrom(TrainedFace.ToBitmap()) as ImageSource;
                //Show face added in gray scale
                imageBox1.Source = srcImage;

                var startupPath = Environment.CurrentDirectory;
                //Write the number of triained faces in a file text for further load
                File.WriteAllText(startupPath + "/TrainedFaces/TrainedLabels.txt", trainingImages.ToArray().Length.ToString() + "%");

                //Write the labels of triained faces in a file text for further load
                for (int i = 1; i < trainingImages.ToArray().Length + 1; i++)
                {
                    trainingImages.ToArray()[i - 1].Save(startupPath + "/TrainedFaces/face" + i + ".bmp");
                    File.AppendAllText(startupPath + "/TrainedFaces/TrainedLabels.txt", labels.ToArray()[i - 1] + "%");
                }

               // MessageBox.Show(textBox1.Text + "´s face detected and added :)", "Training OK", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch
            {
                MessageBox.Show("Enable the face detection first", "Training Fail", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
开发者ID:nycode,项目名称:ATTIoT,代码行数:63,代码来源:StudentListView.xaml.cs

示例8: UIUpdate

        void UIUpdate(bool flag)
        {
            try
            {
                LeftEyeCoord = "(" + leftEyeCenter.X.ToString() + " , " + leftEyeCenter.Y.ToString() + ")";
                RightEyeCoord = "(" + rightEyeCenter.X.ToString() + " , " + rightEyeCenter.Y.ToString() + ")";

                LeftRelocationCoord = "(" + leftRelocation.X.ToString() + " , " + leftRelocation.Y.ToString() + ")";
                RightRelocationCoord = "(" + rightRelocation.X.ToString() + " , " + rightRelocation.Y.ToString() + ")";

                //记录一条新的实验数据
                    EyeData.EyeExpName = (ExperimentType)Enum.Parse(typeof(ExperimentType), ExpType[CurrentExpIndex]);
                    EyeData.Time = DateTime.Now;
                    EyeData.MilliSecond = DateTime.Now.Millisecond;
                    EyeData.LeftEyeCoordX = leftEyeCenter.X;
                    EyeData.LeftEyeCoordY = leftEyeCenter.Y;
                    EyeData.RightEyeCoordX = rightEyeCenter.X;
                    EyeData.RightEyeCoordY = rightEyeCenter.Y;
                    EyeData.LeftRelocationCoordX = leftRelocation.X;
                    EyeData.LeftRelocationCoordY = leftRelocation.Y;
                    EyeData.RightRelocationCoordX = rightRelocation.X;
                    EyeData.RightRelocationCoordY = rightRelocation.Y;
                    if (flag == false)
                        EyeData.Valid = 0;
                    else
                        EyeData.Valid = 1;

                    
                   
                 
                //计算帧率
                time_span = EyeData.Time - time_pre;
                time_pre = EyeData.Time;
                Fps = (Convert.ToInt32(1000 / time_span.TotalMilliseconds)).ToString() + "/s";
                EyeQueue.Enqueue(EyeData);
                //SaveThread.Suspend();
                
            }
            catch (System.Exception ex)
            {
                LeftEyeCoord = "0";
                RightEyeCoord = "0";
                LeftRelocationCoord = "0";
                RightRelocationCoord = "0";
                Fps = "0";
            }

          

           
            if (ShowImage)
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    imagePtr = GetResultImage();
                    result_image = IplImagePointerConverter.ToEmgucvImage<Bgr, Byte>(imagePtr);
                    result_image2 = result_image.Resize(320, 240, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
                    ResultImageSource = BitmapSourceConverter.ToBitmapSource(result_image2);
                    OnPropertyChanged("ResultImageSource");
                }), null);
            }

         
        }
开发者ID:WangXiang10,项目名称:xinli,代码行数:64,代码来源:Eye.cs

示例9: Shrink

        public void Shrink(string filename, string outfile, int width)
        {
            FileStream fs = File.OpenRead(R.Server.MapPath(filename));
            Image image = new Image(fs);

            //int h = height;
            if (image.PixelWidth > width)
            {
                //if(h <= 0) { h = (image.PixelHeight / (image.PixelWidth / width)); }
                image = image.Resize(width);
            }
            Save(outfile, image);
            fs.Dispose();
        }
开发者ID:nhtera,项目名称:Home,代码行数:14,代码来源:Images.cs

示例10: UIUpdate

        void UIUpdate(bool flag)
        {
            try
            {
                LeftEyeCoord = "(" + leftEyeCenter.X.ToString() + " , " + leftEyeCenter.Y.ToString() + ")";
                RightEyeCoord = "(" + rightEyeCenter.X.ToString() + " , " + rightEyeCenter.Y.ToString() + ")";

                LeftRelocationCoord = "(" + leftRelocation.X.ToString() + " , " + leftRelocation.Y.ToString() + ")";
                RightRelocationCoord = "(" + rightRelocation.X.ToString() + " , " + rightRelocation.Y.ToString() + ")";

                //记录一条新的实验数据
                    EyeData.EyeExpName = (ExperimentType)Enum.Parse(typeof(ExperimentType), ExpType[CurrentExpIndex]);
                    EyeData.Time = DateTime.Now;
                    EyeData.MilliSecond = DateTime.Now.Millisecond;
                    EyeData.LeftEyeCoordX = leftEyeCenter.X;
                    EyeData.LeftEyeCoordY = leftEyeCenter.Y;
                    EyeData.RightEyeCoordX = rightEyeCenter.X;
                    EyeData.RightEyeCoordY = rightEyeCenter.Y;
                    EyeData.LeftRelocationCoordX = leftRelocation.X;
                    EyeData.LeftRelocationCoordY = leftRelocation.Y;
                    EyeData.RightRelocationCoordX = rightRelocation.X;
                    EyeData.RightRelocationCoordY = rightRelocation.Y;
                    if (flag == false)
                        EyeData.Valid = 0;
                    else
                        EyeData.Valid = 1;

                    
                   
                 
                //计算帧率
                time_span = EyeData.Time - time_pre;
                time_pre = EyeData.Time;
                Fps = (Convert.ToInt32(1000 / time_span.TotalMilliseconds)).ToString() + "/s";
                EyeQueue.Enqueue(EyeData);
                //SaveThread.Suspend();
                
            }
            catch (System.Exception ex)
            {
                LeftEyeCoord = "0";
                RightEyeCoord = "0";
                LeftRelocationCoord = "0";
                RightRelocationCoord = "0";
                Fps = "0";
            }

          

            //SaveThread.Resume();
            // 写入数据库,由于速度太慢,不再使用这种方法
            //time1 = DateTime.Now;
            /*
                try
                {
                    if (DatabaseHelper.SaveEyeExperimentData(EyeExperimentName, EyeData))
                    {
                        /*
                        this.TrialEvent(this, new TrialEventArgs(TrialState.Running, TrialCount));
                        // 状态5:实验过渡
                        State = 5;
                        TrialTimer.Stop();
                        TrialTimer.Interval = 500;
                        TrialTimer.Start();
                         
                    }
                    else
                    {
                        // 实验数据未写入数据库
                        DatabaseMessage.ShowDatabaseFailure("");
                        //  Pause();
                    }
                }
                catch (System.Exception ex)
                {
                    DatabaseMessage.ShowDatabaseFailure(ex.Message);
                }
            */

            // use_time1 = (int)(DateTime.Now - time1).TotalMilliseconds;
            if (ShowImage)
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    imagePtr = GetResultImage();
                    result_image = IplImagePointerConverter.ToEmgucvImage<Bgr, Byte>(imagePtr);
                    result_image2 = result_image.Resize(320, 240, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
                    ResultImageSource = BitmapSourceConverter.ToBitmapSource(result_image2);
                    OnPropertyChanged("ResultImageSource");
                }), null);
            }

            /*
            if (ShowLocus)
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    whiteimagePtr = GetWhiteImage();
                    result_whiteimage = IplImagePointerConverter.ToEmgucvImage<Bgr, Byte>(whiteimagePtr);
                    ResultLocusSource = BitmapSourceConverter.ToBitmapSource(result_whiteimage);
//.........这里部分代码省略.........
开发者ID:WangXiang10,项目名称:xinli,代码行数:101,代码来源:Eye+-+副本.cs

示例11: Run

        public void Run()
        {
            double totaltime = 0;

            int s = 100, r = 5;

            string[] templatefiles = Directory.GetFiles(@"D:\Play Data\train_data\sc\", "*.sc")
                .Take(100).ToArray();
            #region 打开模板
            string templatepath = @"D:\Play Data\template\";
            int templatecount = templatefiles.Length;
            Debug("打开{0}个模板--------------------------------------------", templatecount);
            double[][,] templates = new double[templatecount][,];
            int[] templatenums = new int[templatecount];
            timer.Restart();
            for (int i = 0; i < templatefiles.Length; ++i) {
                string file = templatefiles[i];
                string filename = Path.GetFileNameWithoutExtension(file);
                templatenums[i] = int.Parse(filename.Split('-')[1]);
                templates[i] = new double[s, 60];
                using (var fs = new FileStream(file, FileMode.Open)) {
                    using (var br = new BinaryReader(fs)) {
                        for (int j = 0; j < s; ++j) {
                            for (int k = 0; k < 60; ++k) {
                                templates[i][j, k] = br.ReadDouble();
                            }
                        }
                    }
                }
                if (i % 100 == 0)
                    Debug("已完成{0}个", i);
            }
            Debug("模板读取完成,用时{0}ms.", timer.Stop());
            #endregion

            string[] testfiles = Directory.GetFiles(@"D:\Play Data\test\", "*.bmp")
                .Take(100).ToArray();
            #region 测试
            int testcase = testfiles.Length, acc = 0;
            Debug("为{0}个对象寻找候选模板------------------------------------------", testcase);
            foreach (var file in testfiles) {
                timer.Restart();
                string filenameext = Path.GetFileName(file);
                string filename = Path.GetFileNameWithoutExtension(file);
                int thisnum = int.Parse(filename.Split('-')[1]);
                Image<Gray, Byte> img = new Image<Gray, byte>(file);
                var list = getEdge(img.Resize(2.5, Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR)).Sample(s);
                var scq = Jim.OCR.ShapeContext2D.ShapeContext.ComputeSC(list);

                var arr = new ValueIndexPair<double>[templatecount];
                for (int i = 0; i < templatecount; ++i) {
                    double[,] sci = templates[i];
                    double[,] costmat = Jim.OCR.ShapeContext2D.ShapeContext.HistCost(scq, sci);

                    var costmat_int = new int[s, s];
                    for (int ii = 0; ii < s; ++ii) {
                        for (int jj = 0; jj < s; ++jj) {
                            costmat_int[ii, jj] = (int)(costmat[ii, jj] * 10000);
                        }
                    }
                    var km = new KM(s, costmat_int);
                    km.Match(false);
                    arr[i] = new ValueIndexPair<double> { Index = i, Value = km.MatchResult / 10000.0 };
                }
                Array.Sort(arr, (a, b) => a.Value.CompareTo(b.Value));
                int[] matchcount = new int[10];
                double[] matchcost = new double[10];
                int knn = 10;
                foreach (var pair in arr.Take(knn)) {
                    int num = templatenums[pair.Index];
                    matchcount[num]++;
                    matchcost[num] += pair.Value;
                }
                var match = matchcount.Select((val, i) => new { Count = val, Num = i })
                                      .Where(v => v.Count > 0)
                                      .OrderByDescending(v => v.Count).ToArray();
                //var match = matchcost.Select((val, i) => new { Cost = val / matchcount[i], Num = i })
                //                     .Where(v => !double.IsNaN(v.Cost))
                //                     .OrderBy(v => v.Cost).ToArray();

                #region 进行精细匹配,效果一般
                //double[] matchrate = new double[10];
                //foreach (var m in match) {
                //    if (m.Count == 0) break;
                //    string template = Path.Combine(templatepath, m.Num + ".bmp");
                //    Jim.OCR.ShapeContext2D.ShapeContext sc = new Jim.OCR.ShapeContext2D.ShapeContext(file, template);
                //    sc.debug_flag = false;
                //    sc.timer_flag = false;
                //    sc.display_flag = false;
                //    sc.n_iter = 3;
                //    sc.matchScale = 2.5;
                //    sc.maxsamplecount = 100;
                //    matchrate[m.Num] = sc.MatchFile();
                //}
                //var bestmatches = matchrate.Select((val, i) => new { Cost = val, Num = i })
                //                           .Where(m => m.Cost > 0)
                //                           .OrderBy(m => m.Cost).ToArray();
                //int firstmatch = bestmatches[0].Num;
                #endregion

//.........这里部分代码省略.........
开发者ID:pakerliu,项目名称:sharp-context,代码行数:101,代码来源:OnlyKM.cs

示例12: client_DownloadDataCompleted

 private void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
 {
     try
     {
         var image = new Image(e.Result);
         image.Convert(Image.kFormatAlpha16);
         if (image.width != 1081 || image.height != 1081)
         {
             if (!image.Resize(1081, 1081))
             {
                 errorLabel.text = string.Concat(new object[]
                     {
                         "Resize not supported: ",
                         image.format,
                         "-",
                         image.width,
                         "x",
                         image.height,
                         " Expected: ",
                         1081,
                         "x",
                         1081
                     });
                 return;
             }
         }
         m_LastHeightmap16 = image.GetPixels();
         SimulationManager.instance.AddAction(LoadHeightMap16(m_LastHeightmap16));
     }
     catch (Exception ex)
     {
         errorLabel.text = ex.ToString();
     }
 }
开发者ID:GlitchedMan,项目名称:Cities-Skylines-Mapper,代码行数:34,代码来源:MapperWindow.cs

示例13: Render

        public void Render(Image image, Drawable drawable)
        {
            var parser = new MathExpressionParser();
              parser.Init(GetValue<string>("formula"), image.Dimensions);

              var newImage = new Image(image.Dimensions, image.BaseType);
              var srcPR = new PixelRgn(drawable, image.Bounds, false, false);

              PixelRgn destPR1 = null;
              var layer1 = AddLayer(newImage, 1, _("layer_one"), "translate_1_x",
                "translate_1_y", out destPR1);

              PixelRgn destPR2 = null;
              var layer2 = AddLayer(newImage, 2, _("layer_two"), "translate_2_x",
                "translate_2_y", out destPR2);

              var transparent = new Pixel(4);

              if (destPR1 != null && destPR2 != null)
            {
              var iterator = new RegionIterator(srcPR, destPR1, destPR2);
              iterator.ForEach((src, dest1, dest2) =>
            {
              var tmp = Copy(src);
              if (parser.Eval(src) < 0)
              {
            dest1.Set(tmp);
            dest2.Set(transparent);
              }
              else
              {
            dest2.Set(tmp);
            dest1.Set(transparent);
              }
            });
            }
              else if (destPR1 != null)
            {
              var iterator = new RegionIterator(srcPR, destPR1);
              iterator.ForEach((src, dest) =>
               dest.Set((parser.Eval(src) < 0)
                    ? Copy(src) : transparent));
            }
              else	// destPR2 != null
            {
              var iterator = new RegionIterator(srcPR, destPR2);
              iterator.ForEach((src, dest) =>
               dest.Set((parser.Eval(src) >= 0)
                    ? Copy(src) : transparent));
            }

              Rotate(layer1, GetValue<int>("rotate_1"));
              Rotate(layer2, GetValue<int>("rotate_2"));

              if (GetValue<bool>("merge"))
            {
              var merged =
            newImage.MergeVisibleLayers(MergeType.ExpandAsNecessary);
              merged.Offsets = new Offset(0, 0);
              newImage.Resize(merged.Dimensions, merged.Offsets);
            }

              new Display(newImage);

              Display.DisplaysFlush();
        }
开发者ID:unhammer,项目名称:gimp-sharp,代码行数:66,代码来源:Renderer.cs

示例14: ShowOriginalImage

 public void ShowOriginalImage(Image<Bgr, byte> drawedImage, Face face)
 {
     this.OriginalImageViewer.Image = drawedImage.Resize(this.OriginalImageViewer.Width, this.OriginalImageViewer.Height, INTER.CV_INTER_LINEAR);
     //this.trainBox.ShowOriginalImage(drawedImage, face);
 }
开发者ID:tavotavotavo,项目名称:beyondbody,代码行数:5,代码来源:FormMain.cs

示例15: saveTransformImagesToBlobAsJpeg

        public async Task saveTransformImagesToBlobAsJpeg(IFormFile file, string fileName)
        {

            foreach (var size in imageSizes)
            {
                CloudBlockBlob blockBlob = _container.GetBlockBlobReference(Enum.GetName(typeof(Sizes),size.Size) + "/" + fileName);
                blockBlob.Properties.ContentType = "image/jpeg";

                using (var inStream = file.OpenReadStream())
                {
                    // Create or overwrite
                    using (var fileStream = await blockBlob.OpenWriteAsync())
                    {
                        var image = new Image(inStream);

                        image.Resize(size.width, 0) // Passing zero on height or width will perserve the aspect ratio of the image.
                        .Save(fileStream, new JpegFormat());
                    }
                }
            }
        }
开发者ID:s165519,项目名称:ASPNET5Examples,代码行数:21,代码来源:FileHandler.cs


注:本文中的System.Image.Resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。