已有函数能取得显卡(或显示屏)中的数据,原形为:
int __stdcall ReadDispWindow(HDC hdc,int left,int top,int width,int height,BYTE* lpDestBuf);
函数说明:取指定窗口内的图象数据,存于数据区 lpDestBuf中,lpDestBuf中的第一行数据为图象窗口中最后一行数据,按先后顺序存放。对于8位图象数据方式:每个像素对应其灰度值;对于15位以上数据方式:每个像素有红,绿,蓝三个各8位,共24位颜色值。我不知道怎样取出lpDestBuf中的数据,经过怎样的转换才能显示为jpeg.望各位老大给一段程序。

解决方案 »

  1.   

    每个像素有红,绿,蓝三个各8位,也就是每三个字节表示一个像素,这也是24位图的表现形式,好像得知道图像的宽和高,24位的可以直接用jpeg.lib中的库函数转换成jpeg,
    原型:
    extern "C" void RGBtoJPEGFile(BYTE* Buff,DWORD ImageWidth,DWORD ImageHeight,char* outFileName);
      

  2.   

    上面的width,height就是图象的宽和高了。谢谢了,我先试试。
      

  3.   

    var
        Bitmap: TBitmap;
        ByteArray: PByteArray;
        x, y: Integer;
    begin
        Bitmap := TBitmap.Create;
        Bitmap.Width := 320;
        Bitmap.Height := 200;
        Bitmap.PixelFormat := pf24bit;
        for y:=0 to 200 do
        begin
            ByteArray := Bitmap.ScanLine[y];
            ByteArray := lpDestBuf;  //这样就可以传入一行象素
        end;
        Bitmap.SaveToFile('tom.bmp');
        Bitmap.Free;
    end;稍做修改和扩展就可以了
      

  4.   

    在msdn中我找不到,在delphi中怎么做呢?procedure ReadBuffer(var Buffer; Count: Longint);读吗?读出来要怎么弄成jpg或jpeg图象呢?
      

  5.   

    to hansome(连环),好,我试试。
      

  6.   

    函数原形为:ReadDispWindow(hdc:LongWord; Left,Top,Width, Height:Integer;
               lpDestBuf:PChar):integer;stdcall;呢?
      

  7.   

    RGBtoJPEGFile 不是微软的冬冬,是第三方连接库,你到google上查一下jpeg.lib 会有的