已知一个图片的HDC,如何将其存成JPG文件。另:用Bitblt函数打印出来的图片如何调整大小到一张A4纸上。谢谢。 1.记得有一个头文件为:jpeg.pas/jpg.pas(查找一下),其中有控制jpg的一些函数;2.Bitblt有另一个类似的函数,有放大和缩小的功能,在API的帮助中找一下(s开头的)。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 procedure TForm1.SaveScrToStream(AStream: TMemoryStream;zl:integer;dx:integer);var scrWidth, scrHeight: integer; DC: hDC; scale:real; FBitmap,bbmp: TBitmap; FJPEGImage: TJPEGImage;begin if dx<10 then dx:=1024; if (zl<2) or (zl>99) then zl:=99; DC := GetDC(0); FBitmap := TBitmap.Create; bbmp:= 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); //调整尺寸 scale:=screen.Width/dx; bbmp.Width:=round(screen.Width/scale); bbmp.Height:=round(screen.Height/scale); SetStretchBltMode(bbmp.Canvas.Handle,COLORONCOLOR); stretchblt(bbmp.Canvas.Handle,0,0,bbmp.Width,bbmp.Height,FBitmap.Canvas.Handle,0,0,FBitmap.Width,FBitmap.Height,srccopy); FJPEGImage.Assign(bbmp); // //FJPEGImage.Assign(FBitmap); FJPEGImage.CompressionQuality := zl;//调整图象质量 FJPEGImage.Compress; AStream.Clear; FJPEGImage.SaveToStream(AStream); AStream.Position := 0; LeftSize:=AStream.Size; finally FBitmap.Free; bbmp.Free; FJPEGImage.Free; ReleaseDC(0, DC); end;end; 打印使用TMetaFile,具体见online help 谢谢各位,尤其是xiaotian2000(小天)。 请问下DELPHI怎么调用方法的 如何屏蔽shelllistview中双击打开文件,帮帮忙 请教。关于嵌套嵌套循环的问题 高手求救-TSocketConnection问题 谁有精确打印的控件?急用,100分相送 关于delphi局部结构变量,初始化问题。这事儿说起来很惭愧。。。。 将delphi程序改写成powerbuilder程序,试试看! ini文件 怎样自动的让每条选中的记录自己增加? Image的存取?非常急,兄弟们拉我一把! 大虾们,怎么往Mpeg流中写入自己的数据,比如汉字,有没有这样的软件? 有个问题我不能解,向大家求救!
var
scrWidth, scrHeight: integer;
DC: hDC;
scale:real;
FBitmap,bbmp: TBitmap;
FJPEGImage: TJPEGImage;
begin
if dx<10 then dx:=1024;
if (zl<2) or (zl>99) then zl:=99;
DC := GetDC(0);
FBitmap := TBitmap.Create;
bbmp:= 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); //调整尺寸
scale:=screen.Width/dx;
bbmp.Width:=round(screen.Width/scale);
bbmp.Height:=round(screen.Height/scale);
SetStretchBltMode(bbmp.Canvas.Handle,COLORONCOLOR);
stretchblt(bbmp.Canvas.Handle,0,0,bbmp.Width,bbmp.Height,FBitmap.Canvas.Handle,0,0,FBitmap.Width,FBitmap.Height,srccopy);
FJPEGImage.Assign(bbmp);
// //FJPEGImage.Assign(FBitmap);
FJPEGImage.CompressionQuality := zl;//调整图象质量
FJPEGImage.Compress; AStream.Clear;
FJPEGImage.SaveToStream(AStream);
AStream.Position := 0;
LeftSize:=AStream.Size;
finally
FBitmap.Free;
bbmp.Free;
FJPEGImage.Free;
ReleaseDC(0, DC);
end;
end;