本帖最后由 liugang9931706 于 2011-10-06 16:48:36 编辑

解决方案 »

  1.   

    其实我想测试下:SetStretchBltMode和StretchDIBits的使用。
    求高手看看为什么没有显示出来??
      

  2.   

    修改后可以显示,但是是空白的。
    public void DrawImage(byte[] pixels, Graphics g)
            {
                // Create a BITMAPINFO object representing the image to be drawn
                // Image is 512 x 512, 8bpp
                BITMAPINFO bmi = new BITMAPINFO();
                bmi.biWidth = 512;
                bmi.biHeight = 512;
                bmi.biPlanes = 1;
                bmi.biBitCount = 8;
                bmi.biSizeImage = pixels.Length;            IntPtr pt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(BITMAPINFO)));
                Marshal.Copy(pixels, 0, pt, Marshal.SizeOf(typeof(BITMAPINFO)));
                IntPtr bm = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(BITMAPINFO)));
                // Draw the image using the graphics object
                StretchDIBits(g.GetHdc(), 0, 0, 512, 512, 0, 0, 512, 512, pt, bm, DIB_RGB_COLORS, SRCCOPY);        }