【问题标题】:Image losing quality when displayed via imagelist通过图像列表显示时图像质量下降
【发布时间】:2015-06-29 07:54:37
【问题描述】:

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

直接在PictureBox中显示时的图像:

显示在PictureBox 中但通过ImageList (pictureBox1.Image = imglist.Images[0];) 显示的图像:

我的图片是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");

【问题讨论】:

  • 你试过this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;吗?
  • @Hughnited 是的,但我得到了相同的结果。
  • 看图片,好像不是质量下降,而是imageList在加边框……
  • @DominikB 是真的。但是为什么会出现呢?
  • 她的一个类似问题的链接:stackoverflow.com/questions/10372797/…

标签: c# image winforms picturebox imagelist


【解决方案1】:

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

试试这个替代方案:

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

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

  3. 与 PictureBox 一起使用: PictureboxVar.BackgroundImage = imagename1;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-03
    • 1970-01-01
    相关资源
    最近更新 更多