我有一个VB写的类如下:
Public Type BITMAPINFOHEADER
        biSize As Long
        biWidth As Long
        biHeight As Long
        biPlanes As Integer
        biBitCount As Integer
        biCompression As Long
        biSizeImage As Long
        biXPelsPerMeter As Long
        biYPelsPerMeter As Long
        biClrUsed As Long
        biClrImportant As Long
End TypePublic Type RGBQUAD
        rgbBlue As Byte
        rgbGreen As Byte
        rgbRed As Byte
        rgbReserved As Byte
End TypePublic Type rgb
    red As Byte
    green As Byte
    blue As Byte
End TypePublic Type BITMAPINFO
        bmiHeader As BITMAPINFOHEADER
        bmiColors As RGBQUAD
End Type前面四个我都会用DELPHI来写了,但后面一个用DELPHI写的时候不知道如果写成类的类型
请教
Public Type BITMAPINFO
        bmiHeader As BITMAPINFOHEADER
        bmiColors As RGBQUAD
End Type
就这个不会写.

解决方案 »

  1.   

    在delphi里边BITMAPINFOHEADER 应该是个记录类型,RGBQUAD 不清楚
      

  2.   

    参考一下这个文章http://www.vckbase.com/document/viewdoc/?id=674
      

  3.   


    typedef struct tagBITMAPINFOHEADER{ // bmih 
        DWORD  biSize; 
        LONG   biWidth; 
        LONG   biHeight; 
        WORD   biPlanes; 
        WORD   biBitCount 
        DWORD  biCompression; 
        DWORD  biSizeImage; 
        LONG   biXPelsPerMeter; 
        LONG   biYPelsPerMeter; 
        DWORD  biClrUsed; 
        DWORD  biClrImportant; 
    } BITMAPINFOHEADER; typedef struct tagRGBQUAD { // rgbq 
        BYTE    rgbBlue; 
        BYTE    rgbGreen; 
        BYTE    rgbRed; 
        BYTE    rgbReserved; 
    } RGBQUAD;
    转成pascal代码吧
      

  4.   

    BITMAPINFOHEADER=record...end;
    RGBQUAD=record...end;
    BITMAPINFO=record
      bmiHeader: BITMAPINFOHEADER; 
      bmiColors: RGBQUAD;
    end; 
      

  5.   

    4楼用的是C++CODE代码,用结构体.....我贴代码出来..
     type
        BITMAPINFOHEADER=class
            biSize:Integer;
            biWidth:Integer;
            biHeight:Integer;
            biPlanes:Integer;
            biBitCount:Integer;
            biCompression:Integer;
            biSizeImage:Integer;
            biXPelsPerMeter:Integer;
            biYPelsPerMeter:Integer;
            biClrUsed:Integer;
            biClrImportant:Integer;
     end;
     type
         RGBQUAD=class
          rgbBlue:Byte;
          rgbGreen:Byte;
          rgbRed:Byte;
          rgbReserved:Byte;
     end;
     type
         rgb=class
         red:Byte;
         green:Byte;
         blue:Byte;
     end;
    最后一个如下:这样转DELPHI编不过去
     type
        BITMAPINFO=class;
       bmiHeader:BITMAPINFOHEADER;
       bmiColors:RGBQUAD;
     end;
      

  6.   

    为什么是BITMAPINFOHEADER=record 而不是BITMAPINFOHEADER=class 
      

  7.   


    type 
      BITMAPINFOHEADER=record
      biSize:Integer; 
      biWidth:Integer; 
      biHeight:Integer; 
      biPlanes:Integer; 
      biBitCount:Integer; 
      biCompression:Integer; 
      biSizeImage:Integer; 
      biXPelsPerMeter:Integer; 
      biYPelsPerMeter:Integer; 
      biClrUsed:Integer; 
      biClrImportant:Integer; 
    end; 
    你写成class了
      

  8.   

    是的,我刚才写成RECORD就可以编过去了,但我不明白为什么是RECORD而不是CLASS..我也见DELPHI里有用CLASS的啊.比如FORM类...能解释吗?
    我写个答谢你俩进来给分你们..
      

  9.   

    class是pascal语言的类,类是可以具有变量,方法和函数的,record类型相当于c/c++的结构体这里这能说BITMAPINFOHEADER是个记录类型,不是class
      

  10.   


    tagBITMAPINFOHEADER = packed record
        biSize: DWORD;
        biWidth: Longint;
        biHeight: Longint;
        biPlanes: Word;
        biBitCount: Word;
        biCompression: DWORD;
        biSizeImage: DWORD;
        biXPelsPerMeter: Longint;
        biYPelsPerMeter: Longint;
        biClrUsed: DWORD;
        biClrImportant: DWORD;
      end;
      TBitmapInfoHeader = tagBITMAPINFOHEADER;
      {$EXTERNALSYM BITMAPINFOHEADER}
      BITMAPINFOHEADER = tagBITMAPINFOHEADER;
    复制自delphi6的vcl源代码