简体   繁体   English

C#宽度增加的位图变成透明

[英]c# width increased bitmap turns transparent

i tried to draw a headerCell. 我试图画一个headerCell。

original picture looks like this (increased): 原始图片看起来像这样(增加):

增加

I tried to stretch the images width: 我试图拉伸图像的宽度:

 Bitmap bmp = new Bitmap(3000, 1000);
 Graphics graph = Graphics.FromImage(bmp);
 Image headerMain = Image.FromFile(imagePfad + "header_main.jpg");
 graph.DrawImage(headerMain, X, Y, 300, headerMain.Height);

 Graphics g = CreateGraphics();
 g.DrawImage(bmp, 0, 0);

But then it turns into transparent like this: 但随后变成透明:

headerPic

what am i doing wrong? 我究竟做错了什么?

At such extreme magnifications, the work done by the interpolation filter becomes highly visible. 在这样的极端放大倍数下,插值滤镜所做的工作变得非常明显。 You'll want to de-tune it to nearest-neighbor, pixel offset mode matters too: 您需要将其调整为最近邻,像素偏移模式也很重要:

graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
graph.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM