CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C++ Builder >  基础类

用API函数实际图片或文档的打印怎么写的?

楼主tompkins2000(AirHunter)2005-04-04 14:32:55 在 C++ Builder / 基础类 提问

打印各种图片啊,文档什么的 问题点数:40、回复次数:4Top

1 楼Raptor(猛禽)回复于 2005-04-04 15:35:59 得分 5

1Top

2 楼constantine(飘遥的安吉儿)回复于 2005-04-04 16:30:11 得分 30

#include   <Printers.hpp>  
      Graphics::TBitmap   *pBitmap   =   new   Graphics::TBitmap();  
      TImage   *image   =   new   TImage(this);  
   
      try  
      {  
          image->AutoSize   =   true;  
          image->Picture->LoadFromFile("your_file");  
          pBitmap->Assign(image->Picture);  
   
          int   border   =   100;   //pixels  
          int   width,height;  
          TPrinter   *Prntr   =   Printer();  
          TRect   rect   =   Rect(border,border,Prntr->PageWidth   -   border,Prntr->PageHeight   -   border);  
   
          Prntr->BeginDoc();  
          for   (int   x=0;   x<image->Picture->Width;   x   +=   rect.Width())  
          {  
              for   (int   y=0;   y<image->Picture->Height;   y   +=   rect.Height())  
              {  
                  width   =   (x   +   rect.Width()<image->Picture->Width)   ?   rect.Width()   :   image->Picture->Width   -   x;  
                  height   =   (y   +   rect.Height()<image->Picture->Height)   ?   rect.Height()   :   image->Picture->Height   -   y;  
                  BitBlt(Prntr->Canvas->Handle,rect.Left,rect.Top,width,height,pBitmap->Canvas->Handle,x,y,SRCCOPY);  
                  Prntr->NewPage();  
              }  
          }  
          Prntr->EndDoc();  
      }  
      catch(...)  
      {  
          ShowMessage("Cann't   load   image   file");  
      }  
      delete   pBitmap;  
      delete   image;  
  帮你搜的Top

3 楼NetSpider9804040(网络蛛蛛)回复于 2005-04-04 17:45:54 得分 5

学习!Top

4 楼tompkins2000(AirHunter)回复于 2005-04-05 09:37:15 得分 0

多谢楼上各位~~  
  最好是用API。我想看看API打印是怎么做的~~上面的代码也不错~~收藏ing  
  Top

相关问题

  • 寻求API函数库的电子文档
  • OPENGL的API及扩展函数的文档
  • 小声的问一下:Windows api函数那里有说明文档?
  • api函数
  • 求API函数?
  • API函数
  • API函数
  • API 函数!
  • api函数求教
  • api函数问题?

关键词

  • 打印
  • api
  • prntr
  • rect
  • pbitmap
  • picture
  • height
  • image
  • width
  • border

得分解答快速导航

  • 帖主:tompkins2000
  • Raptor
  • constantine
  • NetSpider9804040

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo