[急切求助]DrawDibDraw函数绘bmp图问题...

C# code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing.Imaging;
using System.IO; 


//一帧图片数据保存在txt文件中
//从文本文件读出来,绘制在Panel控件中
//但是用下面的代码绘制后什么也看不到...
namespace test
{
    public partial class Form1 : Form
    {
        public Rectangle SrcRect, DstRect;
        IntPtr hdd;
        public Control myControl = new Control(); //创建对象
        public BITMAPINFOHEADER bmiHeader;
              
            public void drawOpen()
            {
                //hdd赋值
                this.hdd = DrawDibOpen();

                bool b = DrawDibBegin(hdd,
                    IntPtr.Zero,
                    -1,
                    -1, 
                    ref this.bmiHeader, 
                    176, 
                    144, 
                    0);
            }

            public void Draw(byte[] data, IntPtr hdcPanel)
            {
                //hdc赋值
                IntPtr hdcPanel2 = GetDC(panel1.Handle); 
                IntPtr Hdc = GetDC(IntPtr.Zero);
                //Graphics g = Graphics.FromHdc(Hdc);
                               
               using (Graphics g = this.myControl.CreateGraphics())
               // using (Graphics g = this.panel1.CreateGraphics())                
                {
                    this.SrcRect = this.DstRect = new Rectangle(0, 0, 176, 144);
                    g.DrawRectangle(new Pen(Color.Red,2), this.Control.ClientRectangle);                    
                    IntPtr hdc = g.GetHdc(); 
                                        
                    this.bmiHeader.biCompression = 0;
                    this.bmiHeader.biPlanes = 1;
                    this.bmiHeader.biBitCount = 24;
                    this.bmiHeader.biSize = 40;
                    this.bmiHeader.biWidth = 176;
                    this.bmiHeader.biHeight = 144;
                       
             //绘图           
             bool b = DrawDibDraw(
             hdd,
             hdc,
             10,
             20,
             -1,
             -1,
             ref this.bmiHeader,
             data,
             0,
             0,
             176,
             144,
             8);  //DDF_SAME_DRAW
               
             g.ReleaseHdc(hdc);
                }
            }

        //绘制图片
        private void button2_Click(object sender, EventArgs e)
        {     
            //文本文件中保存一帧图片的数据,读出来放在byte数组中    
            byte[] buffer = System.IO.File.ReadAllBytes(@"d:\videoFrame.txt");            
            this.drawOpen();
            this.Draw(buffer, panel1.Handle);
        }
    }
}

作者: audiovideo2011   发布时间: 2011-06-15

C# code
DrawDibBegin和DrawDibDraw返回值都为true;

不知道是不是hdc获取的值有问题,
感觉hdc值比较大 hdc = 1090591572

作者: audiovideo2011   发布时间: 2011-06-15