Created
July 3, 2025 08:09
-
-
Save PhoenixGameDevelopment/ad67433847e9b4060a40a345a648251b to your computer and use it in GitHub Desktop.
A Simple AI-Generated Program to display an image encoded into a Base64 string to the screen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Drawing; | |
using System.IO; | |
using System.Windows.Forms; | |
class ImageReceiver : Form | |
{ | |
PictureBox displayBox; | |
TextBox inputBox; | |
public ImageReceiver() | |
{ | |
Text = "Base64 Image Portal"; | |
ClientSize = new Size(400, 450); | |
// Image display area | |
displayBox = new PictureBox | |
{ | |
Size = new Size(320, 320), | |
Location = new Point(40, 20), | |
BorderStyle = BorderStyle.FixedSingle, | |
SizeMode = PictureBoxSizeMode.Zoom | |
}; | |
// Input area | |
inputBox = new TextBox | |
{ | |
Multiline = true, | |
Size = new Size(320, 50), | |
Location = new Point(40, 350) | |
}; | |
// Decode button | |
var decodeBtn = new Button | |
{ | |
Text = "Decode Image", | |
Location = new Point(140, 410) | |
}; | |
decodeBtn.Click += (s, e) => DecodeBase64Image(); | |
Controls.AddRange(new Control[]{ | |
displayBox, inputBox, decodeBtn | |
}); | |
} | |
void DecodeBase64Image() | |
{ | |
try | |
{ | |
byte[] bytes = Convert.FromBase64String(inputBox.Text); | |
using (var ms = new MemoryStream(bytes)) | |
{ | |
displayBox.Image = new Bitmap(ms); | |
} | |
} | |
catch (Exception ex) | |
{ | |
MessageBox.Show($"Decoding failed:\n{ex.Message}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment