BYTE* lpDestBuf 缓冲区中存有图象数据,怎样取出来存为jpeg图象(或bmp)
已有函数能取得显卡(或显示屏)中的数据,原形为:
int __stdcall ReadDispWindow(HDC hdc,int left,int top,int width,int height,BYTE* lpDestBuf);
函数说明:取指定窗口内的图象数据,存于数据区 lpDestBuf中,lpDestBuf中的第一行数据为图象窗口中最后一行数据,按先后顺序存放。对于8位图象数据方式:每个像素对应其灰度值;对于15位以上数据方式:每个像素有红,绿,蓝三个各8位,共24位颜色值。
我不知道怎样取出lpDestBuf中的数据,经过怎样的转换才能显示为jpeg.望各位老大给一段程序。
问题点数:100、回复次数:8Top
1 楼pop155()回复于 2003-09-03 15:58:06 得分 20
每个像素有红,绿,蓝三个各8位,也就是每三个字节表示一个像素,这也是24位图的表现形式,好像得知道图像的宽和高,24位的可以直接用jpeg.lib中的库函数转换成jpeg,
原型:
extern "C" void RGBtoJPEGFile(BYTE* Buff,DWORD ImageWidth,DWORD ImageHeight,char* outFileName);
Top
2 楼bphantom(无花无酒)回复于 2003-09-03 16:03:35 得分 0
上面的width,height就是图象的宽和高了。谢谢了,我先试试。Top
3 楼XZHHAI(星之瀚海)回复于 2003-09-03 16:05:46 得分 0
学习Top
4 楼hansome(连环)回复于 2003-09-03 16:07:49 得分 40
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;
稍做修改和扩展就可以了Top
5 楼bphantom(无花无酒)回复于 2003-09-03 16:17:33 得分 0
在msdn中我找不到,在delphi中怎么做呢?procedure ReadBuffer(var Buffer; Count: Longint);读吗?读出来要怎么弄成jpg或jpeg图象呢?Top
6 楼bphantom(无花无酒)回复于 2003-09-03 16:19:48 得分 0
to hansome(连环),好,我试试。Top
7 楼bphantom(无花无酒)回复于 2003-09-03 16:47:26 得分 0
函数原形为:ReadDispWindow(hdc:LongWord; Left,Top,Width, Height:Integer;
lpDestBuf:PChar):integer;stdcall;呢?Top
8 楼pop155()回复于 2003-09-04 11:52:55 得分 40
RGBtoJPEGFile 不是微软的冬冬,是第三方连接库,你到google上查一下jpeg.lib 会有的Top




