コード例 #1
0
        public void Image_Blur(ImageItem imageItem)
        {
            KalikoImage bluredImage = new KalikoImage(imageItem.UriSource.OriginalString);

            bluredImage.ApplyFilter(new GaussianBlurFilter());
            imageItem.Image = ImageToBitmapImage(bluredImage);
        }
コード例 #2
0
        public string Execute(FileItem item, string infile, string dest, ValuePairEnumerator configData)
        {
            try
            {
                var conf = new ChromakeyViewModel(configData);
                dest = Path.Combine(Path.GetDirectoryName(dest), Path.GetFileNameWithoutExtension(dest) + ".jpg");

                KalikoImage image  = new KalikoImage(infile);
                var         x      = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(conf.BackgroundColor);
                var         filter = new ChromaKeyFilter();
                filter.KeyColor             = Color.FromArgb(x.R, x.G, x.B);
                filter.ToleranceHue         = conf.Hue;
                filter.ToleranceSaturnation = conf.Saturnation / 100f;
                filter.ToleranceBrightness  = conf.Brigthness / 100f;
                image.ApplyFilter(filter);
                var res = image.Clone();

                if (conf.UnsharpMask)
                {
                    res.ApplyFilter(new UnsharpMaskFilter(1.4f, 1.32f, 5));
                }

                var backdrop = new KalikoImage(conf.BackgroundFile);
                backdrop = backdrop.Scale(new FitScaling(image.Width, image.Height));
                backdrop.BlitImage(res);

                backdrop.SaveJpg(dest, 90);
                return(dest);
            }
            catch (Exception e)
            {
                Log.Debug("Chromakey error", e);
            }
            return(null);
        }
コード例 #3
0
        private void ProcessImage(KalikoImage image)
        {
            image.Resize(XSIZE, YSIZE);        // for faster operations / debugging

            // operating on image
            NormalizationFilter normalization = new NormalizationFilter();

            image.ApplyFilter(normalization);

            FastGaussianBlurFilter gaussian = new FastGaussianBlurFilter(5f);

            image.ApplyFilter(gaussian);

            Histogram histogram         = new Histogram(image);
            byte      filteredThreshold = histogram.GetThresholdLevel();

            ThresholdFilter threshold = new ThresholdFilter(filteredThreshold);

            image.ApplyFilter(threshold);
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: alastar09/YUV
        public void Unsharpmask(object b22)
        {
            KalikoImage image = new KalikoImage("C:\\Users\\Dima\\Pictures\\1.jpg");

            // Create a thumbnail of 128x128 pixels
            KalikoImage thumb = image.GetThumbnailImage(128, 128, ThumbnailMethod.Crop);

            // Apply unsharpen filter (radius = 1.4, amount = 32%, threshold = 0)
            thumb.ApplyFilter(new UnsharpMaskFilter(1.4f, 0.32f, 0));

            // Save the thumbnail as JPG in quality 99 (very high)
            thumb.SaveJpg("C:\\Users\\Dima\\Pictures\\1111.jpg", 99);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            KalikoImage image = new KalikoImage("testimage.jpg");

            image.BackgroundColor = Color.Aquamarine;

            image.Scale(new FitScaling(100, 100)).SaveJpg("thumbnail-fit.jpg", 90);

            image.Scale(new CropScaling(100, 100)).SaveJpg("thumbnail-crop.jpg", 90);

            image.Scale(new PadScaling(100, 100)).SaveJpg("thumbnail-pad.jpg", 90);

            KalikoImage sharpimg = image.Scale(new CropScaling(100, 100));

            sharpimg.ApplyFilter(new UnsharpMaskFilter(1.2f, 0.3f, 1));
            sharpimg.SaveJpg("thumbnail-unsharpened.jpg", 90);

            sharpimg.ApplyFilter(new DesaturationFilter());
            sharpimg.SaveJpg("thumbnail-gray.jpg", 90);

            sharpimg.ApplyFilter(new ContrastFilter(30));
            sharpimg.SaveJpg("thumbnail-contrast.jpg", 90);
        }
コード例 #6
0
ファイル: Player.cs プロジェクト: ye0jun/youtube-music-player
 void SetBackground(string str)
 {
     if (panel.InvokeRequired)
     {
         delegateString a = new delegateString(SetBackground);
         panel.Invoke(a, str);
     }
     else
     {
         var image = new KalikoImage(str);
         image.ApplyFilter(new FastGaussianBlurFilter(30.0f));
         image = image.Scale(new FitScaling(1024, 1024));
         panel.BackgroundImage = image.GetAsBitmap();
     }
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: alastar09/YUV
        private void button5_Click(object sender, EventArgs e)
        {
            //Bitmap bmp = new Bitmap(pictureBox1.Image);
            //Thread Unsharpmaskthread = new Thread(Unsharpmask);
            //Unsharpmaskthread.Start(bmp);
            KalikoImage image = new KalikoImage("C:\\Users\\Dima\\Pictures\\1.jpg");

            // Create a thumbnail of 128x128 pixels
            //KalikoImage thumb = image.GetThumbnailImage(128, 128, ThumbnailMethod.Crop);

            // Apply unsharpen filter (radius = 1.4, amount = 32%, threshold = 0)
            image.ApplyFilter(new UnsharpMaskFilter(1.4f, 0.32f, 0));

            // Save the thumbnail as JPG in quality 99 (very high)
            image.SaveJpg("C:\\Users\\Dima\\Pictures\\1111.jpg", 99);
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: ye0jun/youtube-music-player
        public Form1()
        {
            InitializeComponent();
            m_chromeBrowser = new ChromiumWebBrowser("http://13.124.243.73:3000/");
            panel_Youtube.Controls.Add(m_chromeBrowser);
            this.FormBorderStyle = FormBorderStyle.None;
            Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 15, 15));
            this.Controls.SetChildIndex(this.panel_leftBackground, 1);



            Panel transparent = new Panel();

            transparent.BackgroundImage = Properties.Resources.transparent30;
            transparent.Width           = 320;
            transparent.Height          = 554;
            transparent.BackColor       = Color.Transparent;
            this.panel_leftBackground.Controls.Add(transparent);
            this.Controls.SetChildIndex(this.panel_Youtube, 0);

            var image = new KalikoImage(@"http://www.jangsada.com/files/attach/images/1572/500/002/db0e26c4043c42908ad321de21aeef76.jpg");

            image.ApplyFilter(new FastGaussianBlurFilter(30.0f));
            panel_leftBackground.BackgroundImage = image.GetAsBitmap();

            var pb_logo    = CreatePicturBox(transparent, Properties.Resources.logo, new Size((int)(150 * 0.65f), (int)(36 * 0.65f)), new Point(160 - (int)(150 * 0.65f) / 2, 15));
            var pb_close   = CreatePicturBox(transparent, Properties.Resources.btnCloseDefault_Normal, new Size(22, 22), new Point(19, 15));
            var pb_hide    = CreatePicturBox(transparent, Properties.Resources.btnHideDefault_Normal, new Size(22, 22), new Point(42, 15));
            var pb_play    = CreatePicturBox(transparent, Properties.Resources.btnPauseDefault_Normal, new Size(44, 44), new Point(138, 430));
            var pb_prev    = CreatePicturBox(transparent, Properties.Resources.btnPrevDefault_Normal, new Size(32, 32), new Point(90, 435));
            var pb_next    = CreatePicturBox(transparent, Properties.Resources.btnNextDefault_Normal, new Size(32, 32), new Point(198, 435));
            var pb_shuffle = CreatePicturBox(transparent, Properties.Resources.btnShuffleDefault_Normal, new Size(32, 32), new Point(48, 435));
            var pb_repeat  = CreatePicturBox(transparent, Properties.Resources.btnRepeatDefault_Normal, new Size(32, 32), new Point(239, 435));
            var pb_volume  = CreatePicturBox(transparent, Properties.Resources.btnVolumeDefault_Normal, new Size(32, 32), new Point(144, 487));

            label_Title           = new Label();
            label_Title.Text      = "재생을 기다리고 있습니다";
            label_Title.Font      = new Font("나눔바른고딕", 12);
            label_Title.ForeColor = Color.FromArgb(255, 255, 255);
            label_Title.Width     = 320;
            label_Title.Location  = new Point(0, 385);

            label_Title.TextAlign = ContentAlignment.MiddleCenter;
            transparent.Controls.Add(label_Title);

            Label leftTime = new Label();

            leftTime.Text      = "00:00";
            leftTime.Font      = new Font("나눔바른고딕", 9);
            leftTime.ForeColor = Color.FromArgb(255, 255, 255);
            leftTime.Width     = 50;
            leftTime.Location  = new Point(16, 355);
            transparent.Controls.Add(leftTime);

            Label rightTime = new Label();

            rightTime.Text      = "00:00";
            rightTime.Font      = new Font("나눔바른고딕", 9);
            rightTime.ForeColor = Color.FromArgb(255, 255, 255);
            rightTime.Width     = 50;
            rightTime.Location  = new Point(265, 355);
            transparent.Controls.Add(rightTime);

            seekbar = new Ye0junSeekbar(transparent, 280, 300);
            seekbar.SetPosition(new Point(16, 340));
            seekbar.SetValue(0);


            ////////////////////////////////////////////////////////////////

            pb_play.MouseClick += new MouseEventHandler((o, e) => {
                player.Toggle((b) =>
                {
                    if (b)
                    {
                        pb_play.Image = Properties.Resources.btnPauseDefault_Normal;
                    }
                    else
                    {
                        pb_play.Image = Properties.Resources.btnPlayDefault_Normal;
                    }
                });
            });

            pb_prev.MouseClick += new MouseEventHandler((o, e) => {
                player.preVideo(() =>
                {
                    label_Title.Text = player._title;
                });
            });

            pb_next.MouseClick += new MouseEventHandler((o, e) => {
                player.nextVideo();
                label_Title.Text = player._title;
            });

            pb_shuffle.MouseClick += new MouseEventHandler((o, e) => {
                player.shuffle = !player.shuffle;
                if (player.shuffle)
                {
                    pb_shuffle.Image = Properties.Resources.btnShuffleOnDefault_Normal;
                }
                else
                {
                    pb_shuffle.Image = Properties.Resources.btnShuffleDefault_Normal;
                }
            });

            pb_repeat.MouseClick += new MouseEventHandler((o, e) => {
                if (player.GetRepeatState() == 2)
                {
                    player.SetRepeatState(0);
                }
                else
                {
                    player.SetRepeatState(player.GetRepeatState() + 1);
                }

                switch (player.GetRepeatState())
                {
                case 0:
                    pb_repeat.Image = Properties.Resources.btnRepeatDefault_Normal;
                    break;

                case 1:
                    pb_repeat.Image = Properties.Resources.btnRepeatOnDefault_Normal;
                    break;

                case 2:
                    pb_repeat.Image = Properties.Resources.btn1RepeatOnDefault_Normal;
                    break;
                }
            });

            Youtube youtube = new Youtube();

            searchBar.KeyDown += new KeyEventHandler((o, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    pb_myList.Image      = Properties.Resources.menuMymusicDefault_Normal;
                    underline_my.Visible = false;
                    UTF8Encoding utf8    = new UTF8Encoding();
                    byte[] encodedBytes  = utf8.GetBytes(searchBar.Text);
                    string utf8String    = "";
                    foreach (byte b in encodedBytes)
                    {
                        utf8String += "%" + String.Format("{0:X}", b);
                    }
                    youtube.Search(utf8String, (arr) =>
                    {
                        musicList.SetSearchList(arr);
                    });
                }
            });

            ////////////////////////////////////////////////////////////////
            line_1.BackColor            = Color.FromArgb(230, 230, 230);
            line_2.BackColor            = Color.FromArgb(230, 230, 230);
            panel_rightbottom.BackColor = Color.FromArgb(243);
            underline_my.BackColor      = Color.FromArgb(252, 63, 59);

            player    = new Player(m_chromeBrowser, label_Title, panel_leftBackground, leftTime, seekbar);
            musicList = new MusicList(panel_right, player);


            messageFromBrowser = new MessageFromBrowser(() =>
            {
                Console.WriteLine(player.GetRepeatState() + "   ");
                if (player.GetRepeatState() != 2)
                {
                    player.nextVideo();
                }
                else
                {
                    player.reVideo();
                }
                //label_Title.Text = "ffff";
            }, m_chromeBrowser, seekbar, rightTime);


            m_chromeBrowser.RegisterAsyncJsObject("toCSharp", messageFromBrowser);

            pb_close.MouseClick += new MouseEventHandler(FClose);
            pb_hide.MouseClick  += new MouseEventHandler(FMinimized);

            var bMouseClick = false;
            var myX         = 0;
            var myY         = 0;

            transparent.MouseDown += new MouseEventHandler((o, e) =>
            {
                bMouseClick = true;
                myX         = e.X;
                myY         = e.Y;
            });

            transparent.MouseUp += new MouseEventHandler((o, e) =>
            {
                bMouseClick = false;
            });

            transparent.MouseMove += new MouseEventHandler((o, e) =>
            {
                if (bMouseClick)
                {
                    const short SWP_NOMOVE   = 0X2;
                    const short SWP_NOSIZE   = 1;
                    const short SWP_NOZORDER = 0X4;
                    const int SWP_SHOWWINDOW = 0x0040;
                    Process process          = Process.GetCurrentProcess();
                    IntPtr handle            = process.MainWindowHandle;

                    var finalX = MousePosition.X - myX;
                    var finalY = MousePosition.Y - myY;
                    if (handle != IntPtr.Zero)
                    {
                        SetWindowPos(handle, 0, finalX, finalY, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW);
                    }
                }
            });

            searchBar.GotFocus += new EventHandler((o, e) =>
            {
                disappear_icon.Visible  = false;
                disappear_label.Visible = false;
            });

            searchBar.LostFocus += new EventHandler((o, e) =>
            {
                if (searchBar.Text == "")
                {
                    disappear_icon.Visible  = true;
                    disappear_label.Visible = true;
                }
            });
        }