English 中文(简体)
将增强型图元文件转换为Windows图元文件而不进行像素舍入的正确方法
原标题:Proper way to convert an Enhanced Metafile to a Windows Metafile without pixel rounding

当我将增强型元文件(通过C#中的GDI+构建)转换为老式的Windows元文件时,结果非常粗糙,显然是因为坐标被四舍五入到了最近的屏幕像素。如果我通过

GetWinMetaFileBits(emph、bits_l、bits、MM_ANISOTROPIC、GetDC(0));

或使用GDI+的Metafile::EmfToWmfBits。罪魁祸首可能是正在使用的屏幕DC这篇文章建议使用打印机DC,这对我来说很有效,但如果用户没有安装打印机,显然就不起作用。有更好的方法吗?我曾考虑过为此创建一个高分辨率的内存DC,但我找不到合适的文档,我还担心使用的RAM。

问题回答

通常的方法是创建一个分辨率高得多的内存DC,渲染到该DC,然后根据需要保存。请注意,字体大小可能会因此而变得一团糟。

 HDC memDC = CreateCompatibleDC ( hDC );
 HBITMAP memBM = CreateCompatibleBitmap ( hDC, nWidth, nHeight );
 SelectObject ( memDC, memBM );

With nWidth , nHeight much larger.
The CreateCompatible bit should set all the dpi etc, but I have had problems where the fonts were drawn fixed pixel size rather than rescaled - so they ended up being only 10pixels high on a 10,000 pixel image

向谷歌索取ENMETA.EXE

Microsoft说明

下载中包含示例。





相关问题
How to read exact number of bytes from a stream (tcp) socket?

In winsock, both the sync recv and the async WSARecv complete as soon as there is data available in a stream socket, regardless of the size specified (which is only the upper limit). This means that ...

AcquireCredentialsHandle returns SEC_E_NO_CREDENTIALS

I created a self-signed certificate (created using OpenSSL) and installed it into the Certificate Store using the Certificates MMC snap-in (CertMgr.msc) on Windows Vista Ultimate. I have managed to ...

Calling Win32 EnumThreadWindows() in C#

I m trying to get a call to EnumThreadWindows working, but I always get a Wrong Parameter-Error, although my code is nearly the same as this example on pinvoke.net. I don t know why this doesn t work: ...

COM Basic links

folks can you provide me the tutorial link or .pdf for learning basic COM?. i do google it.. still i recommend answers of stackoverflow so please pass me.. Thanks

Handling multiple windows WIN32 API

HI I m trying to create an application in the Win32 environment containing more than one window. How do i do that? all the Win32 Tutorials on web i found only showed how to manage one window. How do i ...

Creating a thread in DllMain?

It seems that when a thread is created from within DllMain upon DLL_PROCESS_ATTACH it won t begin until all dll s have been loaded. Since I need to make sure the thread runs before I continue, I get a ...

热门标签