/// <summary>Apply filter to an image</summary>
        /// <param name="id">Filter index, CLFilters[id], to apply</param>
        /// <param name="bmp">Bitmap to be processes</param>
        public static Bitmap ApplyFilter(int id, Bitmap bmp)
        {
            //if (bmp.Width < 4096)
            //{
            //    CLCalc.Program.Image2D CLImgSrc = new CLCalc.Program.Image2D(bmp);
            //    CLCalc.Program.Image2D CLImgDst = new CLCalc.Program.Image2D(bmp);
            //    CLCalc.Program.MemoryObject[] args = new CLCalc.Program.MemoryObject[] { CLImgSrc, CLImgDst };

            //    CLFilters[id].FilterKernel.Execute(args, new int[] { bmp.Width - 7, bmp.Height - 7 });

            //    return CLImgDst.ReadBitmap();
            //}
            //else
            //{
            //Pictures can be too big; it's necessary to split
            List <Bitmap> bmps = MPOReader.SplitJPS(bmp);

            CLCalc.Program.Image2D        CLImgSrc0 = new CLCalc.Program.Image2D(bmps[0]);
            CLCalc.Program.Image2D        CLImgDst0 = new CLCalc.Program.Image2D(bmps[0]);
            CLCalc.Program.MemoryObject[] args0     = new CLCalc.Program.MemoryObject[] { CLImgSrc0, CLImgDst0 };

            CLFilters[id].FilterKernel.Execute(args0, new int[] { bmps[0].Width - 7, bmps[0].Height - 7 });

            CLCalc.Program.Image2D        CLImgSrc1 = new CLCalc.Program.Image2D(bmps[1]);
            CLCalc.Program.Image2D        CLImgDst1 = new CLCalc.Program.Image2D(bmps[1]);
            CLCalc.Program.MemoryObject[] args1     = new CLCalc.Program.MemoryObject[] { CLImgSrc1, CLImgDst1 };

            CLFilters[id].FilterKernel.Execute(args1, new int[] { bmps[1].Width - 7, bmps[1].Height - 7 });

            Bitmap bmpL = CLImgDst0.ReadBitmap();
            Bitmap bmpR = CLImgDst1.ReadBitmap();

            return(MPOReader.AssembleJPS(bmpL, bmpR));
            //}
        }
Beispiel #2
0
        private void importleftrightToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "Images|*.JPG;*.JPEG;*.BMP;*.GIF;*.TIF";

                string[] s = lblLeftRightImgs.Text.Split('|');

                //Left
                ofd.Title = s[0];
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    string leftImg = ofd.FileName;

                    System.IO.FileInfo fi = new System.IO.FileInfo(leftImg);
                    if (fi.Name.Split('.')[0].ToUpper().EndsWith("L"))
                    {
                        ofd.FileName = fi.Name.Substring(0, fi.Name.Length - 5) + "R" + fi.Extension;
                    }

                    //Right
                    ofd.Title = s[1];
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        lblStatus.Text = lblOpenFiles.Text;

                        string rightimg = ofd.FileName;

                        Bitmap left  = new Bitmap(leftImg);
                        Bitmap right = new Bitmap(rightimg);

                        frmPicture frmPic = new frmPicture(MPOReader.AssembleJPS(left, right), fi.Directory.GetFiles("*" + fi.Extension), fi.FullName);
                        frmPic.Text      = leftImg;
                        frmPic.MdiParent = this;
                        frmPic.Show();

                        lblStatus.Text = lblReady.Text;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter      = "Stereoscopic Images|*.JPS;*.JPG;*.MPO";
            ofd.Multiselect = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                lblStatus.Text = lblOpenFiles.Text;


                for (int i = 0; i < ofd.FileNames.Length; i++)
                {
                    try
                    {
                        System.IO.FileInfo fi = new System.IO.FileInfo(ofd.FileNames[i]);

                        Bitmap bmp = null;
                        if (fi.Extension.ToLower() == ".mpo")
                        {
                            List <Bitmap> bmps = MPOReader.ReadFromMPF(ofd.FileNames[i]);
                            bmp = MPOReader.AssembleJPS(bmps[0], bmps[1]);
                        }
                        else
                        {
                            bmp = new Bitmap(ofd.FileNames[i]);
                        }
                        frmPicture frmPic = new frmPicture(bmp, fi.Directory.GetFiles("*" + fi.Extension), fi.FullName);
                        frmPic.Text      = ofd.FileNames[i];
                        frmPic.MdiParent = this;
                        frmPic.Show();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                lblStatus.Text = lblReady.Text;
            }
        }
Beispiel #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = "Stereo JPS|*.JPS";
            sfd.FileName = fileName;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    MPOReader.Save(this.ImgBmp, sfd.FileName, 98);
                    fileName = sfd.FileName;
                    saved    = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #5
0
        private void LoadBmpFromFile(string fileName)
        {
            this.Text = "";

            System.IO.FileInfo fi = new System.IO.FileInfo(fileName);

            if (fi.Extension.ToLower() == ".mpo")
            {
                List <Bitmap> bmps = MPOReader.ReadFromMPF(fileName);
                ImgBmp = MPOReader.AssembleJPS(bmps[0], bmps[1]);
            }
            else
            {
                ImgBmp = new Bitmap(fileName);
            }

            ImageFiles = fi.Directory.GetFiles("*" + fi.Extension);
            aspect     = (float)ImgBmp.Width / (float)ImgBmp.Height;

            scale   = 1.0;
            paralax = 0;
            tx      = 0; ty = 0; txTemp = 0; tyTemp = 0;

            ReloadBmp();
            saved     = true;
            this.Text = fileName;

            //Locates current ind position
            for (int ii = 0; ii < ImageFiles.Length; ii++)
            {
                if (ImageFiles[ii].FullName == fileName)
                {
                    curImgIndex = ii;
                }
            }
        }