gdi+ 打印的问题,尺寸不对。

ljn2 2004-04-08 11:24:38
我的打印机在A4上是(像素:4800,6800,毫米210,288),
不知gdi+使用的是哪种单位,画了个0,0,100,100的框,打印到A4纸上一看,
如果说是像素,那么明显大于了100,100的范围,如果说是1/10毫米,又明显太小.
那位打过,给个提示啊
...全文
433 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
ljn2 2004-04-12
  • 打赏
  • 举报
回复
OK 搞定了谢谢大家
Boll 2004-04-12
  • 打赏
  • 举报
回复
The Unit enumeration specifies the unit of measure for a given data type.

Syntax

typedef enum {
UnitWorld = 0,
UnitDisplay = 1,//1/96英寸
UnitPixel = 2, //1像素
UnitPoint = 3,//1/72英寸
UnitInch = 4,
UnitDocument = 5,//1/300英寸
UnitMillimeter = 6//1mm
} Unit;

Constants

UnitWorld
Specifies world coordinates, a nonphysical unit.

UnitDisplay
Specifies display units. For example, if the display device is a monitor, then the unit is 1 pixel.

UnitPixel
Specifies that a unit is 1 pixel.

UnitPoint
Specifies that a unit is 1 point or 1/72 inch.

UnitInch
Specifies that a unit is 1 inch.

UnitDocument
Specifies that a unit is 1/300 inch.

UnitMillimeter
Specifies that a unit is 1 millimeter.

是啊,你用SetPageUnit设置坐标计量单位是对的
ljn2 2004-04-11
  • 打赏
  • 举报
回复
封杀并不是问题的关键,大家不用老是盯着不放

SetMapMode是gdi函数,gdi+里不管用。估计得用SetPageUnit
mynameisno1 2004-04-11
  • 打赏
  • 举报
回复
什么叫被封杀?

映射模式设了吗
SetMapMode()
ljn2 2004-04-11
  • 打赏
  • 举报
回复
谢谢geniusage(),我再试试.

to zhangcrony,我还健在.
smallbull 2004-04-10
  • 打赏
  • 举报
回复
关注
geniusage 2004-04-10
  • 打赏
  • 举报
回复
为什么被封杀呢
geniusage 2004-04-10
  • 打赏
  • 举报
回复
就是说你传的(200, 500) ,(200, 150)是世界坐标,gdi+做了两次转换,
world->page->device
zhangcrony 2004-04-10
  • 打赏
  • 举报
回复
楼主被封杀,大家不要回了
geniusage 2004-04-10
  • 打赏
  • 举报
回复
GDI+用World Transformation(世界坐标),page Transformation 和device Transformation 三种坐标。你画的是用像素,画出来的大小,根据你
的设备的dpi,就是//REAL dpiX = graphics.GetDpiX();
//REAL dpiY = graphics.GetDpiY();
你可以算出大小来,如果是96,就是37.795像素/厘米,

那377.95像素就是10厘米
ljn2 2004-04-09
  • 打赏
  • 举报
回复
#include "stdafx.h"
#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;

INT main()
{
// Initialize GDI+.
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

DOCINFO docInfo;
ZeroMemory(&docInfo, sizeof(DOCINFO));
docInfo.cbSize = sizeof(DOCINFO);
docInfo.lpszDocName = "GdiplusPrint";

// Create a PRINTDLG structure, and initialize the appropriate fields.
PRINTDLG printDlg;
ZeroMemory(&printDlg, sizeof(PRINTDLG));
printDlg.lStructSize = sizeof(PRINTDLG);
printDlg.Flags = PD_RETURNDC;

// Display a print dialog box.
if(!PrintDlg(&printDlg))
{
printf("Failure\n");
}
else
{
// Now that PrintDlg has returned, a device context handle
// for the chosen printer is in printDlg->hDC.

StartDoc(printDlg.hDC, &docInfo);
StartPage(printDlg.hDC);
Graphics* graphics = new Graphics(printDlg.hDC);
Pen* pen = new Pen(Color(255, 0, 0, 0));
graphics->DrawRectangle(pen, 200, 500, 200, 150);
graphics->DrawEllipse(pen, 200, 500, 200, 150);
graphics->DrawLine(pen, 200, 500, 400, 650);
delete pen;
delete graphics;
EndPage(printDlg.hDC);
EndDoc(printDlg.hDC);
}

if(printDlg.hDevMode)
GlobalFree(printDlg.hDevMode);
if(printDlg.hDevNames)
GlobalFree(printDlg.hDevNames);
if(printDlg.hDC)
DeleteDC(printDlg.hDC);

GdiplusShutdown(gdiplusToken);
return 0;

}
abrams 2004-04-09
  • 打赏
  • 举报
回复
把你代码贴出来
ljn2 2004-04-09
  • 打赏
  • 举报
回复
up
ljn2 2004-04-09
  • 打赏
  • 举报
回复
up

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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