通过图像列表显示时图像质量下降

时间:2015-06-29 07:54:37

标签: c# image winforms picturebox imagelist

我想使用ImageList使用计时器在循环中显示图像。它工作正常,但在PictureBox生动地显示的同一图像在同一PictureBox应该显示图像列表中的图片时会失去其质量。

直接在PictureBox显示的图片:

enter image description here

PictureBox中显示的图片,但是ImageListpictureBox1.Image = imglist.Images[0];):

enter image description here

我的图片是128x128 png,这是我的PictureBoxImageList的设计师代码:

// 
// pictureBox1
// 
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(378, 78);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(128, 128);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;

// 
// imglist
// 
this.imglist.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imglist.ImageStream")));
this.imglist.TransparentColor = System.Drawing.Color.Transparent;
this.imglist.Images.SetKeyName(0, "1423093311_supportfemale-48.png");

enter image description here

1 个答案:

答案 0 :(得分:0)

使用 ImageList for PictureBox 显示图像有时会降低图像质量。

试试这个替代方案:

  1. 右键单击项目>选择属性>从左侧选项卡中选择资源>从水平菜单中选择图像>单击添加资源(从您的机器添加所需的图像)>保存 ...这会将图像添加到带有 imagename.extension

    的资源中
  2. 在 fromNameLoad(任何最先执行的加载方法)中,写入:
    图片 imagename1 = Properties.Resources.imagename;

  3. 与图片框一起使用: PictureboxVar.BackgroundImage = imagename1;