在图片控件或静态控件中加载图像 [英] Loading a image in picture control or static control

查看:91
本文介绍了在图片控件或静态控件中加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我想通过使用图片控件或静态的路径加载任何类型(即.png,.bmp,.jpg或任何类型)控制



提前感谢您的帮助!

Hello

I want load any type of (i.e, .png,.bmp,.jpg or any) by using a path into a picture control or static control

Thanks in advance for any help!

推荐答案

您好,



如果您正在使用C#Winform应用程序,那么您所寻找的是已知的

PictureBox控件 [ ^ ]

图片框需要一个Image的instane,可以使用以下代码创建:



Hi,

If you are working on C# Winform application, then what you are looking for is known
PictureBox control[^]
Picture box needs an instane of Image which can be created using following code:

var MyImage = new Bitmap(fileToDisplay);   
pictureBox1.Image = (Image) MyImage ;





在WPF中你可以使用图像控制 [ ^ ]

您可以使用如下图像控件:



选项1:





In WPF you can use Image control[^]
You can use Image control as below:

Option 1:

<image width="200">
Source="C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg"/></image>







选项2






Option 2

<image width="200">
  <image.source>
    <bitmapimage decodepixelwidth="200">
     UriSource="C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg" />
  </bitmapimage></image.source>
</image>





谢谢

Ankush Bansal



Thanks
Ankush Bansal


有看看Liviu Birjegas的文章:缩略图查看器和使用GDI +的图像处理和MFC [ ^ ]



祝你好运

Espen Harlinn
Have a look at Liviu Birjegas article: Thumbnails viewer and image processing using GDI+ and MFC[^]

Best regards
Espen Harlinn


这篇关于在图片控件或静态控件中加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆