Пример #1
0
        void BtnCreateClick(object sender, EventArgs e)
        {
            if (IP.SelectedTool == ImageProcessor.Tool.Vectorize && GrblFile.TimeConsumingFilling(IP.FillingDirection) && IP.FillingQuality > 2 &&
                System.Windows.Forms.MessageBox.Show(this, $"Using { GrblCore.TranslateEnum(IP.FillingDirection)} with quality > 2 line/mm could be very time consuming with big image. Continue?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) != DialogResult.OK)
            {
                return;
            }

            using (ConvertSizeAndOptionForm f = new ConvertSizeAndOptionForm(mCore))
            {
                f.ShowDialog(this, IP);
                if (f.DialogResult == DialogResult.OK)
                {
                    preventClose = true;
                    Cursor       = Cursors.WaitCursor;
                    SuspendLayout();
                    TCOriginalPreview.SelectedIndex = 0;
                    FlipControl.Enabled             = false;
                    BtnCreate.Enabled = false;
                    WB.Visible        = true;
                    WB.Running        = true;
                    FormBorderStyle   = FormBorderStyle.FixedSingle;
                    TlpLeft.Enabled   = false;
                    MaximizeBox       = false;
                    ResumeLayout();

                    StoreSettings();
                    Project.AddSettings(GetActualSettings()); // Store project settings

                    IP.GenerateGCode();                       //processo asincrono che ritorna con l'evento "OnGenerationComplete"
                }
            }
        }
Пример #2
0
        public bool Process(string command, string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Invalid arguments, see --help");
                return(false);
            }

            var fI = new FileInfo(args[1]);
            var fO = new FileInfo(args[2]);

            if (!fI.Exists)
            {
                Console.WriteLine("Input file not found");
                return(false);
            }

            var file = new GrblFile(0, 0, 200, 300);

            file.LoadImportedSVG(fI.FullName, false);
            file.SaveProgram(fO.FullName, true, true, false, 1);

            Console.WriteLine("Conversion finished");

            return(true);
        }
Пример #3
0
        protected ManualResetEvent MustExit;            //exit condition

        public ImageProcessor(GrblFile file, string fileName, Size boxSize, bool append)
        {
            mFile      = file;
            mFileName  = fileName;
            mAppend    = append;
            mSuspended = true;
            //mOriginal = new Bitmap(fileName);

            //this double pass is needed to normalize loaded image pixelformat
            //http://stackoverflow.com/questions/2016406/converting-bitmap-pixelformats-in-c-sharp
            using (Bitmap loadedBmp = new Bitmap(fileName))
            {
                mFileDPI        = (int)loadedBmp.HorizontalResolution;
                mFileResolution = loadedBmp.Size;

                using (Bitmap tmpBmp = new Bitmap(loadedBmp))
                    mOriginal = tmpBmp.Clone(new Rectangle(0, 0, tmpBmp.Width, tmpBmp.Height), System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                if (boxSize.IsEmpty)
                {
                    boxSize    = loadedBmp.Size;
                    TargetSize = boxSize;
                }
            }

            mTrueOriginal = mOriginal.Clone() as Bitmap;

            mBoxSize = boxSize;
            ResizeRecalc();
            mGrayScale = TestGrayScale(mOriginal);
        }
        private void processFile(string input, string output)
        {
            var file = new GrblFile(0, 0, 200, 300);

            ImageProcessor IP = new ImageProcessor(file, input, Size.Empty, false);

            IP.WhiteClip      = 5;
            IP.Brightness     = 100;
            IP.Contrast       = 100;
            IP.Quality        = 3;
            IP.FillingQuality = 3;
            IP.BorderSpeed    = 1000;
            IP.LaserOff       = "M5";
            IP.LaserOn        = "M3";
            IP.MarkSpeed      = 1000;
            IP.MaxPower       = 1000;
            IP.GenerateGCodeSync();
            file.SaveProgram(output, true, true, false, 1);
        }
Пример #5
0
        private RasterToLaserForm(GrblCore core, string filename, bool append)
        {
            InitializeComponent();
            mCore = core;

            UDQuality.Maximum = UDFillingQuality.Maximum = GetMaxQuality();

            BackColor = ColorScheme.FormBackColor;
            GbCenterlineOptions.ForeColor = GbConversionTool.ForeColor = GbLineToLineOptions.ForeColor = GbParameters.ForeColor = GbVectorizeOptions.ForeColor = ForeColor = ColorScheme.FormForeColor;
            BtnCancel.BackColor           = BtnCreate.BackColor = ColorScheme.FormButtonsColor;

            IP = new ImageProcessor(core, filename, GetImageSize(), append);
            //PbOriginal.Image = IP.Original;
            ImageProcessor.PreviewReady       += OnPreviewReady;
            ImageProcessor.PreviewBegin       += OnPreviewBegin;
            ImageProcessor.GenerationComplete += OnGenerationComplete;

            LblGrayscale.Visible = CbMode.Visible = !IP.IsGrayScale;

            CbResize.SuspendLayout();
            CbResize.AddItem(InterpolationMode.HighQualityBicubic);
            CbResize.AddItem(InterpolationMode.NearestNeighbor);
            CbResize.ResumeLayout();

            CbDither.SuspendLayout();
            foreach (ImageTransform.DitheringMode formula in Enum.GetValues(typeof(ImageTransform.DitheringMode)))
            {
                CbDither.Items.Add(formula);
            }
            CbDither.SelectedIndex = 0;
            CbDither.ResumeLayout();
            CbDither.SuspendLayout();

            CbMode.SuspendLayout();
            foreach (ImageTransform.Formula formula in Enum.GetValues(typeof(ImageTransform.Formula)))
            {
                CbMode.AddItem(formula);
            }
            CbMode.SelectedIndex = 0;
            CbMode.ResumeLayout();

            CbDirections.SuspendLayout();
            foreach (ImageProcessor.Direction direction in Enum.GetValues(typeof(ImageProcessor.Direction)))
            {
                if (GrblFile.RasterFilling(direction))
                {
                    CbDirections.AddItem(direction, true);
                }
            }
            CbDirections.SelectedIndex = 0;
            CbDirections.ResumeLayout();

            CbFillingDirection.SuspendLayout();
            CbFillingDirection.AddItem(ImageProcessor.Direction.None);
            foreach (ImageProcessor.Direction direction in Enum.GetValues(typeof(ImageProcessor.Direction)))
            {
                if (GrblFile.VectorFilling(direction))
                {
                    CbFillingDirection.AddItem(direction);
                }
            }
            foreach (ImageProcessor.Direction direction in Enum.GetValues(typeof(ImageProcessor.Direction)))
            {
                if (GrblFile.RasterFilling(direction))
                {
                    CbFillingDirection.AddItem(direction);
                }
            }
            CbFillingDirection.SelectedIndex = 0;
            CbFillingDirection.ResumeLayout();

            RbLineToLineTracing.Visible = supportPWM;

            LoadSettings();
            RefreshVE();
        }