相关疑难解决方法(0)

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

我想ImageList使用计时器循环显示图像。它工作正常,除了PictureBoxPictureBox它应该显示图像列表中的图片时,在a上生动显示的相同图像会失去其质量。

直接显示时的图像PictureBox

在此处输入图片说明

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

在此处输入图片说明

我的图片是一个128x128png,这里是我PictureBox和我的设计器代码ImageList

// 
// 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");
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

c# image imagelist picturebox winforms

5
推荐指数
1
解决办法
773
查看次数

ImageList上的32位图像

我有以下图像:

图标

我正在从资源中读取它,放入ImageList中,然后从ImageList中读取它以在控件的表面上绘制。但是当我这样做时,图像似乎失去了有关Alpha通道的信息:

屏幕截图

这是所有相关的代码段:

Program.cs

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Run Code Online (Sandbox Code Playgroud)

MainForm.cs

ilFilters = new ImageList()
{            
    ColorDepth = ColorDepth.Depth32Bit,
    ImageSize = new Size(16, 16)
};

// (...)

if (info.Icon != null)
{
    if (info.Icon.Width == 16 && info.Icon.Height == 16)
    {
        ilFilters.Images.Add(info.Icon);

        index = ilFilters.Images.Count - 1;
    }
}
Run Code Online (Sandbox Code Playgroud)

实际上,我在(info.Icon)之前和之后(ilFilters.Images[0])将图像保存到图像列表中。第一个版本正确,第二个-损坏。好像ImageList损坏了图像。

我还尝试将PNG转换为32位BMP图像。没有成功

我正在运行的系统是Windows7。.NET4.5.1,Visual Studio 2013社区。

添加到图像列表时,如何保持图像的Alpha通道?


编辑: 概念验证应用

c# image imagelist alpha-transparency winforms

3
推荐指数
1
解决办法
1708
查看次数

标签 统计

c# ×2

image ×2

imagelist ×2

winforms ×2

alpha-transparency ×1

picturebox ×1