]、。·ˉˇ¨〃々—~‖…’”〕〉》」』〗】∶!"'),.:;?]` procedure SaveScrToStream(AStream: TMemoryStream);
var
scrWidth, scrHeight: integer;
DC: hDC;
FBitmap: TBitmap;
FJPEGImage: TJPEGImage;
begin
DC := GetDC(0);
FBitmap := TBitmap.Create;
FJPEGImage := TJPEGImage.Create;
try
scrWidth := Screen.Width;
scrHeight := Screen.Height;
FBitmap.Width := scrWidth;
FBitmap.Height := scrHeight;
BitBlt(FBitmap.Canvas.Handle, 0, 0, scrWidth, scrHeight, DC, 0, 0, SRCCOPY);
FJPEGImage.Assign(FBitmap);
FJPEGImage.CompressionQuality := 10;
FJPEGImage.Compress;
AStream.Clear;
FJPEGImage.SaveToStream(AStream);
AStream.Position := 0;
finally
FBitmap.Free;
FJPEGImage.Free;
ReleaseDC(0, DC);
end;
end;
//将内存流中的 JPEG 图像显示出来
procedure DrawJpegStream(AStrem: TMemoryStream; AImage: TImage);
var
FJPEGImage: TJPEGImage;
begin
FJPEGImage := TJPEGImage.Create;
try
FJPEGImage.LoadFromStream(AStream);
AImage.Width := FJPEGImage.Width;
AImage.Height := FJPEGImage.Height;
AImage.Canvas.Draw(0, 0, FJPEGImage);
finally
FJPEGImage.Free;
end;
end;