Q&A

  • 어떻게 인쇄를 해야 할지 몰라유~!
unit Unit7;



interface



uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs ,printers,

StdCtrls, ExtCtrls ;



type

TForm1 = class(TForm)

Image1: TImage;

Button1: TButton;

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

procedure PrintBmp(ARect : TRect ; ABitmap : TBitmap);

end;



var

Form1: TForm1;



implementation



{$R *.DFM}



{ TForm1 }



procedure TForm1.PrintBmp(ARect: TRect; ABitmap: TBitmap);

var

Info : PBitmapInfo ;

InfoSize : DWORD ;

Image : Pointer ;

ImageSize : DWORD ;

Bits : HBITMAP ;

DIBWidth , DIBHeight : Longint ;

begin

with Printer,Canvas do

begin

Bits := ABitmap.Handle ;

GetDIBSizes(Bits , InfoSize , ImageSize ) ;

Info:= AllocMem(InfoSize) ;

try

Image := AllocMem(ImageSize) ;

try

GetDIB(Bits,0,Info^,image^) ;

with Info^.bmiHeader do

begin

DIBWidth := biWidth ;

DIBHeight := biHeight ;

end ;

StretchDIBits(printer.Canvas.Handle ,

ARect.Left ,ARect.Top ,ARect.Right,ARect.Bottom ,

0,0,DIBWidth ,DIBHeight,

Image , info^ , DIB_RGB_COLORS , SRCCOPY) ;

finally

FreeMem(Image , ImageSize ) ;

end;

finally

FreeMem(info , InfoSize) ;

end ;

end;

end ;

procedure TForm1.Button1Click(Sender: TObject);

var

hi : TRect;

begin

hi.Top := 0;

hi.Left := 0;

hi.Right := Image1.Width;

hi.Bottom := Image1.Height;

Printer.BeginDoc ;

SetMapMode( printer.Handle , 4) ;

PrintBmp(hi, Image1.Picture.Bitmap );

Printer.EndDoc ;

end;



end.



그야 간단히.. 한줄짜리 코드로 가능하겠지만요..! 제가 생각하는 것은

트루칼라 비트맵에서조차도 선명한 그림 인쇄이옵니다.



왜 인쇄가 안될까유~!

0  COMMENTS