Advertisement
Fhernd

Principal.cs

Mar 13th, 2018
1,145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4.  
  5. namespace R808ImagenVistaReducida
  6. {
  7.     public partial class Principal : Form
  8.     {
  9.         private Image imagenVistaRedida;
  10.  
  11.         public Principal()
  12.         {
  13.             InitializeComponent();
  14.         }
  15.  
  16.         private void Principal_Load(object sender, EventArgs e)
  17.         {
  18.             using (Image imagen = Image.FromFile(@"Resources\VisualStudio-Logo.jpg"))
  19.             {
  20.                 int anchoVistaReducida = 0;
  21.                 int altoVistaReducida = 0;
  22.  
  23.                 if (imagen.Width > imagen.Height)
  24.                 {
  25.                     anchoVistaReducida = 200;
  26.                     altoVistaReducida = Convert.ToInt32(((200F / imagen.Width) * imagen.Height));
  27.                 }
  28.                 else
  29.                 {
  30.                     altoVistaReducida = 200;
  31.                     anchoVistaReducida = Convert.ToInt32(((200F / imagen.Height) * imagen.Width));
  32.                 }
  33.  
  34.                 imagenVistaRedida = imagen.GetThumbnailImage(anchoVistaReducida, altoVistaReducida, null, IntPtr.Zero);
  35.             }
  36.         }
  37.  
  38.         private void Principal_Paint(object sender, PaintEventArgs e)
  39.         {
  40.             e.Graphics.DrawImage(imagenVistaRedida, 10, 10);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement