Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,

Please help me out, how to display image using windows console application in c#.

is it possible?
Posted
Updated 20-Sep-21 5:57am

You cannot display a bitmap/image in a Console Window: the Console is Text only. Good summary here of what you can, and can't do with a Console Window: [^].

You can do this:

0. reference System.Drawing in a Console app, and create graphics, and save them to a file, or open a grahics file and modify its bits and save it, etc.

1. display Unicode extended characters in the Console Window, some of which are kind-of graphics

2. drive yourself crazy trying to make art of characters

3. display a Console Window in, or along with, a Windows Forms application, and use the WinForm app to display the bitmap/image in the usual way.

I explored this in 2009, using code on this post on StackOverFlow: [^].

And I asked a question based on my experience adapting that code: [^].

Turned out to be tricky stuff, getting the Window and Console working together, positioned correctly, etc.
 
Share this answer
 
v2
Comments
Richard Deeming 21-Sep-21 4:28am    
As the plagiarist in solution 3 has dragged this back into the "active" list, you might be interested to know that you can draw images in a console window now. :)

Spectre.Console - Canvas Image[^]
BillWoodruff 21-Sep-21 4:36am    
Thanks ! "ImageSharp superpowers" ... sounds like a must-have :)

I look forward to exploring what that library provides. If I ever start drawing in a Console window, I hope someone has the kindness to kill me.

Well you can create a windows form and set its border to none add a picture box set its dock to fill and set its image then show the form

here is the code:
C#
var f = new Form();
f.FormBorderStyle = FormBorderStyle.None;
 f.Controls.Add(new PictureBox() { ImageLocation = @"Path//To//Image",Dock = DockStyle.Fill});
f.Show();

Hope it works for you.

EDIT:
dont for get to use the namespace System.Windows.Forms
C#
using System.Windows.Forms;
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900