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 WindowsFormsApplication19 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Bitmap vzor = (Bitmap)pictureBox1.Image; Bitmap kopie = new Bitmap(vzor.Width, vzor.Height); pictureBox2.Image = kopie; int[] zbytek = new int[vzor.Height]; int[] budouci_zbytek = new int[vzor.Height]; for (int x = 0; x < pictureBox1.Width; x++) { zbytek = budouci_zbytek; budouci_zbytek = new int[vzor.Height]; for (int y = 0; y < pictureBox1.Height; y++) { //int xx = pictureBox1.Width - 1 - x; int xx = x; if (2 * x < vzor.Width) xx = 2 * x; int yy = y; if (2 * y < vzor.Height) yy = 2 * y; xx = x + 20+(int)(20 * Math.Sin(y / 30.00)); yy = y + 20+(int)(20 * Math.Sin(x / 30.00)); Color c = vzor.GetPixel(xx, yy); int svetlost = (int)(c.R * 0.2989 + c.G * 0.5866 + c.B * (1 - 0.2989 - 0.5866)); svetlost += zbytek[y]; Color barva = c; /* if (svetlost >= trackBar1.Value) { barva = Color.White; svetlost = svetlost - trackBar1.Value; } else barva = Color.Black; kopie.SetPixel(x, y, barva); if (y+1 < vzor.Height) zbytek[y + 1] += svetlost / 4; if (y-1 >=0) budouci_zbytek[y - 1] += svetlost / 4; budouci_zbytek[y] += svetlost / 4; if (y + 1 < vzor.Height) budouci_zbytek[y + 1] += svetlost / 4; * */ //barva = Color.FromArgb(255, 255 - c.R, 255 - c.G, 255 - c.B); kopie.SetPixel(x, y, barva); } Refresh(); } } private void trackBar1_Scroll(object sender, EventArgs e) { button1_Click(null, null); } int LHRx = 0; int LHRy = 0; private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { LHRx = e.X; LHRy = e.Y; } private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { Bitmap vzor = (Bitmap)pictureBox1.Image; Bitmap kopie = new Bitmap(vzor.Width, vzor.Height); pictureBox2.Image = kopie; int PDRx = e.X; int PDRy = e.Y; Graphics g = Graphics.FromImage(kopie); Rectangle R = new Rectangle(LHRx,LHRy,(PDRx-LHRx),(PDRy-LHRy)); g.DrawImage( vzor.Clone(R,System.Drawing.Imaging.PixelFormat.DontCare), 100,100 ); } } } -------------------------------------------------------------------- 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 WindowsFormsApplication18 { public partial class Form1 : Form { Bitmap bmp; Graphics g; public Form1() { InitializeComponent(); bmp = new Bitmap(1000, 1000); g = Graphics.FromImage(bmp); pictureBox1.Image = bmp; } private void button1_Click_2(object sender, EventArgs e) { //Graphics g = CreateGraphics(); int sx = ClientRectangle.Width / 16; int sy = ClientRectangle.Height / 16; for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { int x = i * sx; int y = j * sy; Color barva = Color.FromArgb(255, j * 17, 17 * i, trackBar1.Value); Brush stetec = new SolidBrush(barva); g.FillRectangle(stetec, x, y, sx, sy); g.DrawRectangle(Pens.Black, x, y, sx, sy); } } Refresh(); } private void button1_Click(object sender, EventArgs e) { //Graphics g = CreateGraphics(); g.DrawLine(Pens.Blue, 0, 0, 500, 500); } private void button1_Click_1(object sender, EventArgs e) { Graphics g = CreateGraphics(); g.DrawLine(Pens.Blue, 0, 0, 100, 100); int minx = 0; int miny = 0; Pen pero = new Pen(Color.Red, 100); pero.StartCap = System.Drawing.Drawing2D.LineCap.Round; pero.EndCap = System.Drawing.Drawing2D.LineCap.Round; for (int fi = 0; fi < 4*360; fi++) { int x = 250 + (int)(200 * Math.Cos(3 * (double)fi / 3/360.00 * 2 * Math.PI)); int y = 250 + (int)(200 * Math.Sin(4 * (double)fi / 3 / 360.00 * 2 * Math.PI)); pero.Width = 5; //pero.Color = Color. //if (fi > 0) // g.DrawLine(pero, minx, miny, x, y); minx = x; miny = y; g.FillRectangle(Brushes.Yellow, x, y, 50, trackBar1.Value); g.DrawRectangle(Pens.Black, x, y, 50, 30); } } private void trackBar1_Scroll(object sender, EventArgs e) { button1_Click_2(null, null); } } }