打印Canvas中图像的尺寸换算问题

SCUM 2003-11-07 07:46:22
一段打印Canvas中图像的代码:

TPrinter * prn = Printer();
HDC dc_cav = Canvas->Handle;
HDC dc_prn = prn->Handle;
prn->BeginDoc();
BitBlt( dc_prn, 0, 0, 100, 100, dc_cav, 0, 0, SRCCOPY );
prn->EndDoc();
.....

其中的数值只是测试用

不过有如下问题:
打印出的图像比屏幕上的原图小了许多
不知道该怎样换算尺寸

...全文
92 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
shadowstar 2004-03-21
  • 打赏
  • 举报
回复
收藏!
kataboy 2004-03-21
  • 打赏
  • 举报
回复
收藏!
jEditor 2003-11-10
  • 打赏
  • 举报
回复
// AcDraw:要输出的图像[打印机Cancvas].
// AbitCopy:要打印的图像.
void __fastcall StretchBitMap(TCanvas *AcDraw, int X,
int Y, int AiWid, int AiHei, Graphics::TBitmap *AbitCopy)
{
BYTE *pbitHeader;
unsigned int ihedSize = 0;
unsigned int iimgSize = 0;
unsigned char *pbitArry;
GetDIBSizes(AbitCopy->Handle,
ihedSize,
iimgSize);
pbitHeader = new BYTE[ihedSize];
pbitArry = new unsigned char[iimgSize];
GetDIB(AbitCopy->Handle,
AbitCopy->Handle,
pbitHeader,
pbitArry);
int iRetValue = StretchDIBits(AcDraw->Handle,
X, Y, AiWid,
AiHei, 0, 0,
AbitCopy->Width,
AbitCopy->Height,
pbitArry,
(BITMAPINFO*)pbitHeader,
DIB_PAL_COLORS,
SRCCOPY);
if(iRetValue <= 0)
ShowMessage(SysErrorMessage(GetLastError()));
delete []pbitHeader;
delete []pbitArry;
}
//------------------------------------------------------------------------------
用StretchDraw可以,但是在碰到某些驱动的时候就会出现问题。
用这个函数,构造颜色的全部,保证好.
xabcxyz 2003-11-07
  • 打赏
  • 举报
回复
帮你up一下

不过既然BitBlt是原大小拷贝,那么自己先定义一个TBitmap调整一下大小再BitBlt不行吗?用:void __fastcall StretchDraw(const TRect &Rect, TGraphic* Graphic);


BOOL BitBlt(
HDC hdcDest, // handle to destination device context
int nXDest, // x-coordinate of destination rectangle's upper-left corner
int nYDest, // y-coordinate of destination rectangle's upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle to source device context
int nXSrc, // x-coordinate of source rectangle's upper-left corner
int nYSrc, // y-coordinate of source rectangle's upper-left corner
DWORD dwRop // raster operation code
);

13,822

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧