显卡在.net错误的图像插值显卡、图像、错误、插值

2023-09-03 05:42:03 作者:别碰我的小熊

我有一个简单的测试。当它被解决了,我的问题解决了。 当小图像时,显卡插不坏的工作。

I have an simple test. When it is solved, my problem is solved too. When working with small images, the graphics interpolation does bad work.

请检查出来,如果​​你知道如何解决,在以下code的结果图像并忽略图像的下半年绘制的问题。 使用的LoadImage从JPG或任何你想要的东西画在图像上。

Please check out if you know how to fix the problem that the result image in the following code does ignore second half of image to draw. Draw something on the image by using loadimage from JPG or whatever you want.

    Dim GrayImage as system.drawing.Bitmap(640,480)    
    Dim bmTmp As New System.Drawing.Bitmap(GrayImage.Width, 1)
    Using gr As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(bmTmp)
         gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None
         gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear
         gr.DrawImage(GrayImage, New System.Drawing.Rectangle(0, 0, bmTmp.Width, bmTmp.Height), New System.Drawing.Rectangle(0, 0, GrayImage.Width - 0, GrayImage.Height - 0), System.Drawing.GraphicsUnit.Pixel)
     End Using

     GrayImage = New System.Drawing.Bitmap(GrayImage.Width, GrayImage.Height, GrayImage.PixelFormat)
     Using gr As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(GrayImage)
         gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None
         gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor
         gr.DrawImage(bmTmp, New System.Drawing.Rectangle(0, 0, GrayImage.Width, GrayImage.Height ), New System.Drawing.Rectangle(0, 0, bmTmp.Width - 0, bmTmp.Height - 0), System.Drawing.GraphicsUnit.Pixel)
     End Using

点击这里下载原始数据来源: http://www.goldengel.ch/temp/Source01% 20one%20Pixel.jpg (一个像素高的图像)

Download original Source here: http://www.goldengel.ch/temp/Source01%20one%20Pixel.jpg (one Pixel height image)

下半场垂直不被使用的DrawImage梅索德绘制。我想有形象,因此,你在第一次看到图片。拉伸图像源上的全部内容。

The second half vertical is not drawn by using the DrawImage methode. I want to have the image as result as you see on first picture. Stretched image with source on whole content.

*下载* 点击此处下载完整的工作VS2010 VB.Net演示项目:

* DOWNLOAD* Download here full working VS2010 VB.Net demo project:

VS2010缩放项目与描述 - 蒂莫·鲍姆(Böhme)

推荐答案

请尝试添加:

gr.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality

你的最后一句。 GDI魔法我想:)

to your last clause. GDI magic I guess :)

希望这有助于!