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; using System.IO; namespace WindowsFormsApp3 { public partial class Form1 : Form { Color color = Color.Black; public Form1() { InitializeComponent(); } private void New_Click(object sender, EventArgs e) { Bitmap pic = new Bitmap(100, 100); Graphics bg = Graphics.FromImage(pic); //bg.DrawLine(new Pen(Color.Red, 2), 10, 10, 30, 30); bg.FillRectangle(Brushes.White, 0, 0, 100, 100); pictureBox1.Image = pic; } private void pictureBox1_Click(object sender, EventArgs e) { MouseEventArgs me = (MouseEventArgs)e; Graphics bg = pictureBox1.CreateGraphics(); float velkost = trackBar1.Value; bg.FillEllipse(new SolidBrush(color), me.X - velkost/2, me.Y - velkost / 2, velkost, velkost); } private void trackBar1_Scroll(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { DialogResult result = colorDialog1.ShowDialog(); if (result == DialogResult.OK) { color = colorDialog1.Color; } } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { MouseEventArgs me = (MouseEventArgs)e; if (me.Button == MouseButtons.Left) { Graphics bg = pictureBox1.CreateGraphics(); float velkost = trackBar1.Value; bg.FillEllipse(new SolidBrush(color), me.X - velkost / 2, me.Y - velkost / 2, velkost, velkost); } } private void button2_Click(object sender, EventArgs e) { string fn; saveFileDialog1.Filter = "BitMap|*.bmp"; saveFileDialog1.Title = "Uložit obrázek jako ..."; DialogResult result = saveFileDialog1.ShowDialog(); if (result == DialogResult.OK) { fn = saveFileDialog1.FileName; } else return; BinaryWriter bw; //create the file try { bw = new BinaryWriter(new FileStream(fn, FileMode.Create)); } catch (IOException ex) { MessageBox.Show("Selhalo to sorry jako " + ex.Message); return; } bw.Write("BM"); bw.Write((Int32)40054); bw.Write((Int32)0); bw.Write((Int32)54);//todo bw.Write((Int32)40); bw.Write((Int32)100); bw.Write((Int32)100); bw.Write((Int16)1); bw.Write((Int16)32); bw.Write((Int32)0); //compress bw.Write((Int32)40000); bw.Write((Int32)10000); bw.Write((Int32)10000); bw.Write((Int32)0); bw.Write((Int32)0); Bitmap b = (Bitmap)pictureBox1.Image; for (int i = 0; i < 100; i ++) { for (int j = 0; j < 100; j++) { bw.Write(/* TODO */); } } bw.Close(); } } }