I am new to C#, I am using Visual Studo 2010, I have an image that needs to be displayed on a picturebox. I tried many different methods. All the methods results in some unwanted pixels to appear along with image. I have tried picturebox.Image = Image.FromFile("bird.png");
我是C#的新手,我使用的是Visual Studo 2010,我有一个需要在图片框上显示的图像。我尝试了很多不同的方法。所有方法都会导致一些不需要的像素与图像一起出现。我试过过picturebox.Image = Image.FromFile(“bird.png”);
result-> the image is displayed but with the stray white/black pixels at random places.
result->显示图像,但随机位置有杂散的白色/黑色像素。
I also tried creating a bitmap of same size and drawing the image onto the bitmap and then assigning the bitmap to the picture box.Image. Still those unwanted pixels are visible.
我还尝试创建一个相同大小的位图并将图像绘制到位图上,然后将位图分配给图片框。图像。这些不需要的像素仍然可见。
I have tried clearing the picture box image (filling it with white or transparent) and then assigning the image, still same error occurs.
我已经尝试清除图片框图像(用白色或透明填充),然后分配图像,仍然发生相同的错误。
PS: this doesn't happen for all the images only certain images show this behaviour.
PS:对于所有图像都不会发生这种情况,只有某些图像才会显示此行为。
any help would be great
任何帮助都会很棒
Code:
码:
Image org = Bitmap.FromFile("bird.png");
Bitmap final = new Bitmap(org.Width,org.Height);
using (Graphics g = Graphics.FromImage(final))
{
g.DrawImage(org,0,0,GraphicsUnit.Pixel);
}
picturebox.Image = final;
if i use final.save("picture.png"). The "picuture.png" does not have that wrong pixels, it happens only when i use picture box to display it.
如果我使用final.save(“picture.png”)。 “picuture.png”没有错误的像素,只有当我使用图片框来显示它时才会发生。
Please find the images attached defect orginal
请找到图像附加缺陷原始
PS: its not because of different fileformat (orginal and defect)
PS:它不是因为不同的文件格式(原始和缺陷)
1 个解决方案
#1
0
It was an TransperancyKey issue resolved by setting it to Default.
通过将其设置为默认值解决了TransperancyKey问题。
#1
0
It was an TransperancyKey issue resolved by setting it to Default.
通过将其设置为默认值解决了TransperancyKey问题。