write an code for console C# application that take as argument file path for image file…
- User
write an code for console C# application that take as argument file path for image file and load image. Based on loaded image create BMP image N times bigger with where each pixel from original picture is drawn as circle with radious N/2 pixels at location XN and YN where X is vertical pixel place from orginal picture and Y is horizontal pixel place from orginal picture. Save created image to new file.
- Assistant
Sure! Here's an example of how you can achieve that:
using System; using System.Drawing; using System.Drawing.Imaging; namespace ConsoleApp { class Program { static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Please provide the path to the image file as an argument."); return; } string imagePath = args[0]; using (var originalImage = new Bitmap(imagePath)) { int resizeFactor = 2; // Change this to desired resize factor int newWidth = originalImage.Width * resizeFactor; int newHeight = originalImage.Height * resizeFactor; var resizedImage = new Bitmap(newWidth, newHeight); using (var graphics = Graphics.FromImage(resizedImage)) { graphics.Clear(Color.White); for (int x = 0; x < originalImage.Width; x++) { for (int y = 0; y < originalImage.Height; y++) { Color pixelColor = originalImage.GetPixel(x, y); int newX = x * resizeFactor; int newY = y * resizeFactor; using (var brush = new SolidBrush(pixelColor)) { graphics.FillEllipse(brush, newX, newY, resizeFactor, resizeFactor); } } } } string outputImagePath = "output.bmp"; // Path of the output image resizedImage.Save(outputImagePath, ImageFormat.Bmp); Console.WriteLine("Resized image saved successfully to " + outputImagePath); } } } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.