C#中imageList动态添加图片问题

C#中imageList动态添加图片问题,第1张

不会将favicon.ico换成favicon.jpg或favicon.bmp啊…………

将其它PICBOX控件里的图片路径取出存入imageList即可。

msdn中的实例:

C# 复制代码

internal System.Windows.Forms.ImageList ImageList1

// Create an ImageList Object, populate it, and display

// the images it contains.

private void Button1_Click(System.Object sender,

System.EventArgs e)

{

// Construct the ImageList.

ImageList1 = new ImageList()

// Set the ImageSize property to a larger size

// (the default is 16 x 16).

ImageList1.ImageSize = new Size(112, 112)

// Add two images to the list.

ImageList1.Images.Add(

Image.FromFile("c:\\windows\\FeatherTexture.bmp"))

ImageList1.Images.Add(

Image.FromFile("C:\\windows\\Gone Fishing.bmp"))

// Get a Graphics object from the form's handle.

Graphics theGraphics = Graphics.FromHwnd(this.Handle)

// Loop through the images in the list, drawing each image.

for(int count = 0count <ImageList1.Images.Countcount++)

{

ImageList1.Draw(theGraphics, new Point(85, 85), count)

// Call Application.DoEvents to force a repaint of the form.

Application.DoEvents()

// Call the Sleep method to allow the user to see the image.

System.Threading.Thread.Sleep(1000)

}

}

明白吗?难道你会认为imageList.Images.Add()是把地址中的图片存放在imageList中???

增加:

ImageList imageList = new ImageList()

imageList.Images.Add(Image.FromFile(@"D:\我的文件\myrice\favicon.ico"))

imageList.Images.Add(Image.FromFile(@"D:\我的文件\myrice\favicon4.ico"))

imageList.Images.Add(Image.FromFile(@"D:\我的文件\myrice\favicon5.ico"))

读取一

this.lb = new GListBox()

lb.ImageList = imageList

读取二

imageList.Images[a],括号内为索引,表示你要取的序号,不得超过imageList.Images.count的数量,不然会报错。

为什么不去看msdn??

第一步,添加制作GIF的图片

第二步,点击图片复制Ctrl+C,粘贴Ctrl+V

第三步,再继续添加下一张图片,两张图片的帧大小一样,点击确定

第四步,可以编辑图片

第五步,最后就可以点击开始制作

第六步,可以查看制作效果

首先我们点击打开word,然后依次点击"插入"-"图片",然后将一张动态图片插入进去,但是此时我们会发现插入以后的图片是静态的,如下图;

为了恢复动态图原先的面貌,我们需要先打开PPT,也同样插入"图片",然后将刚才的gif图片插入进去;

接下来我们可以自由调整图片的大小,然后将该PPT文档保存到电脑桌面;

此时切换到word,在插入里选择"对象",如图;然后在对象对话框选择"由文件创建";

点击"浏览"找到我们刚才保存到桌面的ppt文档,此时双击刚刚插入的图片就可以播放动态图了...


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/bake/11874340.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存