Add project files.

This commit is contained in:
2025-07-10 08:05:27 -05:00
parent fad1a3ce2f
commit c3e1f5a917
12 changed files with 662 additions and 0 deletions

36
Program.cs Normal file
View File

@@ -0,0 +1,36 @@
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace CopyAndEncodeImage {
internal static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(params string[] args) {
if (args.Count() > 0) {
// If there are command line arguments, pass them to the form
if (Path.GetExtension(args[0].ToLower()) != ".png") {
MessageBox.Show("Please provide a valid PNG file as the first argument.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var bytes = File.ReadAllBytes(args[0]);
string base64String = Convert.ToBase64String(bytes);
//string base64String = new string(base64Chars);
string output = $"data:image/png;base64,{base64String}";
Clipboard.SetText(output);
} else {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
}