import/export files with a push of a button
* arbitrary files can be loaded and saved (presumably after modification)
This commit is contained in:
parent
1ccbd93835
commit
24f9c37af3
|
@ -30,9 +30,9 @@
|
|||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.textBox1putm = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.textBox2 = new System.Windows.Forms.TextBox();
|
||||
this.textBox2getm = new System.Windows.Forms.TextBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
|
@ -48,6 +48,9 @@
|
|||
this.textBox5width = new System.Windows.Forms.TextBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.button6 = new System.Windows.Forms.Button();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.textBox6capacity = new System.Windows.Forms.TextBox();
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
@ -64,13 +67,13 @@
|
|||
//
|
||||
this.openFileDialog1.FileName = "openFileDialog1";
|
||||
//
|
||||
// textBox1
|
||||
// textBox1putm
|
||||
//
|
||||
this.textBox1.Location = new System.Drawing.Point(22, 94);
|
||||
this.textBox1.Multiline = true;
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(342, 66);
|
||||
this.textBox1.TabIndex = 1;
|
||||
this.textBox1putm.Location = new System.Drawing.Point(22, 94);
|
||||
this.textBox1putm.Multiline = true;
|
||||
this.textBox1putm.Name = "textBox1putm";
|
||||
this.textBox1putm.Size = new System.Drawing.Size(342, 66);
|
||||
this.textBox1putm.TabIndex = 1;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
|
@ -81,13 +84,13 @@
|
|||
this.label2.TabIndex = 2;
|
||||
this.label2.Text = "get the secret message";
|
||||
//
|
||||
// textBox2
|
||||
// textBox2getm
|
||||
//
|
||||
this.textBox2.Location = new System.Drawing.Point(22, 226);
|
||||
this.textBox2.Multiline = true;
|
||||
this.textBox2.Name = "textBox2";
|
||||
this.textBox2.Size = new System.Drawing.Size(342, 59);
|
||||
this.textBox2.TabIndex = 3;
|
||||
this.textBox2getm.Location = new System.Drawing.Point(22, 226);
|
||||
this.textBox2getm.Multiline = true;
|
||||
this.textBox2getm.Name = "textBox2getm";
|
||||
this.textBox2getm.Size = new System.Drawing.Size(342, 59);
|
||||
this.textBox2getm.TabIndex = 3;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
|
@ -151,6 +154,7 @@
|
|||
this.button3.TabIndex = 12;
|
||||
this.button3.Text = "export";
|
||||
this.button3.UseVisualStyleBackColor = true;
|
||||
this.button3.Click += new System.EventHandler(this.button3_Click);
|
||||
//
|
||||
// button4
|
||||
//
|
||||
|
@ -225,11 +229,40 @@
|
|||
this.button6.UseVisualStyleBackColor = true;
|
||||
this.button6.Click += new System.EventHandler(this.button6_Click);
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(541, 512);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(47, 13);
|
||||
this.label7.TabIndex = 21;
|
||||
this.label7.Text = "capacity";
|
||||
//
|
||||
// textBox6capacity
|
||||
//
|
||||
this.textBox6capacity.Location = new System.Drawing.Point(594, 509);
|
||||
this.textBox6capacity.Name = "textBox6capacity";
|
||||
this.textBox6capacity.ReadOnly = true;
|
||||
this.textBox6capacity.Size = new System.Drawing.Size(76, 20);
|
||||
this.textBox6capacity.TabIndex = 22;
|
||||
//
|
||||
// label8
|
||||
//
|
||||
this.label8.AutoSize = true;
|
||||
this.label8.Location = new System.Drawing.Point(676, 512);
|
||||
this.label8.Name = "label8";
|
||||
this.label8.Size = new System.Drawing.Size(32, 13);
|
||||
this.label8.TabIndex = 23;
|
||||
this.label8.Text = "bytes";
|
||||
//
|
||||
// main_form
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1041, 584);
|
||||
this.Controls.Add(this.label8);
|
||||
this.Controls.Add(this.textBox6capacity);
|
||||
this.Controls.Add(this.label7);
|
||||
this.Controls.Add(this.button6);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.textBox5width);
|
||||
|
@ -245,9 +278,9 @@
|
|||
this.Controls.Add(this.pictureBox1);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.textBox2);
|
||||
this.Controls.Add(this.textBox2getm);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.textBox1);
|
||||
this.Controls.Add(this.textBox1putm);
|
||||
this.Controls.Add(this.label1);
|
||||
this.DoubleBuffered = true;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
|
@ -265,9 +298,9 @@
|
|||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.TextBox textBox1putm;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox textBox2;
|
||||
private System.Windows.Forms.TextBox textBox2getm;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
|
@ -283,6 +316,9 @@
|
|||
private System.Windows.Forms.TextBox textBox5width;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Button button6;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.TextBox textBox6capacity;
|
||||
private System.Windows.Forms.Label label8;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
56
main_form.cs
56
main_form.cs
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -17,12 +19,24 @@ namespace KRY_0x02
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
public int im_h = 0;
|
||||
public int im_w = 0;
|
||||
|
||||
public string getpath(TextBox t)
|
||||
{
|
||||
string path = t.Text;
|
||||
return path;
|
||||
}
|
||||
|
||||
public int get_capacity(int a, int b)
|
||||
{
|
||||
int c = 0;
|
||||
a = im_h;
|
||||
b = im_w;
|
||||
c = ((a * b) / 8) - 8;
|
||||
return c;
|
||||
}
|
||||
|
||||
//Bitmap my_bitmap = new Bitmap(getpath(textBox1));
|
||||
Color pixel;
|
||||
int int_value;
|
||||
|
@ -69,8 +83,11 @@ namespace KRY_0x02
|
|||
pictureBox1.Image = new Bitmap(dlg.FileName);
|
||||
pictureBox1.SizeMode = PictureBoxSizeMode.Normal;
|
||||
textBox3.Text = dlg.FileName;
|
||||
textBox4height.Text = pictureBox1.Image.Height.ToString();
|
||||
textBox5width.Text = pictureBox1.Image.Width.ToString();
|
||||
im_h = pictureBox1.Image.Height;
|
||||
im_w = pictureBox1.Image.Width;
|
||||
textBox4height.Text = im_h.ToString();
|
||||
textBox5width.Text = im_w.ToString();
|
||||
textBox6capacity.Text = get_capacity(im_h,im_w).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,8 +101,11 @@ namespace KRY_0x02
|
|||
label5pathtopic.Text = $"Security: Actual actual reality: nobody cares about his secrets."
|
||||
+ " (Also, I would be hard-pressed to find that wrench for $5.)";
|
||||
textBox3.Text = filename + "\t\t by randall ... https://xkcd.com/538";
|
||||
textBox4height.Text = pictureBox1.Image.Height.ToString();
|
||||
textBox5width.Text = pictureBox1.Image.Width.ToString();
|
||||
im_h = pictureBox1.Image.Height;
|
||||
im_w = pictureBox1.Image.Width;
|
||||
textBox4height.Text = im_h.ToString();
|
||||
textBox5width.Text = im_w.ToString();
|
||||
textBox6capacity.Text = Convert.ToString(get_capacity(im_h, im_w));
|
||||
}
|
||||
|
||||
private void button6_Click(object sender, EventArgs e)
|
||||
|
@ -96,6 +116,34 @@ namespace KRY_0x02
|
|||
textBox3.Text = "";
|
||||
textBox4height.Text = "";
|
||||
textBox5width.Text = "";
|
||||
textBox6capacity.Text = "";
|
||||
im_h = 0;
|
||||
im_w = 0;
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (pictureBox1.Image == null)
|
||||
{
|
||||
MessageBox.Show("you've nothing to export, boi");
|
||||
return;
|
||||
}
|
||||
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
|
||||
saveFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
||||
saveFileDialog1.Title = "export your neatly stego-ed pic";
|
||||
saveFileDialog1.CheckFileExists = false;
|
||||
saveFileDialog1.CheckPathExists = false;
|
||||
saveFileDialog1.DefaultExt = "";
|
||||
saveFileDialog1.Filter = "png (*.png)|*.png|any file you wish (*.*)|*.*";
|
||||
saveFileDialog1.FilterIndex = 2;
|
||||
saveFileDialog1.RestoreDirectory = true;
|
||||
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Get file name.
|
||||
string name = saveFileDialog1.FileName;
|
||||
pictureBox1.Image.Save($"{name}",ImageFormat.MemoryBmp);
|
||||
MessageBox.Show($"saved to {name}","gj, file saved!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue