Пример #1
0
        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            Imagen img;
            int    loadResult;
            String url       = openFileDialog1.FileName;
            String name      = Path.GetFileName(url);
            String extension = Path.GetExtension(url);

            if (extension != ".ppm" && extension != ".png" && extension != ".jpg")
            {
                MessageBox.Show("Error: Extensión inválida.");
                return;
            }

            img = new Imagen(url);
            if (extension == ".ppm")
            {
                loadResult = img.CargarPPM();
            }
            else
            {
                loadResult = img.CargarBMP(url);
            }
            if (loadResult == -1)
            {
                MessageBox.Show("Error: Archivo no encontrado.");
                return;
            }
            else if (loadResult == -2)
            {
                MessageBox.Show("Error: Archivo no encontrado.");
                return;
            }

            this.bmp = img.ConvertirPPMaBMP();
            getNextPictureBox().Image    = (Image)bmp;
            getNextPictureBox().SizeMode = PictureBoxSizeMode.StretchImage;
            imagenesCargadas++;

            if (imagenesCargadas != 9)
            {
                label2.Text = "Faltan " + (9 - imagenesCargadas) + " imágenes por seleccionar";
                return;
            }

            this.button1.Enabled = false;
            this.button1.Visible = false;
            this.label2.Visible  = false;

            this.botonGuardar.Visible = true;
        }
Пример #2
0
        //Cargar imagen.ppm en memoria
        static string Cargar(Imagen img)
        {
            switch (img.CargarPPM())
            {
            case 0:
                return("Imagen cargada correctamente.");

            case -1:
                return("Imagen no encontrada.");

            case -2:
                return("Formato de los datos de la imagen incorrectos.");

            default:
                return("");
            }
        }