fork download
  1.  
  2. using System.Drawing;
  3. using System.Drawing.Imaging;
  4. using System.IO;
  5. namespace png32to24
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. if (args.Length < 1 || !File.Exists(args[0])) return;
  12. Bitmap png, png24;
  13. try { using (FileStream fs = new FileStream(args[0], FileMode.Open, FileAccess.Read)) { png = (Bitmap)Image.FromStream(fs); } }
  14. catch { return; }
  15. if (png == null) return;
  16. if (Image.GetPixelFormatSize(png.PixelFormat) == 24) return;//24bpp
  17. png24 = new Bitmap(png.Width, png.Height, PixelFormat.Format24bppRgb);
  18. Graphics g = Graphics.FromImage(png24);
  19. g.DrawImage(png, 0, 0, png.Width, png.Height);
  20. g.Dispose();
  21. string filename = Path.GetDirectoryName(args[0]) + "\\" +Path.GetFileNameWithoutExtension(args[0]) + "_png24.png";
  22. png24.Save(filename);
  23. }
  24. }
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.100

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Package source with Name: nuget.org disabled successfully.
Package source with Name: local added successfully.
/home/JBeA7c/Project/Program.cs(12,9): error CS1069: The type name 'Bitmap' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly. [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(13,111): error CS0103: The name 'Image' does not exist in the current context [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(13,104): error CS1069: The type name 'Bitmap' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly. [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(16,13): error CS0103: The name 'Image' does not exist in the current context [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(17,21): error CS1069: The type name 'Bitmap' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly. [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(17,51): error CS0103: The name 'PixelFormat' does not exist in the current context [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(18,9): error CS1069: The type name 'Graphics' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly. [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(18,22): error CS0103: The name 'Graphics' does not exist in the current context [/home/JBeA7c/Project/Project.csproj]



/home/JBeA7c/Project/Program.cs(12,9): error CS1069: The type name 'Bitmap' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly. [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(13,111): error CS0103: The name 'Image' does not exist in the current context [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(13,104): error CS1069: The type name 'Bitmap' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly. [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(16,13): error CS0103: The name 'Image' does not exist in the current context [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(17,21): error CS1069: The type name 'Bitmap' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly. [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(17,51): error CS0103: The name 'PixelFormat' does not exist in the current context [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(18,9): error CS1069: The type name 'Graphics' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly. [/home/JBeA7c/Project/Project.csproj]
/home/JBeA7c/Project/Program.cs(18,22): error CS0103: The name 'Graphics' does not exist in the current context [/home/JBeA7c/Project/Project.csproj]
    0 Warning(s)
    8 Error(s)

Time Elapsed 00:00:04.66
stdout
Standard output is empty