在c#中使用Windows控制台应用程序显示图像 [英] display image using windows console application in c#
本文介绍了在c#中使用Windows控制台应用程序显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮帮我,如何在c#中使用Windows控制台应用程序显示图像。
是否可能?
解决方案
您无法在 控制台窗口中显示位图/图像 :控制台仅限文本。这里有一个很好的总结,你可以和控制台窗口无法做到:[ ^ ]。
你可以这样做:
0.参考System.Drawing在控制台应用程序中,创建图形,并将它们保存到文件,或打开grahics文件并修改其位并保存,等等。
1.显示控制台窗口中的Unicode扩展字符,其中一些是图形类型
2.让自己疯狂尝试制作角色艺术
3.在Windows窗体应用程序中或与Windows窗体应用程序一起显示控制台窗口,并使用WinForm应用程序以通常的方式显示位图/图像。
我在2009年使用StackOverFlow上的这篇文章中的代码进行了探索:[ ^ ]。
我问了一个基于我的经验的问题适应该代码:[ ^ ]。
原来是棘手的东西,让Window和Console一起工作,定位正确等等
你可以创建一个窗体并将其边框设置为无添加图片框设置其底座填充并设置其图像然后显示表格
这里是代码:
var f = < span class =code-keyword> new Form();
f.FormBorderStyle = FormBorderStyle.None;
f.Controls.Add( new PictureBox(){ImageLocation = @ Path // To // Image,Dock = DockStyle.Fill});
f.Show();
希望它适合你。
编辑:
不要使用命名空间System.Windows.Forms使用 System.Windows.Forms;
hi,
Please help me out, how to display image using windows console application in c#.
is it possible?
解决方案
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.
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:
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.Formsusing System.Windows.Forms;
这篇关于在c#中使用Windows控制台应用程序显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文