codigos completos visual studio 2010

32
Practica 1 namespace practica_1_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { String entrada, salida; double centigrados, farenheit; entrada = t1.Text; centigrados = double.Parse(entrada); // convierte texto a numero farenheit = centigrados * 1.8 + 32; salida = farenheit.ToString(); //convierte numero a texto t2.Text = salida; } } } Practica 2 namespace practica_2_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { double entrada, salida=0, euro, peso, dolar; String texto_entrada, texto_salida,texto_dolar,texto_peso,texto_euro; texto_entrada=t1.Text; entrada = Double.Parse(texto_entrada); texto_dolar=t3.Text; dolar=Double.Parse(texto_dolar); texto_euro=t5.Text; euro=Double.Parse(texto_euro); texto_peso=t4.Text; if (c1.Checked) { salida= entrada / dolar; } if(c2.Checked) { salida=entrada* dolar; } if (c3.Checked) { salida = entrada / euro;

Upload: marco-antonio-gomez-valverde

Post on 12-Dec-2015

21 views

Category:

Documents


0 download

DESCRIPTION

Programas de ejemplo en visual studio 2010

TRANSCRIPT

Practica 1

namespace practica_1_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { String entrada, salida; double centigrados, farenheit; entrada = t1.Text; centigrados = double.Parse(entrada); // convierte texto a numero farenheit = centigrados * 1.8 + 32; salida = farenheit.ToString(); //convierte numero a texto t2.Text = salida; } } } Practica 2 namespace practica_2_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { double entrada, salida=0, euro, peso, dolar; String texto_entrada, texto_salida,texto_dolar,texto_peso,texto_euro; texto_entrada=t1.Text; entrada = Double.Parse(texto_entrada); texto_dolar=t3.Text; dolar=Double.Parse(texto_dolar); texto_euro=t5.Text; euro=Double.Parse(texto_euro); texto_peso=t4.Text; if (c1.Checked) { salida= entrada / dolar; } if(c2.Checked) { salida=entrada* dolar; } if (c3.Checked) { salida = entrada / euro;

} if (c4.Checked) { salida = entrada * euro; } if (c5.Checked) { salida = (entrada * dolar)/euro; } if (c6.Checked) { salida = (entrada * euro)/dolar; } texto_salida = salida.ToString(); t2.Text = texto_salida; } private void checkBox2_CheckedChanged(object sender, EventArgs e) { } private void c1_Click(object sender, EventArgs e) { c2.Checked = false; c3.Checked = false; c4.Checked = false; c5.Checked = false; c6.Checked = false; } private void c2_Click(object sender, EventArgs e) { c1.Checked = false; c3.Checked = false; c4.Checked = false; c5.Checked = false; c6.Checked = false; } private void c3_Click(object sender, EventArgs e) { c1.Checked = false; c2.Checked = false; c4.Checked = false; c5.Checked = false; c6.Checked = false; } private void c4_Click(object sender, EventArgs e) { c1.Checked = false; c2.Checked = false; c3.Checked = false;

c5.Checked = false; c6.Checked = false; } private void c5_Click(object sender, EventArgs e) { c1.Checked = false; c2.Checked = false; c3.Checked = false; c4.Checked = false; c6.Checked = false; } private void c6_Click(object sender, EventArgs e) { c1.Checked = false; c2.Checked = false; c3.Checked = false; c4.Checked = false; c5.Checked = false; } } } Practica 3 namespace practica_3_2_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.SelectedIndex == 0) { panel1.BackColor = Color.Black; label1.Text = "0"; } if (comboBox1.SelectedIndex == 1) { panel1.BackColor = Color.Brown; label1.Text = "1"; } if (comboBox1.SelectedIndex == 2) { panel1.BackColor = Color.Red; label1.Text = "2"; } if (comboBox1.SelectedIndex == 3) { panel1.BackColor = Color.Orange; label1.Text = "3"; } if (comboBox1.SelectedIndex == 4) {

panel1.BackColor = Color.Yellow; label1.Text = "4"; } if (comboBox1.SelectedIndex == 5) { panel1.BackColor = Color.Green; label1.Text = "5"; } if (comboBox1.SelectedIndex == 6) { panel1.BackColor = Color.Blue; label1.Text = "6"; } if (comboBox1.SelectedIndex == 7) { panel1.BackColor = Color.Violet; label1.Text = "7"; } if (comboBox1.SelectedIndex == 8) { panel1.BackColor = Color.Gray; label1.Text = "8"; } if (comboBox1.SelectedIndex == 9) { panel1.BackColor = Color.White; label1.Text = "9"; } } private void label3_Click(object sender, EventArgs e) { } private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox2.SelectedIndex == 0) { panel2.BackColor = Color.Black; label2.Text = "0"; } if (comboBox2.SelectedIndex == 1) { panel2.BackColor = Color.Brown; label2.Text = "1"; } if (comboBox2.SelectedIndex == 2) { panel2.BackColor = Color.Red; label2.Text = "2"; } if (comboBox2.SelectedIndex == 3) { panel2.BackColor = Color.Orange; label2.Text = "3"; } if (comboBox2.SelectedIndex == 4)

{ panel2.BackColor = Color.Yellow; label2.Text = "4"; } if (comboBox2.SelectedIndex == 5) { panel2.BackColor = Color.Green; label2.Text = "5"; } if (comboBox2.SelectedIndex == 6) { panel2.BackColor = Color.Blue; label2.Text = "6"; } if (comboBox2.SelectedIndex == 7) { panel2.BackColor = Color.Violet; label2.Text = "7"; } if (comboBox2.SelectedIndex == 8) { panel2.BackColor = Color.Gray; label2.Text = "8"; } if (comboBox2.SelectedIndex == 9) { panel2.BackColor = Color.White; label2.Text = "9"; } } private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox3.SelectedIndex == 0) { panel3.BackColor = Color.Black; label3.Text = "x10 a la 1"; } if (comboBox3.SelectedIndex == 1) { panel3.BackColor = Color.Brown; label3.Text = "x10 a la 2"; } if (comboBox3.SelectedIndex == 2) { panel3.BackColor = Color.Red; label3.Text = "x10 a la 3"; } if (comboBox3.SelectedIndex == 3) { panel3.BackColor = Color.Orange; label3.Text = "x10 a la 4"; } if (comboBox3.SelectedIndex == 4) { panel3.BackColor = Color.Yellow; label3.Text = "x10 a la 5";

} if (comboBox3.SelectedIndex == 5) { panel3.BackColor = Color.Green; label3.Text = "x10 a la 6"; } if (comboBox3.SelectedIndex == 6) { panel3.BackColor = Color.Blue; label3.Text = "x10 a la 7"; } if (comboBox3.SelectedIndex == 7) { panel3.BackColor = Color.Violet; label3.Text = "x10 a la 8"; } if (comboBox3.SelectedIndex == 8) { panel3.BackColor = Color.Gray; label3.Text = "x10 a la 9"; } if (comboBox3.SelectedIndex == 9) { panel3.BackColor = Color.White; label3.Text = "x10 a la 10"; } } private void comboBox4_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox4.SelectedIndex == 0) { panel4.BackColor = Color.Silver; label4.Text = "5%"; } if (comboBox4.SelectedIndex == 1) { panel4.BackColor = Color.White; label4.Text = "10%"; } } } } Practica 4 namespace practica_4_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void checkBox2_CheckedChanged(object sender, EventArgs e) { }

private void button1_Click(object sender, EventArgs e) { double HORAS,HONORARIOS=0,IVA=0,SUBTOTAL=0,RETENCIONIVA=0,RETENCIONISR=0,TOTAL=0; string texto_HORAS, texto_HONORARIOS, texto_IVA, texto_SUBTOTAL, texto_RETENCIONIVA, texto_RETENCIONISR, texto_TOTAL; texto_HORAS = T1.Text; HORAS = double.Parse(texto_HORAS); if (C1.Checked) { SUBTOTAL = HORAS * 100; HONORARIOS = SUBTOTAL / 1.16; IVA = HONORARIOS * 0.16; RETENCIONIVA = (IVA * 2) / 3; RETENCIONISR = HONORARIOS / 10; TOTAL = SUBTOTAL - RETENCIONIVA - RETENCIONISR; } if (C2.Checked) { SUBTOTAL = HORAS * 200; HONORARIOS = SUBTOTAL / 1.16; IVA = HONORARIOS * 0.16; RETENCIONIVA = (IVA * 2) / 3; RETENCIONISR = HONORARIOS / 10; TOTAL = SUBTOTAL - RETENCIONIVA - RETENCIONISR; } texto_HONORARIOS = HONORARIOS.ToString(); T2.Text = texto_HONORARIOS; texto_IVA = IVA.ToString(); T3.Text = texto_IVA; texto_SUBTOTAL = SUBTOTAL.ToString(); T4.Text = texto_SUBTOTAL; texto_RETENCIONIVA = RETENCIONIVA.ToString(); T5.Text = texto_RETENCIONIVA; texto_RETENCIONISR = RETENCIONISR.ToString(); T6.Text = texto_RETENCIONISR; texto_TOTAL = TOTAL.ToString(); T7.Text = texto_TOTAL; } private void C1_Click(object sender, EventArgs e) { C2.Checked = false; } private void C2_Click(object sender, EventArgs e) { C1.Checked = false; } } }

Practica 5 namespace practica_5_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void trackBar1_Scroll(object sender, EventArgs e) { int rojo, verde, azul; rojo = trackBar1.Value; verde = trackBar2.Value; azul = trackBar3.Value; panel1.BackColor = Color.FromArgb(rojo, verde, azul); label1.Text = trackBar1.Value.ToString(); } private void trackBar2_Scroll(object sender, EventArgs e) { int rojo, verde, azul; rojo = trackBar1.Value; verde = trackBar2.Value; azul = trackBar3.Value; panel1.BackColor = Color.FromArgb(rojo, verde, azul); label2.Text = trackBar2.Value.ToString(); } private void trackBar3_Scroll(object sender, EventArgs e) { int rojo, verde, azul; rojo = trackBar1.Value; verde = trackBar2.Value; azul = trackBar3.Value; panel1.BackColor = Color.FromArgb(rojo, verde, azul); label3.Text = trackBar3.Value.ToString(); } private void button1_Click(object sender, EventArgs e) { panel2.BackColor=panel1.BackColor; } private void button2_Click(object sender, EventArgs e) { panel3.BackColor=panel1.BackColor; } private void button3_Click(object sender, EventArgs e) { panel4.BackColor=panel1.BackColor; } private void button4_Click(object sender, EventArgs e) {

panel5.BackColor=panel1.BackColor; } } } Practica 6 namespace practica_6_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { double A,B,C,X1=0,X2=0; string texto_A, texto_B, texto_c, texto_x1, texto_x2; texto_A = T1.Text; ; A = double.Parse(texto_A); texto_B = T2.Text; B = double.Parse(texto_B); texto_c = T2.Text; C = double.Parse(texto_c); if (((B*B)-(4*A*C))<0) { panel1.BackColor = Color.Red; } if (((B*B)-(4*A*C))>=0) { button2.Enabled =true; } } private void button2_Click(object sender, EventArgs e) { double A, B, C, X1 = 0, X2 = 0; string texto_A, texto_B, texto_c, texto_x1, texto_x2; texto_A = T1.Text; ; A = double.Parse(texto_A); texto_B = T2.Text; B = double.Parse(texto_B); texto_c = T3.Text; C = double.Parse(texto_c); X1=((-B+(Math.Sqrt((B*B)-(4*A*C))))/2); texto_x1 = X1.ToString(); T4.Text = texto_x1; X2=((-B-(Math.Sqrt((B*B)-(4*A*C))))/2); texto_x2 = X2.ToString(); T5.Text = texto_x2; } private void button3_Click(object sender, EventArgs e) {

button2.Enabled = false; panel1.BackColor = Color.Empty; T1.Text = ""; T2.Text = ""; T3.Text = ""; T4.Text = ""; T5.Text = ""; } } } Practica 7 namespace practica_7_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { double x = 0, y = 0; String entrada, salida; entrada = t1.Text; try { x = double.Parse(entrada); } catch { t1.Text = ""; } if (c1.Checked && c6.Checked) y = x; if (c1.Checked && c7.Checked) y = x / 100; if (c1.Checked && c8.Checked) y = x / 2.54; if (c1.Checked && c9.Checked) y = x / 30.48; if (c1.Checked && c10.Checked) y = x / 91.94; if (c2.Checked && c6.Checked) y = x * 100; if (c2.Checked && c7.Checked) y = x; if (c2.Checked && c8.Checked) y = x *39.37; if (c2.Checked && c9.Checked) y = x * 3.048; if (c2.Checked && c10.Checked) y = x * 1.09; if (c3.Checked && c6.Checked) y = x * 2.54; if (c3.Checked && c7.Checked) y = x /39.37; if (c3.Checked && c8.Checked) y = x; if (c3.Checked && c9.Checked) y = x / 12; if (c3.Checked && c10.Checked) y = x /36; if (c4.Checked && c6.Checked) y = x * 30.48; if (c4.Checked && c7.Checked) y = x / 3.048; if (c4.Checked && c8.Checked) y = x * 12; if (c4.Checked && c9.Checked) y = x; if (c4.Checked && c10.Checked) y = x * .333; if (c5.Checked && c6.Checked) y = x * 91.44; if (c5.Checked && c7.Checked) y = x * .9144; if (c5.Checked && c8.Checked) y = x * 36; if (c5.Checked && c9.Checked) y = x * 3;

if (c5.Checked && c10.Checked) y = x; if (c1.Checked || c2.Checked || c3.Checked) label1.Text = "sistema metrico"; if (c4.Checked || c5.Checked) label1.Text = "sistema ingles"; salida = y.ToString(); t2.Text = salida; } private void checkBox1_CheckedChanged(object sender, EventArgs e) { } private void c1_Click(object sender, EventArgs e) { c2.Checked = false; c3.Checked = false; c4.Checked = false; c5.Checked = false; } private void c2_Click(object sender, EventArgs e) { c1.Checked = false; c3.Checked = false; c4.Checked = false; c5.Checked = false; } private void c3_Click(object sender, EventArgs e) { c1.Checked = false; c2.Checked = false; c4.Checked = false; c5.Checked = false; } private void c4_Click(object sender, EventArgs e) { c1.Checked = false; c2.Checked = false; c3.Checked = false; c5.Checked = false; } private void c5_Click(object sender, EventArgs e) { c1.Checked = false; c2.Checked = false; c3.Checked = false;

c4.Checked = false; } private void c6_Click(object sender, EventArgs e) { c7.Checked = false; c8.Checked = false; c9.Checked = false; c10.Checked = false; } private void c7_Click(object sender, EventArgs e) { c6.Checked = false; c8.Checked = false; c9.Checked = false; c10.Checked = false; } private void c8_Click(object sender, EventArgs e) { c6.Checked = false; c7.Checked = false; c9.Checked = false; c10.Checked = false; } private void c9_Click(object sender, EventArgs e) { c6.Checked = false; c7.Checked = false; c8.Checked = false; c10.Checked = false; } private void c10_Click(object sender, EventArgs e) { c6.Checked = false; c7.Checked = false; c8.Checked = false; c9.Checked = false; } } } Practica 8 namespace practica_8_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

int x, y; Bitmap uno = new Bitmap(100, 100); private void pictureBox1_Click(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { for (x = 0; x < 100; x++) { for (y = 0; y < 100; y++) { uno.SetPixel(x, y, Color.White); } } pictureBox1.Image = uno; } private void button1_Click(object sender, EventArgs e) { try { int X1,Y1; string texto_x,texto_y; texto_x = t1.Text; X1 = int.Parse(texto_x); texto_y = t2.Text; Y1=int.Parse(texto_y); for (x=X1 ;x<X1+30 ; x++) { uno.SetPixel(x, Y1, Color.Red); } pictureBox1.Image = uno; } catch { } } private void button2_Click(object sender, EventArgs e) { try { int x1, y1; string texto_x, texto_y; texto_x = t1.Text; x1 = int.Parse(texto_x); texto_y = t2.Text; y1 = int.Parse(texto_y); for (x =x1; x < x1+30; x++) { uno.SetPixel(x,y1, Color.Blue); }

pictureBox1.Image = uno; } catch { } } private void button3_Click(object sender, EventArgs e) { try { int x1, y1; string texto_x, texto_y; texto_x = t1.Text; x1 = int.Parse(texto_x); texto_y = t2.Text; y1 = int.Parse(texto_y); for (x =x1; x < x1+30; x++) { uno.SetPixel(x, y1, Color.Yellow); } pictureBox1.Image = uno; } catch { } } } } Practica 9 namespace practica_9_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { timer1.Start(); } int x = 0; private void timer1_Tick(object sender, EventArgs e) { if (x == 0) { label1.Text = "0"; panel1.BackColor = Color.Red; panel2.BackColor = Color.Red; panel3.BackColor = Color.Red; panel4.BackColor = Color.Red; panel5.BackColor = Color.Red; panel6.BackColor = Color.Red; panel7.BackColor = Color.Empty; }

if (x == 1) { label1.Text = "1"; panel1.BackColor = Color.Empty; panel2.BackColor = Color.Blue; panel3.BackColor = Color.Blue; panel4.BackColor = Color.Empty; panel5.BackColor = Color.Empty; panel6.BackColor = Color.Empty; panel7.BackColor = Color.Empty; } if (x == 2) { label1.Text = "2"; panel1.BackColor = Color.Green; panel2.BackColor = Color.Green; panel3.BackColor = Color.Empty; panel4.BackColor = Color.Green; panel5.BackColor = Color.Green; panel6.BackColor = Color.Empty; panel7.BackColor = Color.Green; } if (x == 3) { label1.Text = "3"; panel1.BackColor = Color.Yellow; panel2.BackColor = Color.Yellow; panel3.BackColor = Color.Yellow; panel4.BackColor = Color.Yellow; panel5.BackColor = Color.Empty; panel6.BackColor = Color.Empty; panel7.BackColor = Color.Yellow; } if (x == 4) { label1.Text = "4"; panel1.BackColor = Color.Empty; panel2.BackColor = Color.Red; panel3.BackColor = Color.Red; panel4.BackColor = Color.Empty; panel5.BackColor = Color.Empty; panel6.BackColor = Color.Red; panel7.BackColor = Color.Red; } if (x == 5) { label1.Text = "5"; panel1.BackColor = Color.Red; panel2.BackColor = Color.Empty; panel3.BackColor = Color.Red; panel4.BackColor = Color.Red; panel5.BackColor = Color.Empty; panel6.BackColor = Color.Red; panel7.BackColor = Color.Red; } if (x == 6) {

label1.Text = "6"; panel1.BackColor = Color.Red; panel2.BackColor = Color.Empty; panel3.BackColor = Color.Red; panel4.BackColor = Color.Red; panel5.BackColor = Color.Red; panel6.BackColor = Color.Red; panel7.BackColor = Color.Red; } if (x == 7) { label1.Text = "7"; panel1.BackColor = Color.Red; panel2.BackColor = Color.Red; panel3.BackColor = Color.Red; panel4.BackColor = Color.Empty; panel5.BackColor = Color.Empty; panel6.BackColor = Color.Empty; panel7.BackColor = Color.Empty; } if (x == 8) { label1.Text = "8"; panel1.BackColor = Color.Red; panel2.BackColor = Color.Red; panel3.BackColor = Color.Red; panel4.BackColor = Color.Red; panel5.BackColor = Color.Red; panel6.BackColor = Color.Red; panel7.BackColor = Color.Red; } if (x == 9) { label1.Text = "9"; x = -1; panel1.BackColor = Color.Red; panel2.BackColor = Color.Red; panel3.BackColor = Color.Red; panel4.BackColor = Color.Red; panel5.BackColor = Color.Empty; panel6.BackColor = Color.Red; panel7.BackColor = Color.Red; } x++; } private void button2_Click(object sender, EventArgs e) { timer1.Stop(); } private void button3_Click(object sender, EventArgs e) { x = 0; label1.Text = "0"; { panel1.BackColor = Color.Red;

panel2.BackColor = Color.Red; panel3.BackColor = Color.Red; panel4.BackColor = Color.Red; panel5.BackColor = Color.Red; panel6.BackColor = Color.Red; panel7.BackColor = Color.Empty; } } } } Practica 10 namespace practica_10_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int x, y, alto, ancho, rojo, verde, azul, gris; double formula; Bitmap original = new Bitmap(pictureBox1.Image); Bitmap negativo = new Bitmap(pictureBox1.Image); Bitmap grises = new Bitmap(pictureBox1.Image); Bitmap umbralizado = new Bitmap(pictureBox1.Image); alto = original.Height; ancho = original.Width; for (x=0; x<ancho;x++) { for (y=0; y<alto; y++) { rojo=original.GetPixel(x,y).R; verde=original.GetPixel(x,y).G; azul=original.GetPixel(x,y).B; formula=rojo*0.3+verde*0.59+azul*0.11; gris=Convert.ToInt16(formula); negativo.SetPixel(x,y,Color.FromArgb(255-rojo,255-verde,255-azul)); grises.SetPixel(x,y,Color.FromArgb(gris,gris,gris)); if (gris<128) umbralizado.SetPixel(x,y,Color.Black); else umbralizado.SetPixel(x,y,Color.White); } } pictureBox2.Image=negativo; pictureBox3.Image=grises; pictureBox4.Image=umbralizado; } } } Practica 11 namespace practica_11_Acosta_Ortiz { public partial class Form1 : Form

{ public Form1() { InitializeComponent(); } int x, y; Bitmap uno = new Bitmap(100, 100); private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { int x, y, alto, ancho,rojo,verde,azul; Bitmap original = new Bitmap(pictureBox1.Image); Bitmap izquierda = new Bitmap(pictureBox1.Image); Bitmap derecha = new Bitmap(pictureBox1.Image); Bitmap arriba = new Bitmap(pictureBox1.Image); alto = original.Height; ancho = original.Width; for (x = 0; x < ancho; x++) { for (y = 0; y < alto; y++) { rojo = original.GetPixel(x, y).R; verde = original.GetPixel(x, y).G; azul = original.GetPixel(x, y).B; izquierda.SetPixel(ancho-y-1,x, Color.FromArgb(rojo, verde, azul)); arriba.SetPixel(ancho-x-1, alto-y-1, Color.FromArgb(rojo,verde,azul)); derecha.SetPixel(y , alto-x-1, Color.FromArgb(rojo, verde, azul)); } pictureBox4.Image = arriba; pictureBox2.Image = izquierda; pictureBox3.Image = derecha; } } } } Practica 12 namespace practica_12_Acosta_Ortiz { public partial class Form1 : Form { public Form1() {

InitializeComponent(); } int x, y; Bitmap uno = new Bitmap(100, 100); private void button1_Click(object sender, EventArgs e) { int x, y, alto, ancho,rojo,verde,azul; Bitmap original = new Bitmap(pictureBox1.Image); Bitmap izquierda = new Bitmap(pictureBox1.Image); Bitmap derecha = new Bitmap(pictureBox1.Image); Bitmap arriba = new Bitmap(pictureBox1.Image); alto = original.Height; ancho = original.Width; for (x = 0; x < ancho; x++) { for (y = 0; y < alto; y++) { rojo = original.GetPixel(x, y).R; verde = original.GetPixel(x, y).G; azul = original.GetPixel(x, y).B; izquierda.SetPixel(ancho-x-1, y, Color.FromArgb(rojo, verde, azul)); arriba.SetPixel(ancho - x - 1, alto - y - 1, Color.FromArgb(rojo, verde, azul)); derecha.SetPixel(x, alto - y - 1, Color.FromArgb(rojo, verde, azul)); } } pictureBox4.Image = arriba; pictureBox2.Image = izquierda; pictureBox3.Image = derecha; } private void Form1_Load(object sender, EventArgs e) { } } } Practica 13 namespace practica_13_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { int x, y, alto, ancho, rojo, verde, azul, nuevo_rojo=0, nuevo_azul=0, nuevo_verde=0; Bitmap original = new Bitmap(pictureBox1.Image); Bitmap uno = new Bitmap(pictureBox1.Image); Bitmap dos = new Bitmap(pictureBox1.Image); alto = original.Height;

ancho = original.Width; for (x = 0; x < ancho; x++) { for (y = 0; y < alto; y++) { rojo = uno.GetPixel(x, y).R; verde = uno.GetPixel(x, y).G; azul = uno.GetPixel(x, y).B; if (rojo < 85) nuevo_rojo = 0; else if (rojo > 85) nuevo_rojo = 170; else if(rojo >170) nuevo_rojo = 255; if (verde < 85) nuevo_verde = 0; else if (verde > 85) nuevo_verde = 170; else if (verde > 170) nuevo_verde = 255; if (azul <85) nuevo_azul = 0; else if (azul > 85) nuevo_azul = 170; else if (azul >170) nuevo_azul = 255; dos.SetPixel(x, y, Color.FromArgb(nuevo_rojo, nuevo_verde, nuevo_azul)); } } pictureBox2.Image = dos; } private void button1_Click(object sender, EventArgs e) { int x, y, alto, ancho, rojo, verde, azul,nuevo_rojo,nuevo_azul,nuevo_verde; Bitmap original = new Bitmap(pictureBox1.Image); Bitmap uno = new Bitmap(pictureBox1.Image); Bitmap dos = new Bitmap(pictureBox1.Image); alto = original.Height; ancho = original.Width; for (x = 0; x < ancho; x++) { for (y = 0; y < alto; y++) { rojo = uno.GetPixel(x, y).R; verde = uno.GetPixel(x, y).G; azul = uno.GetPixel(x, y).B; if (rojo > 128) nuevo_rojo = 255; else nuevo_rojo = 0; if (verde > 128) nuevo_verde = 255; else nuevo_verde = 0; if (azul > 128) nuevo_azul = 255; else nuevo_azul = 0; dos.SetPixel(x, y, Color.FromArgb(nuevo_rojo, nuevo_verde, nuevo_azul)); } } pictureBox2.Image = dos; } private void button3_Click(object sender, EventArgs e) {

int x, y, alto, ancho, rojo, verde, azul, nuevo_rojo = 0, nuevo_azul = 0, nuevo_verde = 0; Bitmap original = new Bitmap(pictureBox1.Image); Bitmap uno = new Bitmap(pictureBox1.Image); Bitmap dos = new Bitmap(pictureBox1.Image); alto = original.Height; ancho = original.Width; for (x = 0; x < ancho; x++) { for (y = 0; y < alto; y++) { rojo = uno.GetPixel(x, y).R; verde = uno.GetPixel(x, y).G; azul = uno.GetPixel(x, y).B; if (rojo < 64) nuevo_rojo = 0; else if (rojo > 64) nuevo_rojo = 64; else if (rojo < 128) nuevo_rojo = 128; else if (rojo >128 ) nuevo_rojo = 255; if (verde < 64) nuevo_verde = 0; else if (verde > 64) nuevo_verde = 64; else if (verde< 128) nuevo_verde = 128; else if (verde > 128) nuevo_verde = 255; if (azul < 64) nuevo_azul = 0; else if (azul > 64) nuevo_azul = 64; else if (azul < 128) nuevo_azul = 128; else if (azul > 128) nuevo_azul = 255; dos.SetPixel(x, y, Color.FromArgb(nuevo_rojo, nuevo_verde, nuevo_azul)); } } pictureBox2.Image = dos; } } } Practica 14 namespace practica_14_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void trackBar1_Scroll(object sender, EventArgs e) { int x, y, alto, ancho, rojo, verde, azul, gris; double formula; Bitmap original = new Bitmap(pictureBox1.Image); Bitmap negativo = new Bitmap(pictureBox1.Image); Bitmap grises = new Bitmap(pictureBox1.Image); Bitmap umbralizado = new Bitmap(pictureBox1.Image); alto = original.Height; ancho = original.Width; for (x = 0; x < ancho; x++) { for (y = 0; y < alto; y++)

{ rojo = original.GetPixel(x, y).R; verde = original.GetPixel(x, y).G; azul = original.GetPixel(x, y).B; formula = rojo * 0.3 + verde * 0.59 + azul * 0.11; gris = Convert.ToInt16(formula); negativo.SetPixel(x, y, Color.FromArgb(255 - rojo, 255 - verde, 255 - azul)); grises.SetPixel(x, y, Color.FromArgb(gris, gris, gris)); if (gris < trackBar1.Value) umbralizado.SetPixel(x, y, Color.Black); else umbralizado.SetPixel(x, y, Color.White); } } pictureBox2.Image = negativo; pictureBox2.Image = grises; pictureBox2.Image = umbralizado; } } } Practica 15 namespace practica_15_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void trackBar1_Scroll(object sender, EventArgs e) { int x, y, alto, ancho, rojo, verde, azul,gris; Bitmap original = new Bitmap(pictureBox1.Image); double formula; Bitmap ROJO = new Bitmap(pictureBox1.Image); alto = original.Height; ancho = original.Width; for (x = 0; x < ancho; x++) { for (y = 0; y < alto; y++) { rojo = original.GetPixel(x, y).R; verde = original.GetPixel(x, y).G; azul = original.GetPixel(x, y).B; formula = rojo * 1 + verde * 0+ azul * 0; gris = Convert.ToInt16(formula); if (gris < trackBar1.Value) ROJO.SetPixel(x, y, Color.White); else ROJO.SetPixel(x, y, Color.Red); } } pictureBox2.Image = ROJO; } private void trackBar2_Scroll(object sender, EventArgs e) { int x, y, alto, ancho, rojo, verde, azul, gris;

Bitmap original = new Bitmap(pictureBox1.Image); double formula; Bitmap VERDE = new Bitmap(pictureBox1.Image); alto = original.Height; ancho = original.Width; for (x = 0; x < ancho; x++) { for (y = 0; y < alto; y++) { rojo = original.GetPixel(x, y).R; verde = original.GetPixel(x, y).G; azul = original.GetPixel(x, y).B; formula = rojo * 0 + verde * 1 + azul * 0; gris = Convert.ToInt16(formula); if (gris < trackBar2.Value) VERDE.SetPixel(x, y, Color.White); else VERDE.SetPixel(x, y, Color.Green); } } pictureBox3.Image = VERDE; } private void trackBar3_Scroll(object sender, EventArgs e) { int x, y, alto, ancho, rojo, verde, azul, gris; Bitmap original = new Bitmap(pictureBox1.Image); double formula; Bitmap AZUL = new Bitmap(pictureBox1.Image); alto = original.Height; ancho = original.Width; for (x = 0; x < ancho; x++) { for (y = 0; y < alto; y++) { rojo = original.GetPixel(x, y).R; verde = original.GetPixel(x, y).G; azul = original.GetPixel(x, y).B; formula = rojo * 0 + verde * 0 + azul * 1; gris = Convert.ToInt16(formula); if (gris < trackBar3.Value) AZUL.SetPixel(x, y, Color.White); else AZUL.SetPixel(x, y, Color.Blue); } } pictureBox4.Image = AZUL; } } } Practica 16 namespace practica_16_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent();

} Bitmap original; Bitmap uno; Bitmap dos = new Bitmap(200, 200); private void textBox2_TextChanged(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { pictureBox1.Image = original; } private void button1_Click(object sender, EventArgs e) { int x, y, i, j; Color micolor; try { x = int.Parse(t1.Text); y = int.Parse(t2.Text); for (i = 0; i < 200; i++) { for (j = 0; j < 200; j++) { micolor = uno.GetPixel(x + i, y + j); dos.SetPixel(i, j, micolor); } } for (i = x; i < x + 200; i++) uno.SetPixel(i, y, Color.White); for (i = x; i < x + 200; i++) uno.SetPixel(i, y + 200, Color.White); for (j = y; j < y + 200; j++) uno.SetPixel(x, j, Color.White); for (j = y; j < y + 200; j++) uno.SetPixel(x + 200, j, Color.White); pictureBox1.Image = uno; pictureBox2.Image = dos; } catch { }; } private void Form1_Load(object sender, EventArgs e) { original = new Bitmap(pictureBox1.Image); uno = new Bitmap(pictureBox1.Image); } } }

Practica 17 namespace practica_17_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Bitmap original = new Bitmap(pictureBox2.Image); int x, y, alto, ancho; Color micolor; alto = original.Height; ancho = original.Width; Bitmap salida2=new Bitmap(ancho/8,alto/8); for (x = 0; x < ancho - 8; x = x + 8) { for (y = 0; y < alto - 8; y = y + 8) { micolor = original.GetPixel(x, y); salida2.SetPixel(x / 8, y / 8, micolor); } } pictureBox3.Image = salida2; } private void button2_Click(object sender, EventArgs e) { int x, y, alto, ancho, rojo, verde, azul, gris; double formula; Bitmap original = new Bitmap(pictureBox1.Image); Bitmap grises = new Bitmap(pictureBox1.Image); alto = original.Height; ancho = original.Width; for (x = 0; x < ancho; x++) { for (y = 0; y < alto; y++) { rojo = original.GetPixel(x, y).R; verde = original.GetPixel(x, y).G; azul = original.GetPixel(x, y).B; formula = rojo * 0.3 + verde * 0.59 + azul * 0.11; gris = Convert.ToInt16(formula); grises.SetPixel(x, y, Color.FromArgb(gris, gris, gris)); } pictureBox2.Image = grises; } } }

} Practica 18 namespace practica_18_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void trackBar1_Scroll(object sender, EventArgs e) { panel1.BackColor = Color.FromArgb(trackBar1.Value, trackBar2.Value, trackBar3.Value); } private void trackBar2_Scroll(object sender, EventArgs e) { panel1.BackColor = Color.FromArgb(trackBar1.Value, trackBar2.Value, trackBar3.Value); } private void trackBar3_Scroll(object sender, EventArgs e) { panel1.BackColor = Color.FromArgb(trackBar1.Value, trackBar2.Value, trackBar3.Value); } private void button1_Click(object sender, EventArgs e) { int X, Y, alto,ancho,rojo, verde, azul; Bitmap original = new Bitmap(pictureBox1.Image); Bitmap uno = new Bitmap(original.Width / 4, original.Height / 4); Bitmap dos = new Bitmap(original.Width / 4, original.Height / 4); Boolean a, b, c; alto = original.Height; ancho = original.Width; for (X = 0; X < ancho - 4; X = X + 4) { for (Y = 0; Y < alto-4; Y = Y + 4) { rojo = original.GetPixel(X, Y).R; verde = original.GetPixel(X, Y).G; azul = original.GetPixel(X, Y).B; if (rojo > trackBar1.Value - 40 && rojo < trackBar1.Value + 40) a = true; else a = false; if (verde > trackBar2.Value - 40 && verde < trackBar2.Value + 40) b = true; else b = false; if (azul > trackBar3.Value - 40 && azul < trackBar3.Value + 40) c = true; else c = false; if (a && b && c) { uno.SetPixel(X / 4, Y / 4, Color.FromArgb(rojo, verde, azul)); dos.SetPixel(X / 4, Y / 4, Color.Black); } else

{ uno.SetPixel(X / 4, Y / 4, Color.White); dos.SetPixel(X / 4, Y / 4, Color.White); } } } pictureBox2.Image = uno; pictureBox3.Image = dos; } } } Practica 19 namespace practica_19_Acosta_Ortiz { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Bitmap uno = new Bitmap(pictureBox1.Image); Bitmap dos = new Bitmap(256, 256); Bitmap tres = new Bitmap(256, 256); Bitmap cuatro = new Bitmap(256, 256); Bitmap cinco = new Bitmap(256, 256); Bitmap seis = new Bitmap(256, 256); Bitmap siete = new Bitmap(256, 256); Bitmap ocho = new Bitmap(256, 256); Bitmap nueve = new Bitmap(256, 256); Bitmap diez = new Bitmap(256, 256); Bitmap once = new Bitmap(256, 256); Bitmap doce = new Bitmap(256, 256); Bitmap trece = new Bitmap(256, 256); Bitmap catorce = new Bitmap(256, 256); Bitmap quince = new Bitmap(256, 256); Bitmap diesiseis = new Bitmap(256, 256); Bitmap diesisiete = new Bitmap(256, 256); int x, y, i, j; Color micolor; try { x = 0; y = 0; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); dos.SetPixel(i, j, micolor); } }

pictureBox1.Image = uno; pictureBox2.Image = dos; } catch { }; try { x = 256; y = 0; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); tres.SetPixel(i, j, micolor); } } pictureBox3.Image = tres; } catch { }; try { x = 512; y = 0; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); cuatro.SetPixel(i, j, micolor); } } pictureBox4.Image = cuatro ; } catch { }; try { x = 768; y = 0; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); cinco.SetPixel(i, j, micolor); } } pictureBox5.Image = cinco; } catch { }; try { x = 0; y = 256; for (i = 0; i < 256; i++) {

for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); seis.SetPixel(i, j, micolor); } } pictureBox6.Image = seis ; } catch { }; try { x = 256; y = 256; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); siete.SetPixel(i, j, micolor); } } pictureBox7.Image = siete ; } catch { }; try { x = 512; y = 256; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); ocho.SetPixel(i, j, micolor); } } pictureBox8.Image = ocho ; } catch { }; try { x = 768; y = 256; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); nueve.SetPixel(i, j, micolor); } } pictureBox9.Image = nueve ; } catch { };

try { x = 0; y = 512; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); diez.SetPixel(i, j, micolor); } } pictureBox10.Image = diez ; } catch { }; try { x = 256; y = 512; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); once.SetPixel(i, j, micolor); } } pictureBox11.Image = once ; } catch { }; try { x = 512; y = 512; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); doce.SetPixel(i, j, micolor); } } pictureBox12.Image = doce; } catch { }; try { x = 768; y = 512; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); trece.SetPixel(i, j, micolor);

} } pictureBox13.Image = trece; } catch { }; try { x = 0; y = 768; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); catorce.SetPixel(i, j, micolor); } } pictureBox14.Image = catorce ; } catch { }; try { x = 256; y = 768; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); quince.SetPixel(i, j, micolor); } } pictureBox15.Image = quince ; } catch { }; try { x = 512; y = 768; for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); diesiseis.SetPixel(i, j, micolor); } } pictureBox16.Image = diesiseis ; } catch { }; try { x = 768; y = 768;

for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { micolor = uno.GetPixel(x + i, y + j); diesisiete.SetPixel(i, j, micolor); } } pictureBox17.Image = diesisiete ; } catch { }; } } }