我想从控制台应用程序中显示一个图像,并且我已编写代码来执行此操作。但是当它显示图像时,它会显示一个奇怪的Form
框。如果我保存图像并正常打开它,它会显示图像。
代码:
Bitmap bmpScreenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(bmpScreenCapture);
g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0, 0,
bmpScreenCapture.Size,
CopyPixelOperation.SourceCopy);
bmpScreenCapture.Save("potato.png", ImageFormat.Png);
Form imageForm = new Form();
//imageForm.FormBorderStyle = FormBorderStyle.None;
imageForm.Controls.Add(new PictureBox() { Image = bmpScreenCapture, Visible = true });
imageForm.Show();
答案 0 :(得分:0)
这是因为您看到了表单边框。你走在正确的轨道上:
imageForm.FormBorderStyle = FormBorderStyle.None;
但是,您需要适当调整窗口大小。但你甚至不需要窗户。致电后
bmpScreenCapture.Save("potato.png", ImageFormat.Png);
只需做System.Diagnostics.Process.Start(“Potato.png”);它将在默认程序中打开图像。
答案 1 :(得分:0)
from os import listdir,environ
from sys import argv
from os.path import isfile,join
import os
# Here I convert the argument you get to an integer
size_limit = int(argv[1])
my_path = "./"
onlyfiles = [f for f in listdir(my_path) if isfile(join(my_path, f))]
sizes = []
size_dir = {}
print size_limit
for item in onlyfiles:
print type(os.path.getsize(my_path+item))
if os.path.getsize(my_path+item) < size_limit:
size_dir[item] = os.path.getsize(my_path+item)
print(size_dir)