如何在使用此加密代码的表单中添加图像链接?
怎么能认为这个代码在这里做转换的图像?如何从文件夹中定义的图像是在有bin文件夹“CH/1.JPG”任何一个可以帮助我解决这个问题? 我有20张图片和20种形式...如何在使用此加密代码的表单中添加图像链接?
private static byte[] ConvertImageToByteArray(System.Drawing.Image imageToConvert,
ImageFormat formatOfImage)
{
byte[] Ret;
try
{
using (MemoryStream ms = new MemoryStream())
{
imageToConvert.Save(ms,formatOfImage);
Ret = ms.ToArray();
}
}
catch (Exception) { throw;}
return Ret;
}
//When you are ready to convert the byte array back
//to an image, you can include the following code
//in your method.
System.Drawing.Image newImage;
using (MemoryStream ms = new MemoryStream(myByteArray,0,myByteArray.Length))
{
ms.Write(myByteArray,0,myByteArray.Length);
newImage = Image.FromStream(ms,true);
// work with image here.
// You'll need to keep the MemoryStream open for
// as long as you want to work with your new image.
}
如果你想从一个文件中加载图像,只需使用:
Image img = Image.FromFile("C:\mypath\myimage.png"); //load the file as image
pictureBox1.Image = img; //use the image how you like
你并不需要经过转换的过程图像信息转化为Byte[]
,除非你的意思是存储在某个地方,比如在数据库中。
我有大约400个图像和400所形成这么多的图片,我可以以某种形式与不同的按钮绑定400倍的图像? – BuschJoe 2014-09-30 11:32:42
当然。你为什么想要?为什么这些400张图片没有资源编译到您的项目中? – DonBoitnott 2014-09-30 11:37:39
如果我将所有资源添加到资源中,应用程序崩溃...! – BuschJoe 2014-10-01 06:44:54
我很抱歉,但我不明白的问题,所有..不知道该问什么.. – 2014-09-30 07:38:43
我问我怎么可以添加在这个图像,我怎么能在形式上显示图像? – BuschJoe 2014-09-30 07:41:09