Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace grafika1
- {
- public partial class Form1 : Form
- {
- Bitmap pomoc;
- Bitmap obraz, kopia;
- public Form1()
- {
- InitializeComponent();
- }
- private void Negatyw()
- {
- obraz = new Bitmap(pictureBox1.Image);
- kopia = new Bitmap(obraz.Width, obraz.Height);
- pictureBox1.Image = obraz;
- pomoc = new Bitmap(obraz.Width, obraz.Height);
- Color punkt;
- for (int i = 0; i < obraz.Width; i++)
- {
- for (int j = 0; j < obraz.Height; j++)
- {
- punkt = obraz.GetPixel(i, j);
- pomoc.SetPixel(i, j, Color.FromArgb(255 - punkt.R, 255 - punkt.G, 255 - punkt.B));
- }
- }
- pictureBox2.Image = pomoc;
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Negatyw();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- openFileDialog1.ShowDialog();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- convertToGrayScale();
- }
- private void convertToGrayScale()
- {
- obraz = new Bitmap(pictureBox1.Image);
- kopia = new Bitmap(obraz.Width, obraz.Height);
- pictureBox1.Image = obraz;
- pomoc = new Bitmap(obraz.Width, obraz.Height);
- Color punkt;
- for (int i = 0; i < obraz.Width; i++)
- {
- for (int j = 0; j < obraz.Height; j++)
- {
- punkt = obraz.GetPixel(i, j);
- pomoc.SetPixel(i, j, Color.FromArgb((punkt.R+punkt.G+punkt.B)/3,(punkt.R+punkt.G+punkt.B)/3,(punkt.R+punkt.G+punkt.B)/3));
- }
- }
- pictureBox2.Image = pomoc;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement