Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 25.78 KB | None | 0 0
  1. // --------------------------------------- TRYBY MIESZANIA --------------------------------------- //
  2.  
  3.         private void SetRGB(Bitmap bm, Bitmap bm2, int x, int y)
  4.         {
  5.             r1 = bm.GetPixel(x, y).R / 255.0;
  6.             g1 = bm.GetPixel(x, y).G / 255.0;
  7.             b1 = bm.GetPixel(x, y).B / 255.0;
  8.             r2 = bm2.GetPixel(x, y).R / 255.0;
  9.             g2 = bm2.GetPixel(x, y).G / 255.0;
  10.             b2 = bm2.GetPixel(x, y).B / 255.0;
  11.         }
  12.  
  13.         //SUMA
  14.         private void additiveToolStripMenuItem_Click(object sender, EventArgs e)
  15.         {
  16.             if (check == true && check2 == true)
  17.             {
  18.                 bm = new Bitmap(pictureBox1.Image);
  19.                 bm2 = new Bitmap(pictureBox2.Image);
  20.                 temp = bm;
  21.                 temp2 = bm2;
  22.                 temp3 = new Bitmap(600, 400);
  23.  
  24.                 for (int i = 0; i < temp.Width; i++)
  25.                 {
  26.                     for (int j = 0; j < temp.Height; j++)
  27.                     {
  28.                         SetRGB(temp, temp2, i, j);
  29.  
  30.                         double red = r1 + r2;
  31.                         double green = g1 + g2;
  32.                         double blue = b1 + b2;
  33.                         if (red > 1) red = 1;
  34.                         if (green > 1) green = 1;
  35.                         if (blue > 1) blue = 1;
  36.  
  37.                         red = red * 255.0;
  38.                         green = green * 255.0;
  39.                         blue = blue * 255.0;
  40.  
  41.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  42.  
  43.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  44.                     }
  45.                 }
  46.                 pictureBox3.Image = temp3;
  47.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  48.             }
  49.             else
  50.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  51.         }
  52.  
  53.         //ODEJMOWANIE
  54.         private void subtractiveToolStripMenuItem_Click(object sender, EventArgs e)
  55.         {
  56.             if (check == true && check2 == true)
  57.             {
  58.                 bm = new Bitmap(pictureBox1.Image);
  59.                 bm2 = new Bitmap(pictureBox2.Image);
  60.                 temp = bm;
  61.                 temp2 = bm2;
  62.                 temp3 = new Bitmap(600, 400);
  63.  
  64.                 for (int i = 0; i < temp.Width; i++)
  65.                 {
  66.                     for (int j = 0; j < temp.Height; j++)
  67.                     {
  68.                         SetRGB(temp, temp2, i, j);
  69.  
  70.                         double red = r1 + r2 - 1;
  71.                         double green = g1 + g2 - 1;
  72.                         double blue = b1 + b2 - 1;
  73.                         if (red < 0) red = 0;
  74.                         if (green < 0) green = 0;
  75.                         if (blue < 0) blue = 0;
  76.  
  77.                         red = red * 255.0;
  78.                         green = green * 255.0;
  79.                         blue = blue * 255.0;
  80.  
  81.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  82.  
  83.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  84.                     }
  85.                 }
  86.                 pictureBox3.Image = temp3;
  87.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  88.             }
  89.             else
  90.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  91.         }
  92.  
  93.         //ROZNICA
  94.         private void differenceToolStripMenuItem_Click(object sender, EventArgs e)
  95.         {
  96.             if (check == true && check2 == true)
  97.             {
  98.                 bm = new Bitmap(pictureBox1.Image);
  99.                 bm2 = new Bitmap(pictureBox2.Image);
  100.                 temp = bm;
  101.                 temp2 = bm2;
  102.                 temp3 = new Bitmap(600, 400);
  103.  
  104.                 for (int i = 0; i < temp.Width; i++)
  105.                 {
  106.                     for (int j = 0; j < temp.Height; j++)
  107.                     {
  108.                         SetRGB(temp, temp2, i, j);
  109.  
  110.                         double red = Math.Abs(r1 - r2);
  111.                         double green = Math.Abs(g1 - g2);
  112.                         double blue = Math.Abs(b1 - b2);
  113.  
  114.                         red = red * 255.0;
  115.                         green = green * 255.0;
  116.                         blue = blue * 255.0;
  117.  
  118.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  119.  
  120.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  121.                     }
  122.                 }
  123.                 pictureBox3.Image = temp3;
  124.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  125.             }
  126.             else
  127.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  128.         }
  129.  
  130.         //MNOZENIE
  131.         private void multiplyToolStripMenuItem_Click(object sender, EventArgs e)
  132.         {
  133.             if (check == true && check2 == true)
  134.             {
  135.                 bm = new Bitmap(pictureBox1.Image);
  136.                 bm2 = new Bitmap(pictureBox2.Image);
  137.                 temp = bm;
  138.                 temp2 = bm2;
  139.                 temp3 = new Bitmap(600, 400);
  140.  
  141.                 for (int i = 0; i < temp.Width; i++)
  142.                 {
  143.                     for (int j = 0; j < temp.Height; j++)
  144.                     {
  145.                         SetRGB(temp, temp2, i, j);
  146.  
  147.                         double red = r1 * r2;
  148.                         double green = g1 * g2;
  149.                         double blue = b1 * b2;
  150.  
  151.                         red = red * 255.0;
  152.                         green = green * 255.0;
  153.                         blue = blue * 255.0;
  154.  
  155.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  156.  
  157.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  158.                     }
  159.                 }
  160.                 pictureBox3.Image = temp3;
  161.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  162.             }
  163.             else
  164.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  165.         }
  166.  
  167.         //MNOZENIE ODWROTNOSCI
  168.         private void screenToolStripMenuItem_Click(object sender, EventArgs e)
  169.         {
  170.             if (check == true && check2 == true)
  171.             {
  172.                 bm = new Bitmap(pictureBox1.Image);
  173.                 bm2 = new Bitmap(pictureBox2.Image);
  174.                 temp = bm;
  175.                 temp2 = bm2;
  176.                 temp3 = new Bitmap(600, 400);
  177.  
  178.                 for (int i = 0; i < temp.Width; i++)
  179.                 {
  180.                     for (int j = 0; j < temp.Height; j++)
  181.                     {
  182.                         SetRGB(temp, temp2, i, j);
  183.  
  184.                         double red = 1 - (1 - r1) * (1 - r2);
  185.                         double green = 1 - (1 - g1) * (1 - g2);
  186.                         double blue = 1 - (1 - b1) * (1 - b2);
  187.  
  188.                         red = red * 255.0;
  189.                         green = green * 255.0;
  190.                         blue = blue * 255.0;
  191.  
  192.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  193.  
  194.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  195.                     }
  196.                 }
  197.                 pictureBox3.Image = temp3;
  198.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  199.             }
  200.             else
  201.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  202.         }
  203.  
  204.         //NEGACJA
  205.         private void negationToolStripMenuItem_Click(object sender, EventArgs e)
  206.         {
  207.             if (check == true && check2 == true)
  208.             {
  209.                 bm = new Bitmap(pictureBox1.Image);
  210.                 bm2 = new Bitmap(pictureBox2.Image);
  211.                 temp = bm;
  212.                 temp2 = bm2;
  213.                 temp3 = new Bitmap(600, 400);
  214.  
  215.                 for (int i = 0; i < temp.Width; i++)
  216.                 {
  217.                     for (int j = 0; j < temp.Height; j++)
  218.                     {
  219.                         SetRGB(temp, temp2, i, j);
  220.  
  221.                         double red = 1 - Math.Abs(1 - r1 - r2);
  222.                         double green = 1 - Math.Abs(1 - g1 - g2);
  223.                         double blue = 1 - Math.Abs(1 - b1 - b2);
  224.  
  225.                         red = red * 255.0;
  226.                         green = green * 255.0;
  227.                         blue = blue * 255.0;
  228.  
  229.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  230.  
  231.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  232.                     }
  233.                 }
  234.                 pictureBox3.Image = temp3;
  235.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  236.             }
  237.             else
  238.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  239.         }
  240.  
  241.         // CIEMNIEJSZE
  242.         private void darkenToolStripMenuItem_Click(object sender, EventArgs e)
  243.         {
  244.             if (check == true && check2 == true)
  245.             {
  246.                 bm = new Bitmap(pictureBox1.Image);
  247.                 bm2 = new Bitmap(pictureBox2.Image);
  248.                 temp = bm;
  249.                 temp2 = bm2;
  250.                 temp3 = new Bitmap(600, 400);
  251.  
  252.                 for (int i = 0; i < temp.Width; i++)
  253.                 {
  254.                     for (int j = 0; j < temp.Height; j++)
  255.                     {
  256.                         SetRGB(temp, temp2, i, j);
  257.  
  258.                         double red = Math.Min(r1, r2);
  259.                         double green = Math.Min(g1, g2);
  260.                         double blue = Math.Min(b1, b2);
  261.  
  262.                         red = red * 255.0;
  263.                         green = green * 255.0;
  264.                         blue = blue * 255.0;
  265.  
  266.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  267.  
  268.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  269.                     }
  270.                 }
  271.                 pictureBox3.Image = temp3;
  272.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  273.             }
  274.             else
  275.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  276.         }
  277.  
  278.         // JASNIEJSZE
  279.         private void lightenToolStripMenuItem_Click(object sender, EventArgs e)
  280.         {
  281.             if (check == true && check2 == true)
  282.             {
  283.                 bm = new Bitmap(pictureBox1.Image);
  284.                 bm2 = new Bitmap(pictureBox2.Image);
  285.                 temp = bm;
  286.                 temp2 = bm2;
  287.                 temp3 = new Bitmap(600, 400);
  288.  
  289.                 for (int i = 0; i < temp.Width; i++)
  290.                 {
  291.                     for (int j = 0; j < temp.Height; j++)
  292.                     {
  293.                         SetRGB(temp, temp2, i, j);
  294.  
  295.                         double red = Math.Max(r1, r2);
  296.                         double green = Math.Max(g1, g2);
  297.                         double blue = Math.Max(b1, b2);
  298.  
  299.                         red = red * 255.0;
  300.                         green = green * 255.0;
  301.                         blue = blue * 255.0;
  302.  
  303.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  304.  
  305.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  306.                     }
  307.                 }
  308.                 pictureBox3.Image = temp3;
  309.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  310.             }
  311.             else
  312.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  313.         }
  314.  
  315.         // WYLACZENIE
  316.         private void exclusionToolStripMenuItem_Click(object sender, EventArgs e)
  317.         {
  318.             if (check == true && check2 == true)
  319.             {
  320.                 bm = new Bitmap(pictureBox1.Image);
  321.                 bm2 = new Bitmap(pictureBox2.Image);
  322.                 temp = bm;
  323.                 temp2 = bm2;
  324.                 temp3 = new Bitmap(600, 400);
  325.  
  326.                 for (int i = 0; i < temp.Width; i++)
  327.                 {
  328.                     for (int j = 0; j < temp.Height; j++)
  329.                     {
  330.                         SetRGB(temp, temp2, i, j);
  331.  
  332.                         double red = r1 + r2 - 2 * r1 * r2;
  333.                         double green = g1 + g2 - 2 * g1 * g2;
  334.                         double blue = b1 + b2 - 2 * b1 * b2;
  335.  
  336.                         red = red * 255.0;
  337.                         green = green * 255.0;
  338.                         blue = blue * 255.0;
  339.  
  340.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  341.  
  342.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  343.                     }
  344.                 }
  345.                 pictureBox3.Image = temp3;
  346.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  347.             }
  348.             else
  349.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  350.         }
  351.  
  352.         // NAKLADKA
  353.         private void overlayToolStripMenuItem_Click(object sender, EventArgs e)
  354.         {
  355.             if (check == true && check2 == true)
  356.             {
  357.                 bm = new Bitmap(pictureBox1.Image);
  358.                 bm2 = new Bitmap(pictureBox2.Image);
  359.                 temp = bm;
  360.                 temp2 = bm2;
  361.                 temp3 = new Bitmap(600, 400);
  362.                 double red, green, blue;
  363.                 for (int i = 0; i < temp.Width; i++)
  364.                 {
  365.                     for (int j = 0; j < temp.Height; j++)
  366.                     {
  367.                         SetRGB(temp, temp2, i, j);
  368.  
  369.                         if (r1 < 0.5)
  370.                         {
  371.                             red = 2 * r1 * r2;
  372.                         }
  373.                         else { red = 1 - 2 * (1 - r1) * (1 - r2); }
  374.  
  375.                         if (g1 < 0.5)
  376.                         {
  377.                             green = 2 * g1 * g2;
  378.                         }
  379.                         else { green = 1 - 2 * (1 - g1) * (1 - g2); }
  380.  
  381.                         if (b1 < 0.5)
  382.                         {
  383.                             blue = 2 * b1 * b2;
  384.                         }
  385.                         else { blue = 1 - 2 * (1 - b1) * (1 - b2); }
  386.  
  387.                         red = red * 255.0;
  388.                         green = green * 255.0;
  389.                         blue = blue * 255.0;
  390.  
  391.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  392.  
  393.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  394.                     }
  395.                 }
  396.                 pictureBox3.Image = temp3;
  397.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  398.             }
  399.             else
  400.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  401.         }
  402.  
  403.         // OSTRE SWIATLO
  404.         private void hardLightToolStripMenuItem_Click(object sender, EventArgs e)
  405.         {
  406.             if (check == true && check2 == true)
  407.             {
  408.                 bm = new Bitmap(pictureBox1.Image);
  409.                 bm2 = new Bitmap(pictureBox2.Image);
  410.                 temp = bm;
  411.                 temp2 = bm2;
  412.                 temp3 = new Bitmap(600, 400);
  413.                 double red, green, blue;
  414.                 for (int i = 0; i < temp.Width; i++)
  415.                 {
  416.                     for (int j = 0; j < temp.Height; j++)
  417.                     {
  418.                         SetRGB(temp, temp2, i, j);
  419.  
  420.                         if (r2 < 0.5)
  421.                         {
  422.                             red = 2 * r1 * r2;
  423.                         }
  424.                         else { red = 1 - 2 * (1 - r1) * (1 - r2); }
  425.  
  426.                         if (g2 < 0.5)
  427.                         {
  428.                             green = 2 * g1 * g2;
  429.                         }
  430.                         else { green = 1 - 2 * (1 - g1) * (1 - g2); }
  431.  
  432.                         if (b2 < 0.5)
  433.                         {
  434.                             blue = 2 * b1 * b2;
  435.                         }
  436.                         else { blue = 1 - 2 * (1 - b1) * (1 - b2); }
  437.  
  438.                         red = red * 255.0;
  439.                         green = green * 255.0;
  440.                         blue = blue * 255.0;
  441.  
  442.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  443.  
  444.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  445.                     }
  446.                 }
  447.                 pictureBox3.Image = temp3;
  448.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  449.             }
  450.             else
  451.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  452.         }
  453.  
  454.         // LAGODNE SWIATLO
  455.         private void softLightToolStripMenuItem_Click(object sender, EventArgs e)
  456.         {
  457.             if (check == true && check2 == true)
  458.             {
  459.                 bm = new Bitmap(pictureBox1.Image);
  460.                 bm2 = new Bitmap(pictureBox2.Image);
  461.                 temp = bm;
  462.                 temp2 = bm2;
  463.                 temp3 = new Bitmap(600, 400);
  464.                 double red, green, blue;
  465.                 for (int i = 0; i < temp.Width; i++)
  466.                 {
  467.                     for (int j = 0; j < temp.Height; j++)
  468.                     {
  469.                         SetRGB(temp, temp2, i, j);
  470.  
  471.                         if (r2 < 0.5)
  472.                         {
  473.                             red = 2 * r1 * r2 + Math.Pow(r1, 2) * (1 - 2 * r2);
  474.                         }
  475.                         else { red = 2 * r1 * (1 - r2) + Math.Sqrt(r1) * (2 * r2 - 1); }
  476.  
  477.                         if (g2 < 0.5)
  478.                         {
  479.                             green = 2 * g1 * g2 + Math.Pow(g1, 2) * (1 - 2 * g2);
  480.                         }
  481.                         else { green = 2 * g1 * (1 - g2) + Math.Sqrt(g1) * (2 * g2 - 1); }
  482.  
  483.                         if (b2 < 0.5)
  484.                         {
  485.                             blue = 2 * b1 * b2 + Math.Pow(b1, 2) * (1 - 2 * b2);
  486.                         }
  487.                         else { blue = 2 * b1 * (1 - b2) + Math.Sqrt(b1) * (2 * b2 - 1); }
  488.  
  489.                         red = red * 255.0;
  490.                         green = green * 255.0;
  491.                         blue = blue * 255.0;
  492.  
  493.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  494.  
  495.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  496.                     }
  497.                 }
  498.                 pictureBox3.Image = temp3;
  499.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  500.             }
  501.             else
  502.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  503.         }
  504.  
  505.         // ROZCIENCZENIE
  506.         private void colorDodgeToolStripMenuItem_Click(object sender, EventArgs e)
  507.         {
  508.             if (check == true && check2 == true)
  509.             {
  510.                 bm = new Bitmap(pictureBox1.Image);
  511.                 bm2 = new Bitmap(pictureBox2.Image);
  512.                 temp = bm;
  513.                 temp2 = bm2;
  514.                 temp3 = new Bitmap(600, 400);
  515.                 double red, green, blue;
  516.                 for (int i = 0; i < temp.Width; i++)
  517.                 {
  518.                     for (int j = 0; j < temp.Height; j++)
  519.                     {
  520.                         SetRGB(temp, temp2, i, j);
  521.  
  522.                         red = r1 / (1 - r2);
  523.                         green = g1 / (1 - g2);
  524.                         blue = b1 / (1 - b2);
  525.  
  526.                         if (red > 1) red = 1;
  527.                         if (green > 1) green = 1;
  528.                         if (blue > 1) blue = 1;
  529.  
  530.                         red = red * 255.0;
  531.                         green = green * 255.0;
  532.                         blue = blue * 255.0;
  533.  
  534.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  535.  
  536.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  537.                     }
  538.                 }
  539.                 pictureBox3.Image = temp3;
  540.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  541.             }
  542.             else
  543.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  544.         }
  545.  
  546.         // WYPALANIE
  547.         private void colorBurnToolStripMenuItem_Click(object sender, EventArgs e)
  548.         {
  549.             if (check == true && check2 == true)
  550.             {
  551.                 bm = new Bitmap(pictureBox1.Image);
  552.                 bm2 = new Bitmap(pictureBox2.Image);
  553.                 temp = bm;
  554.                 temp2 = bm2;
  555.                 temp3 = new Bitmap(600, 400);
  556.                 double red, green, blue;
  557.                 for (int i = 0; i < temp.Width; i++)
  558.                 {
  559.                     for (int j = 0; j < temp.Height; j++)
  560.                     {
  561.                         SetRGB(temp, temp2, i, j);
  562.  
  563.                         if (r2 == 0) r2 = 0.01;
  564.                         if (g2 == 0) g2 = 0.01;
  565.                         if (b2 == 0) b2 = 0.01;
  566.  
  567.                         red = 1 - (1 - r1) / r2;
  568.                         green = 1 - (1 - g1) / g2;
  569.                         blue = 1 - (1 - b1) / b2;
  570.  
  571.                         if (red < 0) red = 0;
  572.                         if (green < 0) green = 0;
  573.                         if (blue < 0) blue = 0;
  574.  
  575.                         red = red * 255.0;
  576.                         green = green * 255.0;
  577.                         blue = blue * 255.0;
  578.  
  579.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  580.  
  581.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  582.                     }
  583.                 }
  584.                 pictureBox3.Image = temp3;
  585.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  586.             }
  587.             else
  588.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  589.         }
  590.  
  591.         //REFLECT
  592.         private void reflectToolStripMenuItem_Click(object sender, EventArgs e)
  593.         {
  594.             if (check == true && check2 == true)
  595.             {
  596.                 bm = new Bitmap(pictureBox1.Image);
  597.                 bm2 = new Bitmap(pictureBox2.Image);
  598.                 temp = bm;
  599.                 temp2 = bm2;
  600.                 temp3 = new Bitmap(600, 400);
  601.                 double red, green, blue;
  602.                 for (int i = 0; i < temp.Width; i++)
  603.                 {
  604.                     for (int j = 0; j < temp.Height; j++)
  605.                     {
  606.                         SetRGB(temp, temp2, i, j);
  607.  
  608.                         red = Math.Pow(r1, 2) / (1 - r2);
  609.                         green = Math.Pow(g1, 2) / (1 - g2);
  610.                         blue = Math.Pow(b1, 2) / (1 - b2);
  611.  
  612.                         if (red > 1) red = 1;
  613.                         if (green > 1) green = 1;
  614.                         if (blue > 1) blue = 1;
  615.  
  616.                         red = red * 255.0;
  617.                         green = green * 255.0;
  618.                         blue = blue * 255.0;
  619.  
  620.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  621.  
  622.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  623.                     }
  624.                 }
  625.                 pictureBox3.Image = temp3;
  626.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  627.             }
  628.             else
  629.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  630.         }
  631.  
  632.         // PRZEZROCZYSTOSC
  633.         private void transparencyToolStripMenuItem_Click(object sender, EventArgs e)
  634.         {
  635.             if (check == true && check2 == true)
  636.             {
  637.                 bm = new Bitmap(pictureBox1.Image);
  638.                 bm2 = new Bitmap(pictureBox2.Image);
  639.                 temp = bm;
  640.                 temp2 = bm2;
  641.                 temp3 = new Bitmap(600, 400);
  642.                 double red, green, blue, alpha;
  643.                 for (int i = 0; i < temp.Width; i++)
  644.                 {
  645.                     for (int j = 0; j < temp.Height; j++)
  646.                     {
  647.                         SetRGB(temp, temp2, i, j);
  648.                         alpha = double.Parse(textBox1.Text);
  649.  
  650.                         red = (1 - alpha) * r2 + alpha * r1;
  651.                         green = (1 - alpha) * g2 + alpha * g1;
  652.                         blue = (1 - alpha) * b2 + alpha * b1;
  653.  
  654.                         if (red > 1) red = 1;
  655.                         if (green > 1) green = 1;
  656.                         if (blue > 1) blue = 1;
  657.  
  658.                         red = red * 255.0;
  659.                         green = green * 255.0;
  660.                         blue = blue * 255.0;
  661.  
  662.                         //Console.WriteLine("czerwony to {0}, zielony to {1}, niebieski to {2} ", red, green, blue);
  663.  
  664.                         temp3.SetPixel(i, j, Color.FromArgb((int)red, (int)green, (int)blue));
  665.                     }
  666.                 }
  667.                 pictureBox3.Image = temp3;
  668.                 pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
  669.             }
  670.             else
  671.                 System.Windows.Forms.MessageBox.Show("Nie załadowano zdjęcia.");
  672.         }
  673.  
  674.         // Suwak do janości
  675.         private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
  676.         {
  677.             label1.Text = hScrollBar1.Value.ToString();
  678.             brightness = hScrollBar1.Value;
  679.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement