コード例 #1
0
ファイル: Efectos.cs プロジェクト: RoberthDudiver/PhotoBooth
        public static Image ProcesarCartoon(Bitmap selectedSource)
        {
            string ruta = AssemblyDirectory;

            Bitmap bitmapResult = null;

            ExtBitmap.SmoothingFilterType filterType =
                ExtBitmap.SmoothingFilterType.Gaussian3x3;


            bitmapResult = selectedSource.CartoonEffectFilter(
                60, filterType);



            FileStream fs = new FileStream(ruta + @"\Efectos\T0.png", FileMode.Open, FileAccess.Read);

            var tama = new Size(selectedSource.Width, selectedSource.Height);

            System.Drawing.Bitmap bitmap1 = new System.Drawing.Bitmap(fs);
            System.Drawing.Bitmap bitmap  = new System.Drawing.Bitmap(bitmap1, tama);

            FileStream fss = new FileStream(ruta + @"\Efectos\T1.png", FileMode.Open, FileAccess.Read);

            System.Drawing.Bitmap bitmaps = new System.Drawing.Bitmap(fss);


            FileStream fsss = new FileStream(ruta + @"\Efectos\T2.png", FileMode.Open, FileAccess.Read);

            System.Drawing.Bitmap fondo = new System.Drawing.Bitmap(fsss);



            FileStream fssss = new FileStream(ruta + @"\Efectos\T3.png", FileMode.Open, FileAccess.Read);

            System.Drawing.Bitmap principal = new System.Drawing.Bitmap(fssss);

            System.Drawing.Graphics r = System.Drawing.Graphics.FromImage(bitmap);

            r.DrawImage(bitmapResult, 0, 0, selectedSource.Width, selectedSource.Height);
            r.DrawImage(bitmaps, 0, 0, selectedSource.Width, selectedSource.Height);

            r.DrawImage(fondo, 0, 0, selectedSource.Width, selectedSource.Height);
            r.DrawImage(principal, 0, 0, selectedSource.Width, selectedSource.Height);


            fondo.Dispose();
            bitmaps.Dispose();



            return(bitmap);
        }
コード例 #2
0
        private void ApplyFilter(bool preview)
        {
            if (previewBitmap == null || cmbSmoothingFilter.SelectedIndex == -1)
            {
                return;
            }

            Bitmap selectedSource = null;
            Bitmap bitmapResult   = null;

            if (preview == true)
            {
                selectedSource = previewBitmap;
            }
            else
            {
                selectedSource = originalBitmap;
            }

            if (selectedSource != null)
            {
                ExtBitmap.SmoothingFilterType filterType =
                    ((ExtBitmap.SmoothingFilterType)cmbSmoothingFilter.SelectedItem);


                bitmapResult = selectedSource.CartoonEffectFilter(
                    (byte)trcThreshold.Value, filterType);
            }

            if (bitmapResult != null)
            {
                if (preview == true)
                {
                    picPreview.Image = bitmapResult;
                }
                else
                {
                    resultBitmap = bitmapResult;
                }
            }
        }