Printing Tips and Tricks

甲骨文数字化:两阶段GAN数据增强技术解析 在文化遗产数字化领域,生成对抗网络(GAN)已成为解决小样本问题的关键技术。通过纹理-结构解耦的神经网络设计,能够有效保留甲骨文的裂纹特征与字形结构,其核心在于多尺度特征提取与动态权重调节机制。这种技术不仅显著提升文物数字化的保真度(FID指标降低至19.5),更在OCR识别、断代分析等下游任务中实现30%以上的性能提升。针对甲骨文这类特殊文字,两阶段训练策略结合文化合规性校验,既解决了传统数据增强导致的语义失真问题,又满足了考古研究的学术规范要求,为其他濒危文字保护提供了可复用的技术框架。 阅读详情

Printing Tips and Tricks

By Sam Thai 2000-3-20

Here are a few tips, tricks, and answers to frequently asked questions to help you write better printing code and resolve problems that aren't addressed in this chapter's sample programs.

Using the Print Dialog's Selection Button
The Print dialog that MFC displays before printing begins includes a Selection radio button that the user can click to print the current selection rather than the entire document or a range of pages. By default, the button is disabled. You can enable it by adding the following statement to OnPreparePrinting just before the call to DoPreparePrinting:

pInfo->m_pPD->m_pd.Flags &= ~PD_NOSELECTION;
 


To select the radio button after it's enabled, add this statement as well:

pInfo->m_pPD->m_pd.Flags ¦= PD_SELECTION;
 


The m_pPD data member of the CPrintInfo structure passed to OnPreparePrinting points to the CPrintDialog object that DoPreparePrinting uses to display the Print dialog box. CPrintDialog::m_pd holds a reference to the PRINTDLG structure the dialog is based on, and PRINTDLG's Flags field holds bit flags that define the dialog box's properties. Removing the PD_NOSELECTION flag added by CPrintInfo's constructor enables the Selection button, and adding a PD_SELECTION flag selects the button. If DoPreparePrinting returns a nonzero value, indicating that the dialog was dismissed with the OK button, you can find out whether the Selection button was selected by calling CPrintDialog::PrintSelection. A nonzero return value means the button was selected; 0 means it wasn't:

if (pInfo->m_pPD->PrintSelection ()) {    // Print the current selection.}
 


You can call PrintSelection and other CPrintDialog functions that return information about settings entered in a Print or Print Setup dialog through the pInfo parameter passed to OnPreparePrinting after DoPreparePrinting returns. You can also call them through the pInfo parameter passed to OnBeginPrinting and other CView print overridables.

You can use CPrintInfo::m_pPD in other ways to modify the appearance and behavior of the Print dialog that DoPreparePrinting displays. Refer to the documentation that accompanies Visual C++ for more information about PRINTDLG and its data members.

Assume Nothing—And Test Thoroughly!
When you send output to the printed page, it's generally a mistake to assume anything about the printable area of the pages you'll be printing. Even if you know you're printing to, say, an 8½-by-11-inch page, the printable page area will differ for different printers. The printable page area can even differ for the same printer and the same paper size depending on which printer driver is being used, and the horizontal and vertical dimensions of the printable page area will be switched if the user opts to print in landscape rather than portrait mode. Rather than assume you have a given amount of space to work with, do as HexDump does and call GetDeviceCaps through the CDC pointer provided to CView print functions to determine the printable page area each time you print, or use CPrintInfo::m_rectDraw in your OnPrint function. This simple precaution will enable your printing code to work with any printer Windows can throw at it and will greatly reduce the number of problem reports you receive from users.

As you've already learned, calling GetDeviceCaps with HORZRES and VERTRES parameters returns the horizontal and vertical dimensions of the printable page area. You can pass the following values to GetDeviceCaps to get more information about a printer or other hardcopy device:

Value Description
HORZRES Returns the width of the printable page area in pixels.
VERTRES Returns the height of the printable page area in pixels.
HORSIZE Returns the width of the printable page area in millimeters.
VERTSIZE Returns the height of the printable page area in millimeters.
LOGPIXELSX Returns the number of pixels per inch in the horizontal direction (300 for a 300-dpi printer).
LOGPIXELSY Returns the number of pixels per inch in the vertical direction (300 for a 300-dpi printer).
PHYSICALWIDTH Returns the page width in pixels (2,550 for an 8½-by-11-inch page on a 300-dpi printer).
PHYSICALHEIGHT Returns the page height in pixels (3,300 for an 8½-by-11-inch page on a 300-dpi printer).
PHYSICALOFFSETX Returns the distance in pixels from the left side of the page to the beginning of the page's printable area.
PHYSICALOFFSETY Returns the distance in pixels from the top of the page to the beginning of the page's printable area.
TECHNOLOGY Returns a value that identifies the type of output device the DC pertains to. The most common return values are DT_RASDISPLAY for screens, DT_RASPRINTER for printers, and DT_PLOTTER for plotters.
RASTERCAPS Returns a series of bit flags identifying the level of GDI support provided by the printer driver. For example, an RC_BITBLT flag indicates that the printer supports BitBlts, and RC_STRETCHBLT indicates that the printer supports StretchBlts.
NUMCOLORS Returns the number of colors the printer supports. The return value is 2 for black-and-white printers.


You've already seen one use for the GetDeviceCaps NUMCOLORS parameter: to detect when a black-and-white printer is being used so that you draw print previews in shades of gray. The PHYSICALOFFSETX and PHYSICALOFFSETY parameters are useful for setting margin widths based on information the user enters in a Page Setup dialog. (MFC's CWinApp::OnFilePrintSetup function displays a Print Setup dialog instead of a Page Setup dialog, but you can display a Page Setup dialog yourself using MFC's CPageSetupDialog class.) If the user wants 1-inch margins on the left side of the page, for example, you can subtract the PHYSICALOFFSETX value returned by GetDeviceCaps from the number of pixels printed per inch (LOGPIXELSX) to compute the x offset from the left of the printable page area where printing should begin. If the printer driver returns accurate information, the resulting margin will fall within a few pixels of being exactly 1 inch. You can use the HORZRES, VERTRES, LOGPIXELSX, LOGPIXELSY, PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, and PHYSICALOFFSETY values to characterize the printable area of a page and pinpoint exactly where on the page the printable area lies.

If you're concerned about the occasional hardcopy device that won't draw bitmaps, you can find out whether CDC::BitBlt and CDC::StretchBlt are supported by calling GetDeviceCaps with a RASTERCAPS parameter and checking the return flags. For the most part, only vector devices such as plotters don't support the GDI's Blt functions. If the driver for a raster device doesn't support blitting directly, the GDI will compensate by doing the blitting itself. You can determine outright whether printed output is destined for a plotter by calling GetDeviceCaps with a TECHNOLOGY parameter and checking to see if the return value equals DT_PLOTTER.

When you use a number of different printers to test an application that prints, you'll find that printer drivers are maddeningly inconsistent in the information they report and the output they produce. For example, some printer drivers return the same values for PHYSICALWIDTH and PHYSICALHEIGHT as they return for HORZRES and VERTRES. And sometimes an ordinary GDI function such as CDC::TextOut will work fine on hundreds of printers but will fail on one particular model because of a driver bug. Other times, a GDI function won't fail outright but will behave differently on different printers. I once ran across a printer driver that defaulted to the TRANSPARENT background mode even though other drivers for the same family of printers correctly set the device context's default background mode to OPAQUE. Printer drivers are notoriously flaky, so you need to anticipate problems and test as thoroughly as you can on as many printers as possible. The more ambitious your program's printing needs, the more likely that driver quirks will require you to write workarounds for problems that crop up only on certain printers.

Adding Default Pagination Support
HexDump calls CPrintInfo::SetMaxPage from OnBeginPrinting rather than from OnPreparePrinting because the pagination process relies on the printable page area and OnBeginPrinting is the first virtual CView function that's called with a pointer to a printer DC. Because the maximum page number isn't set until after OnPreparePrinting returns, the From box in the Print dialog is filled in (with a 1) but the To box isn't. Some users might think it incongruous that an application can correctly paginate a document for print preview but can't fill in the maximum page number in a dialog box. In addition to displaying the maximum page number correctly, many commercial applications display page breaks outside print preview and "Page mm of nn" strings in status bars. How do these applications know how the document will be paginated when they don't know what printer the document will be printed on or what the page orientation will be?

The answer is that they don't know for sure, so they make their best guess based on the properties of the default printer. The following code snippet initializes a CSize object with the pixel dimensions of the printable page area on the default printer or the last printer that the user selected in Print Setup. You can call it from OnPreparePrinting or elsewhere to compute a page count or to get the information you need to provide other forms of default pagination support:

CSize size;CPrintInfo pi;if (AfxGetApp ()->GetPrinterDeviceDefaults (&pi.m_pPD->m_pd)) {    HDC hDC = pi.m_pPD->m_pd.hDC;    if (hDC == NULL)        hDC = pi.m_pPD->CreatePrinterDC ();    if (hDC != NULL) {        CDC dc;        dc.Attach (hDC);        size.cx = dc.GetDeviceCaps (VERTRES);        size.cy = dc.GetDeviceCaps (HORZRES);        ::DeleteDC (dc.Detach ());    }}
 


CWinApp::GetPrinterDeviceDefaults initializes a PRINTDLG structure with values describing the default printing configuration. A 0 return means that the function failed, which usually indicates that no printers are installed or that a default printer hasn't been designated. CPrintInfo::CreatePrinterDC creates a device context handle from the information in the PRINTDLG structure encapsulated in a CPrintInfo object. With the device context in hand, it's a simple matter to wrap it in a CDC object and use CDC::GetDeviceCaps to measure the printable page area.

Enumerating Printers
Sometimes it's useful to be able to build a list of all the printers available so that the user can select a printer outside a Print or Print Setup dialog box. The following routine uses the Win32 ::EnumPrinters function to enumerate the printers currently installed and adds an entry for each to the combo box pointed to by pComboBox.

#include <winspool.h>    DWORD dwSize, dwPrinters;::EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 5,    NULL, 0, &dwSize, &dwPrinters); BYTE* pBuffer = new BYTE[dwSize];::EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 5,    pBuffer, dwSize, &dwSize, &dwPrinters); if (dwPrinters != 0) {    PRINTER_INFO_5* pPrnInfo = (PRINTER_INFO_5*) pBuffer;    for (UINT i=0; i<dwPrinters; i++) {        pComboBox->AddString (pPrnInfo->pPrinterName);        pPrnInfo++;    }}delete[] pBuffer;
 


The first call to ::EnumPrinters retrieves the amount of buffer space needed to hold an array of PRINTER_INFO_5 structures describing individual printers. The second call to ::EnumPrinters initializes the buffer pointed to by pBuffer with an array of PRINTER_INFO_5 structures. On return, dwPrinters holds a count of the printers enumerated (which equals the count of PRINTER_INFO_5 structures copied to the buffer), and each structure's pPrinterName field holds a pointer to a zero-delimited string containing the device name of the associated printer. Enumerating printers with PRINTER_INFO_5 structures is fast because no remote calls are required; all information needed to fill the buffer is obtained from the registry. For fast printer enumerations in Windows NT or Windows 2000, use PRINTER_INFO_4 structures instead.

If a printer is selected from the combo box and you want to create a device context for it, you can pass the device name copied from the PRINTER_INFO_5 structure to CDC::CreateDC as follows:

CString strPrinterName;int nIndex = pComboBox->GetCurSel ();pComboBox->GetLBText (nIndex, strPrinterName);CDC dc;dc.CreateDC (NULL, strPrinterName, NULL, NULL);
 


You can use the resulting CDC object just like the CDC objects whose addresses are passed to OnBeginPrinting and other CView print functions

西周BC994年世界历史地图矢量文件SHP格式.zip 本资源为《西周BC994年世界历史地图矢量文件SHP格式》压缩包,文件大小约 28.70 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。 立即下载

相关推荐

C盘爆满不想重装系统?一键把AppData隐藏文件夹“搬家”到D盘

前言:C盘红了,除了重装还能怎么办? 当系统盘空间捉襟见肘时,任何常规的清理方式往往都起不到太好的作用。有时候,对于不太懂电脑的朋友来说,面对满屏飘红的C盘总会感到茫然失措,但又实在不想(或不愿意)大动干戈去重装系统。 正所谓有因有果。其实,系统盘(以C盘为例)不断臃肿的罪魁祸首,除了常见的 temp临时文件夹、我的文档、下载目录之外,最隐晦、最占空间的其实是 C:\Users\用户名\AppData 目录下 Local 和 Roaming 这两个隐藏文件夹里的一些“吃空间大户”。 举几个典型的例子: Local 下:Programs(各种软件安装在这里)、Microsoft\Edge\User Data\Default(浏览器缓存)。 Roaming 下:tencent(微信、QQ的聊天记录和缓存)等。 我的文档下:存放微信、QQ文件的地方,以及一些以 . 开头的隐藏缓存文件夹。 当然,“我的文档”和“下载”等目录,大家可以通过右键属性 -> 位置 -> 移动到其它盘来解决。但 AppData 属于受保护的系统隐藏目录,直接剪切往往会引发软件报错。 因此,我制作了这个小工具,专门针对这些顽固文件夹进行“无损搬家”。

Printing Tips and Tricks (转)

Printing Tips and Tricks (转)[@more@]Printing tips and Tricks Here are a few tips, tricks, and answers to frequent...

csd3176的博客 129

西周BC934年世界历史地图矢量文件SHP格式.zip

本资源为《西周BC934年世界历史地图矢量文件SHP格式》压缩包,文件大小约 28.47 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

qradiant

我实在没有什么时间来整理好这个了,这一篇没有任何的技术含量,其实就是一些代码的描述罢了, 加之个人能力有限,理解不到家,有空再写清楚 关卡编辑器部分    关卡编辑器的代码分析, 在关卡编辑器开始时,使用mfc来初始化这个opengl这个驱动等等的处理 检测鼠标,键盘的输入,滑动等等 我自己自个划分的有 界面层 ,操作层,介质层 界面层 专门画显示界面的

tailiangliang的专栏 2068

西周BC995年世界历史地图矢量文件SHP格式.zip

本资源为《西周BC995年世界历史地图矢量文件SHP格式》压缩包,文件大小约 28.70 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

Delphi 13.2控件之unidsa-unigui-delphi-main.zip

Delphi 13.2控件之unidsa-unigui-delphi-main.zip

北京大学4位数英验证码

北京大学4位数英验证码

西周BC912年世界历史地图矢量文件SHP格式.zip

本资源为《西周BC912年世界历史地图矢量文件SHP格式》压缩包,文件大小约 28.58 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

智慧科技馆智能化及系统集成系统规划建设方案.docx

智慧科技馆智能化及系统集成系统规划建设方案.docx

行政服务中心综合政务基于AI大模型建设方案.docx

行政服务中心综合政务基于AI大模型建设方案.docx

齿轮与叶片抗疲劳之激光冲击强化工艺参数工艺设计.pdf

技术分享

【机器人路径规划】基于PSO算法的栅格地图路径优化模型:融合A星引导与障碍物膨胀的安全导航系统设计 项目介绍 Python实现基于粒子群算法(PSO)的栅格地图机器人路径规划(含模型描述及部分示例代码

内容概要:本文详细介绍了一个基于Python实现的粒子群算法(PSO)在栅格地图中进行机器人路径规划的完整项目。项目通过构建二维栅格地图,结合障碍物膨胀技术确保机器人安全边界,并采用A星算法生成初始引导路径,提升粒子群算法初始种群质量。粒子群算法对路径中间控制点进行优化,综合考虑路径长度、碰撞惩罚和转角平滑性,实现高效、安全、稳定的路径规划。系统支持多轮独立运行以避免早熟收敛,输出最优路径及收敛曲线,并通过Matplotlib实现结果可视化。项目结构清晰,具备良好的可扩展性,适用于多种机器人应用场景。; 适合人群:具备一定Python编程基础,熟悉NumPy、Matplotlib等库,对路径规划、智能优化算法(如PSO、A星)感兴趣的高校学生、科研人员及从事机器人导航系统开发的工程师(工作年限1-3年为宜)。; 使用场景及目标:①应用于仓储搬运、巡检、配送等移动机器人全局路径规划任务;②用于验证粒子群算法在组合优化与多目标约束下的性能表现;③作为课程设计、科研原型或工程预研的基础模块,支持接入SLAM地图、动态避障、控制器集成等扩展功能; 阅读建议:此资源不仅提供核心代码示例,还深入讲解模型设计思路与关键技术难点(如连续坐标与离散栅格的映射、路径平滑处理、适应度函数设计),建议读者结合代码逐模块调试运行,理解各层功能实现,并尝试调整参数或引入新评价指标以深化学习效果。

智慧展览馆智能化及系统集成系统规划建设方案.docx

智慧展览馆智能化及系统集成系统规划建设方案.docx

智能体工作流编排引擎与可视化低代码搭建平台详细设计方案.docx

智能体工作流编排引擎与可视化低代码搭建平台详细设计方案.docx

市十五五城市大脑2.0与全域数字孪生底座一体化升级工程详细设计方案.docx

市十五五城市大脑2.0与全域数字孪生底座一体化升级工程详细设计方案.docx

数字化艺术馆数智平台规划方案.docx

数字化艺术馆数智平台规划方案.docx

上一篇: 中国人写的编译器-值得看看
下一篇: 一步步Notepad变Word
普通网友
博客等级 码龄22年 1万+粉丝 3156原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址