Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.IO;
- namespace ImageProcessing
- {
- internal class Program
- {
- // Path to the input and output image files
- // The file should be located where the .exe application is
- public static string imagePath = "image.jpg";
- public static string newImagePath = "newImage.jpg";
- public static void Main(string[] args)
- {
- }
- public static void BrightenImage(Bitmap img)
- {
- }
- public static void DarkenImage(Bitmap img)
- {
- }
- public static void SwapColors(Bitmap img)
- {
- }
- // This method converts the RGB values entered by the user into a Color object.
- public static Color ConvertStringToColor(string rgb)
- {
- int r, g, b;
- try
- {
- string[] rgbComponents = rgb.Split(',');
- r = int.Parse(rgbComponents[0]);
- g = int.Parse(rgbComponents[1]);
- b = int.Parse(rgbComponents[2]);
- return Color.FromArgb(r, g, b);
- }
- catch (Exception e)
- {
- Console.WriteLine("Invalid color input. Setting default color (black).");
- return Color.Black;
- }
- }
- // This method prevents values from exceeding the 0-255 (RGB) range by clamping the variables.
- public static int ClampValue(int value)
- {
- if (value < 0) return 0;
- if (value > 255) return 255;
- return value;
- }
- // This method retrieves the image from the given path and displays a message if there's a problem.
- public static Bitmap LoadImage(string filePath)
- {
- if (File.Exists(filePath) == false) return null;
- try
- {
- Bitmap bitmap = new Bitmap(filePath);
- return bitmap;
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- return null;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement