You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.8 KiB
106 lines
2.8 KiB
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 zz_winsign
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void cmbPenWidth_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
//sign1.PenWidth = Convert.ToInt32(cmbPenWidth.Text);
|
|
}
|
|
|
|
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
sign1.PenWidth = Convert.ToInt32(listBox1.Text);
|
|
}
|
|
|
|
private void colorUIControl1_ColorSelected(object sender, EventArgs e)
|
|
{
|
|
sign1.PenColor = colorUIControl1.SelectedColor;
|
|
}
|
|
|
|
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
saveFileDialog1.Filter = "JPG-Dateien | *.jpg";
|
|
saveFileDialog1.DefaultExt = "jpg";
|
|
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
|
|
{
|
|
if (System.IO.File.Exists(saveFileDialog1.FileName)) { System.IO.File.Delete(saveFileDialog1.FileName); }
|
|
Bitmap newSign = AdjustBrightness(sign1.SignatureBitmap, Convert.ToInt32(listBox2.Text));
|
|
|
|
newSign.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
|
|
|
|
//sign1.ClearSignature();
|
|
|
|
}
|
|
}
|
|
|
|
public Bitmap AdjustBrightness(Bitmap inputB, int brightnessvalue)
|
|
{
|
|
Bitmap bmap = inputB;
|
|
Color c;
|
|
|
|
|
|
for (int i = 0; i < bmap.Width; i++)
|
|
{
|
|
for (int j = 0; j < bmap.Height; j++)
|
|
{
|
|
|
|
c = bmap.GetPixel(i, j);
|
|
|
|
int cR = c.R + brightnessvalue;
|
|
int cG = c.G + brightnessvalue;
|
|
int cB = c.B + brightnessvalue;
|
|
|
|
|
|
if (cR < 0) cR = 1;
|
|
if (cR > 255) cR = 255;
|
|
|
|
|
|
if (cG < 0) cG = 1;
|
|
if (cG > 255) cG = 255;
|
|
if (cB < 0) cB = 1;
|
|
if (cB > 255) cB = 255;
|
|
|
|
|
|
bmap.SetPixel(i, j, Color.FromArgb(cR, cG, cB));
|
|
}
|
|
}
|
|
|
|
return bmap;
|
|
}
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
{
|
|
colorUIControl1.SelectedColor = Color.Black;
|
|
listBox1.Text = "6";
|
|
listBox2.Text = "100";
|
|
sign1.PenColor=Color.Black;
|
|
sign1.PenWidth = 4;
|
|
}
|
|
|
|
private void btnDeleteImage_Click(object sender, EventArgs e)
|
|
{
|
|
sign1.ClearSignature();
|
|
}
|
|
}
|
|
}
|