Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:2k
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <Printers.hpp>
- #include <math.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- Printer()->BeginDoc();
- PaintTo(Printer()->Handle, 10, 10);
- Printer()->EndDoc();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- TRect rect;
- int px,py;
- double aa;
- Graphics::TBitmap *bmp = new Graphics::TBitmap();
- px=GetDeviceCaps(Printer()->Handle,LOGPIXELSX);
- py=GetDeviceCaps(Printer()->Handle,LOGPIXELSY);
- bmp->Width=Width;
- bmp->Height=Height;
- // bmp->Canvas->MoveTo(10,10);
- // bmp->Canvas->LineTo(100,100);
- // bmp->LoadFromFile("c:\te\bmp.bmp");
- PaintTo(bmp->Handle, 0, 0);
- bmp->SaveToFile("c:\te\bmp1.bmp");
- rect.Left=20;
- rect.Top=20;
- aa=px;
- aa=aa/96;
- aa=aa*Width;
- rect.Right=floor(aa);
- aa=py;
- aa=aa/96;
- aa=aa*Height;
- rect.Bottom=floor(aa);
- // Printer()->BeginDoc();
- // StretchBlt(Printer()->Handle,20,20,rect.right,rect.bottom,this,0,0,Width,Height,SRCCOPY);
- // Printer()->Canvas->StretchDraw(rect,bmp);
- // Printer()->EndDoc();
- delete bmp;
- }
- //---------------------------------------------------------------------------