コード例 #1
0
ファイル: Imagen.cs プロジェクト: solutema/ultralight
        private void BotonCapturarImagen_Click(object sender, EventArgs e)
        {
#if WINDOWS
            try {
                WIA.CommonDialogClass WiaDialog = new WIA.CommonDialogClass();
                WIA.ImageFile         WiaImage  = null;

                WiaImage = WiaDialog.ShowAcquireImage(
                    WIA.WiaDeviceType.UnspecifiedDeviceType,
                    WIA.WiaImageIntent.ColorIntent,
                    WIA.WiaImageBias.MaximizeQuality,
                    System.Drawing.Imaging.ImageFormat.Jpeg.Guid.ToString("B"), true, false, false);

                if (WiaImage != null)
                {
                    WIA.Vector vector = WiaImage.FileData;
                    using (Entrada.AuxForms.ImagenRecorte Recorte = new Entrada.AuxForms.ImagenRecorte()) {
                        Recorte.Imagen = System.Drawing.Image.FromStream(new System.IO.MemoryStream((byte[])vector.get_BinaryData()));
                        if (Recorte.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            EntradaImagen.Image = Recorte.Imagen;
                            this.Changed        = true;
                            this.ActualizarElemento();
                        }
                    }
                }
            } catch (Exception ex) {
                Lui.Forms.MessageBox.Show("No se puede conectar con el dispositivo de captura. " + ex.Message, "Error");
            }
#endif
        }
コード例 #2
0
        public ScanResult Scan(Control owner, string fileName)
        {
            ScanResult result;

            WIA.CommonDialogClass cdc       = new WIA.CommonDialogClass();
            WIA.ImageFile         imageFile = null;

            try
            {
                imageFile = cdc.ShowAcquireImage(WIA.WiaDeviceType.UnspecifiedDeviceType,
                                                 WIA.WiaImageIntent.UnspecifiedIntent,
                                                 WIA.WiaImageBias.MaximizeQuality,
                                                 "{00000000-0000-0000-0000-000000000000}",
                                                 true,
                                                 true,
                                                 false);

                Marshal.ReleaseComObject(cdc);
                cdc = null;
            }

            catch (System.Runtime.InteropServices.COMException)
            {
                result    = ScanResult.DeviceBusy;
                imageFile = null;
            }

            if (imageFile != null)
            {
                imageFile.SaveFile(fileName);
                result = ScanResult.Success;
            }
            else
            {
                result = ScanResult.UserCancelled;
            }

            return(result);
        }
コード例 #3
0
ファイル: WiaProxy32.cs プロジェクト: nkaligin/paint-mono
        private static ScanResult Scan(string fileName)
        {
            ScanResult result;

            WIA.CommonDialogClass cdc = new WIA.CommonDialogClass();
            WIA.ImageFile imageFile = null;

            try
            {
                imageFile = cdc.ShowAcquireImage(WIA.WiaDeviceType.UnspecifiedDeviceType,
                                                 WIA.WiaImageIntent.UnspecifiedIntent,
                                                 WIA.WiaImageBias.MaximizeQuality,
                                                 "{00000000-0000-0000-0000-000000000000}",
                                                 true,
                                                 true,
                                                 false);
            }

            catch (System.Runtime.InteropServices.COMException)
            {
                result = ScanResult.DeviceBusy;
                imageFile = null;
            }

            if (imageFile != null)
            {
                imageFile.SaveFile(fileName);
                result = ScanResult.Success;
            }
            else
            {
                result = ScanResult.UserCancelled;
            }

            return result;
        }
コード例 #4
0
ファイル: Imagen.cs プロジェクト: solutema/ultralight
                private void BotonCapturarImagen_Click(object sender, EventArgs e)
                {
#if WINDOWS
                        try {
                                WIA.CommonDialogClass WiaDialog = new WIA.CommonDialogClass();
                                WIA.ImageFile WiaImage = null;
                                
                                WiaImage = WiaDialog.ShowAcquireImage(
                                        WIA.WiaDeviceType.UnspecifiedDeviceType,
                                        WIA.WiaImageIntent.ColorIntent,
                                        WIA.WiaImageBias.MaximizeQuality,
                                        System.Drawing.Imaging.ImageFormat.Jpeg.Guid.ToString("B"), true, false, false);

                                if (WiaImage != null) {
                                        WIA.Vector vector = WiaImage.FileData;
                                        using (Entrada.AuxForms.ImagenRecorte Recorte = new Entrada.AuxForms.ImagenRecorte()) {
                                                Recorte.Imagen = System.Drawing.Image.FromStream(new System.IO.MemoryStream((byte[])vector.get_BinaryData()));
                                                if (Recorte.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                                                        EntradaImagen.Image = Recorte.Imagen;
                                                        this.Changed = true;
                                                        this.ActualizarElemento();
                                                }
                                        }
                                }
                        } catch (Exception ex) {
                                Lui.Forms.MessageBox.Show("No se puede conectar con el dispositivo de captura. " + ex.Message, "Error");
                        }
#endif
                }