to alei_nb
知道怎么做了。tel me
知道怎么做了。tel me
解决方案 »
- delphi如何显示mht文件,不用Twebbrower
- 各位大哥,有个问题帮忙解决一下~~~~~~~~~~~~~~
- 如何取很多表的数据并且可以在一张报表里面统计出来!!急!
- 怎么做才能不让image1在刷新时不闪烁呢.
- 请教一个很着急的问题,如何群发邮件,我用了四种办法
- 谁有超市管理软件,出几千元寻求此管理软件
- 应该不难不问题,解决后马上给200分或更多!!
- EhLib中打印的问题——千山一刀求教
- ComboBox2.Items.Assign(Screen.Fonts);可以读出字体到combobox2中,如果我想把字体的大小读入怎么做呢?
- 麻烦那位朋友帮我找一个函数!!
- 我防空洞棵反对恺撒棵
- 谁有vcl书籍免费下载的网址
分类:图形图象 strang (1998-11-30 9:36:00)
我用Timage控件显示图形,不知道能否将他打印?应如何做?
茶叶蛋 (1998-11-30 9:48:00)
TPrinter类不是有画布(Canvas)吗?可以提供一组处理图形需要的方法。还可以使用任何Windows GDI调用或连接大多数第三方的图形库。关键是
运用TPrinter的Canvas.handle属性。他是一个标准的Windows打印机DC,
每当需要一个DC的handle时,都可能使用它。Ps: 1。使用该handle前必须调用Printer方法的BeginDoc方法(或使用
AssignPrn和Rewrite)。
2。可以看一看Delphi3开发使用手册,里面有很详尽的介绍,还有例子,
略微改一改就可以打印图形了。
strang (1998-11-30 10:15:00)
能否给个例子?
茶叶蛋 (1998-11-30 10:25:00)
例子在书上,我原来作的东西总是随作随丢。
等的及的话,我敲给你。
jiangtao (1998-11-30 13:22:00)
how to print a bitmap:Use the following code. Remember to include the Printers unit in the uses clause :Lines followed by // ** are essential. The others are to get the scaling correct
otherwise you end up with extremely small images. Printer resolutions are higher than
your screen resolution.
procedure TForm1.Button1Click(Sender: TObject);
var
ScaleX, ScaleY: Integer;
R: TRect;
begin
Printer.BeginDoc; // **
with Printer do
try
ScaleX := GetDeviceCaps(Handle, logPixelsX) div PixelsPerInch;
ScaleY := GetDeviceCaps(Handle, logPixelsY) div PixelsPerInch;
R := Rect(0, 0, Image1.Picture.Width * ScaleX,
Image1.Picture.Height * ScaleY);
Canvas.StretchDraw(R, Image1.Picture.Graphic); // **
finally
EndDoc; // **
end;
end;
strang (1998-11-30 14:56:00)
打印出来的图形很小,怎么回事?
jiangtao (1998-11-30 17:55:00) 打印大小和你打打印机的精度,图象大小都有关系,
如为激光打印机或高精度ink printer,(>360dpi)
屏幕的显示精度相当于72dpi,图象打印出来的物理尺寸很小你可以调整打印区域 R 的大小
如果图象很小,放大打印的效果并不好
Another_eYes (1998-11-30 23:28:00)
最简单的办法:
printer.Canvas.StrechDraw(Image1.BoundsRect, Image1.Picture.Graphic);
我用过, 尺寸会自动放大.
liangXing (1998-12-2 16:31:00)
try this: uses Printers; type
PPalEntriesArray = ^TPalEntriesArray; {for palette re-construction}
TPalEntriesArray = array[0..0] of TPaletteEntry; procedure BltTBitmapAsDib(DestDc : hdc; {Handle of where to blt}
x : word; {Bit at x}
y : word; {Blt at y}
Width : word; {Width to stretch}
Height : word; {Height to stretch}
bm : TBitmap); {the TBitmap to Blt}
var
OriginalWidth :LongInt; {width of BM}
dc : hdc; {screen dc}
IsPaletteDevice : bool; {if the device uses palettes}
IsDestPaletteDevice : bool; {if the device uses palettes}
BitmapInfoSize : integer; {sizeof the bitmapinfoheader}
lpBitmapInfo : PBitmapInfo; {the bitmap info header}
hBm : hBitmap; {handle to the bitmap}
hPal : hPalette; {handle to the palette}
OldPal : hPalette; {temp palette}
hBits : THandle; {handle to the DIB bits}
pBits : pointer; {pointer to the DIB bits}
lPPalEntriesArray : PPalEntriesArray; {palette entry array}
NumPalEntries : integer; {number of palette entries}
i : integer; {looping variable}
begin
{If range checking is on - lets turn it off for now}
{we will remember if range checking was on by defining}
{a define called CKRANGE if range checking is on.}
{We do this to access array members past the arrays}
{defined index range without causing a range check}
{error at runtime. To satisfy the compiler, we must}
{also access the indexes with a variable. ie: if we}
{have an array defined as a: array[0..0] of byte,}
{and an integer i, we can now access a[3] by setting}
{i := 3; and then accessing a[i] without error}
{$IFOPT R+}
{$DEFINE CKRANGE}
{$R-}
{$ENDIF} {Save the original width of the bitmap}
OriginalWidth := bm.Width; {Get the screen's dc to use since memory dc's are not reliable}
dc := GetDc(0);
{Are we a palette device?}
IsPaletteDevice :=
GetDeviceCaps(dc, RASTERCAPS) and RC_PALETTE = RC_PALETTE;
{Give back the screen dc}
dc := ReleaseDc(0, dc); {Allocate the BitmapInfo structure}
if IsPaletteDevice then
BitmapInfoSize := sizeof(TBitmapInfo) + (sizeof(TRGBQUAD) * 255)
else
BitmapInfoSize := sizeof(TBitmapInfo);
GetMem(lpBitmapInfo, BitmapInfoSize); {Zero out the BitmapInfo structure}
FillChar(lpBitmapInfo^, BitmapInfoSize, #0); {Fill in the BitmapInfo structure}
lpBitmapInfo^.bmiHeader.biSize := sizeof(TBitmapInfoHeader);
lpBitmapInfo^.bmiHeader.biWidth := OriginalWidth;
lpBitmapInfo^.bmiHeader.biHeight := bm.Height;
lpBitmapInfo^.bmiHeader.biPlanes := 1;
if IsPaletteDevice then
lpBitmapInfo^.bmiHeader.biBitCount := 8
else
lpBitmapInfo^.bmiHeader.biBitCount := 24;
lpBitmapInfo^.bmiHeader.biCompression := BI_RGB;
lpBitmapInfo^.bmiHeader.biSizeImage :=
((lpBitmapInfo^.bmiHeader.biWidth *
longint(lpBitmapInfo^.bmiHeader.biBitCount)) div 8) *
lpBitmapInfo^.bmiHeader.biHeight;
lpBitmapInfo^.bmiHeader.biXPelsPerMeter := 0;
lpBitmapInfo^.bmiHeader.biYPelsPerMeter := 0;
if IsPaletteDevice then begin
lpBitmapInfo^.bmiHeader.biClrUsed := 256;
lpBitmapInfo^.bmiHeader.biClrImportant := 256;
end else begin
lpBitmapInfo^.bmiHeader.biClrUsed := 0;
lpBitmapInfo^.bmiHeader.biClrImportant := 0;
end; {Take ownership of the bitmap handle and palette}
hBm := bm.ReleaseHandle;
hPal := bm.ReleasePalette; {Get the screen's dc to use since memory dc's are not reliable}
dc := GetDc(0); if IsPaletteDevice then begin
{If we are using a palette, it must be}
{selected into the dc during the conversion}
OldPal := SelectPalette(dc, hPal, TRUE);
{Realize the palette}
RealizePalette(dc);
end;
{Tell GetDiBits to fill in the rest of the bitmap info structure}
GetDiBits(dc,
hBm,
0,
lpBitmapInfo^.bmiHeader.biHeight,
nil,
TBitmapInfo(lpBitmapInfo^),
DIB_RGB_COLORS); {Allocate memory for the Bits}
hBits := GlobalAlloc(GMEM_MOVEABLE,
lpBitmapInfo^.bmiHeader.biSizeImage);
pBits := GlobalLock(hBits);
{Get the bits}
GetDiBits(dc,
hBm,
0,
lpBitmapInfo^.bmiHeader.biHeight,
pBits,
TBitmapInfo(lpBitmapInfo^),
DIB_RGB_COLORS);
if IsPaletteDevice then begin
{Lets fix up the color table for buggy video drivers}
GetMem(lPPalEntriesArray, sizeof(TPaletteEntry) * 256);
{$IFDEF VER100}
NumPalEntries := GetPaletteEntries(hPal,
0,
256,
lPPalEntriesArray^);
{$ELSE}
NumPalEntries := GetSystemPaletteEntries(dc,
0,
256,
lPPalEntriesArray^);
{$ENDIF}
for i := 0 to (NumPalEntries - 1) do begin
lpBitmapInfo^.bmiColors[i].rgbRed :=
lPPalEntriesArray^[i].peRed;
lpBitmapInfo^.bmiColors[i].rgbGreen :=
lPPalEntriesArray^[i].peGreen;
lpBitmapInfo^.bmiColors[i].rgbBlue :=
lPPalEntriesArray^[i].peBlue;
end;
FreeMem(lPPalEntriesArray, sizeof(TPaletteEntry) * 256);
end; if IsPaletteDevice then begin
{Select the old palette back in}
SelectPalette(dc, OldPal, TRUE);
{Realize the old palette}
RealizePalette(dc);
end; {Give back the screen dc}
dc := ReleaseDc(0, dc); {Is the Dest dc a palette device?}
IsDestPaletteDevice :=
GetDeviceCaps(DestDc, RASTERCAPS) and RC_PALETTE = RC_PALETTE;
if IsPaletteDevice then begin
{If we are using a palette, it must be}
{selected into the dc during the conversion}
OldPal := SelectPalette(DestDc, hPal, TRUE);
{Realize the palette}
RealizePalette(DestDc);
end; {Do the blt}
StretchDiBits(DestDc,
x,
y,
Width,
Height,
0,
0,
OriginalWidth,
lpBitmapInfo^.bmiHeader.biHeight,
pBits,
lpBitmapInfo^,
DIB_RGB_COLORS,
SrcCopy); if IsDestPaletteDevice then begin
{Select the old palette back in}
SelectPalette(DestDc, OldPal, TRUE);
{Realize the old palette}
RealizePalette(DestDc);
end; {De-Allocate the Dib Bits}
GlobalUnLock(hBits);
GlobalFree(hBits); {De-Allocate the BitmapInfo}
FreeMem(lpBitmapInfo, BitmapInfoSize); {Set the ownership of the bimap handles back to the bitmap}
bm.Handle := hBm;
bm.Palette := hPal; {Turn range checking back on if it was on when we started}
{$IFDEF CKRANGE}
{$UNDEF CKRANGE}
{$R+}
{$ENDIF}
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if PrintDialog1.Execute then begin
Printer.BeginDoc;
BltTBitmapAsDib(Printer.Canvas.Handle,
0,
0,
Image1.Picture.Bitmap.Width,
Image1.Picture.Bitmap.Height,
Image1.Picture.Bitmap);
Printer.EndDoc;
end;
end;
李亚平 (1998-12-4 16:27:00)
最简单的做法:
本人常用:
使用QUICK REPORT 建立一个页面FORM2,
( 在FORM2中放一个QuickRep1控件)使用一个QRIMAGE
FORM1中的图星控件名IMAGE1,代码:
form2.qrimage1.picture:=form1.image1.picture;
form2.QuickRep1.Print; 打印
form2.QuickRep1.Preview 模拟显示
图形的大小可以使用QREPORT自由调节,有标尺呦!
还可以使用QRLABEL加文字!
李亚平 (1998-12-4 16:32:00)
最简单的做法:
本人常用:
使用QUICK REPORT 建立一个页面FORM2,
( 在FORM2中放一个QuickRep1控件)使用一个QRIMAGE
FORM1中的图星控件名IMAGE1,代码:
form2.qrimage1.picture:=form1.image1.picture;
form2.QuickRep1.Print; 打印
form2.QuickRep1.Preview 模拟显示
图形的大小可以使用QREPORT自由调节,有标志呦!
strang (1999-3-26 13:12:00)
多人接受答案了。
zhangyunchao (1999-5-28 15:53:00)
朋友,所有这些答案都是仅打印一页啊!难道大家都不需要打印一个大bitmap 吗?
打印一个大bitmap 需要非常特殊的处理,我这里有源程序。
commons_sheng (2001-9-26 17:31:00)
to liangxing:这个例子打印出来的图形非常小,可有什么办法把它弄大一点?
我出50分
Another_eYes-10,jiangtao-10,liangXing-10,茶叶蛋-10,李亚平-10,的回答最终被接受。