〉》》》》怎样取得打印机分辨率?《〈〈〈〈

dancetime 2002-05-03 05:33:40
我想取得打印机所有的分辨率,就是显示出150dpi、300dpi、600dpi那样的,该怎么做?
...全文
247 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
dancetime 2002-05-06
  • 打赏
  • 举报
回复
还是没有人~~
dancetime 2002-05-06
  • 打赏
  • 举报
回复
过了5。1来还没有人搞定它呀?
King_Cpp 2002-05-06
  • 打赏
  • 举报
回复
//你可以这样:
try this:
int dpi = GetDeviceCaps(hdc, LOGPIXELSX);

int dpi=pDC->GetDeviceCaps(LOGPIXELSX);

//说明信息:/*
HORZSIZE 物理显示宽度(以毫米为单位)
VERTSIZE 物理显示高度(以毫米为单位)
HORZRES 显示宽度(用像素表示)
VERTRES 显示高度(用光栅线表示)
LOGPIXELSX 沿显示宽度方向,每一逻辑单位的像素数。
LOGPIXELSY 沿显示高度方向,每一逻辑单位的像素数
*/
ilovedjl 2002-05-06
  • 打赏
  • 举报
回复
听课~~
dancetime 2002-05-03
  • 打赏
  • 举报
回复
用GetDeviceCaps只能取得当前打印机使用的分辨率,而不能取得此打印机所有支持的分辨率呀。我想要的是得到打印机所支持的全部分辨率。
hnyyy 2002-05-03
  • 打赏
  • 举报
回复
int dpi=pDC->GetDeviceCaps(LOGPIXELSX);

HORZSIZE 物理显示宽度(以毫米为单位)
VERTSIZE 物理显示高度(以毫米为单位)
HORZRES 显示宽度(用像素表示)
VERTRES 显示高度(用光栅线表示)
LOGPIXELSX 沿显示宽度方向,每一逻辑单位的像素数。
LOGPIXELSY 沿显示高度方向,每一逻辑单位的像素数
masterz 2002-05-03
  • 打赏
  • 举报
回复
try this:
int dpi = GetDeviceCaps(hdc, LOGPIXELSX);
dancetime 2002-05-03
  • 打赏
  • 举报
回复
请不要把msdn上的东东原封不动的贴过来好不好啊,至少要解释一下呀。
dancetime 2002-05-03
  • 打赏
  • 举报
回复
是要用GetDevicesCaps还是要用DeviceCapabilities?我用的是DeviceCapabilities,但是在output中的值怎么才能转换成 xxxdpi的形式呢?
shawn_liu 2002-05-03
  • 打赏
  • 举报
回复
SHADEBLENDCAPS Windows 98, Windows 2000: Value that indicates the shading and blending capabilities of the device.
SB_CONST_ALPHA Handles the SourceConstantAlpha member of the BLENDFUNCTION structure, which is referenced by the blendFunction parameter of the AlphaBlend function.
SB_GRAD_RECT Capable of doing GradientFill rectangles.
SB_GRAD_TRI Capable of doing GradientFill triangles.
SB_NONE Device does not support any of these capabilities.
SB_PIXEL_ALPHA Capable of handling per-pixel alpha in AlphaBlend.
SB_PREMULT_ALPHA Capable of handling premultiplied alpha in AlphaBlend.
RASTERCAPS Value that indicates the raster capabilities of the device, as shown in the following table.
RC_BANDING Requires banding support.
RC_BITBLT Capable of transferring bitmaps.
RC_BITMAP64 Capable of supporting bitmaps larger than 64 KB.
RC_DI_BITMAP Capable of supporting the SetDIBits and GetDIBits functions.
RC_DIBTODEV Capable of supporting the SetDIBitsToDevice function.
RC_FLOODFILL Capable of performing flood fills.
RC_GDI20_OUTPUT Capable of supporting features of 16-bit Windows 2.0.
RC_PALETTE Specifies a palette-based device.
RC_SCALING Capable of scaling.
RC_STRETCHBLT Capable of performing the StretchBlt function.
RC_STRETCHDIB Capable of performing the StretchDIBits function.
CURVECAPS Value that indicates the curve capabilities of the device, as shown in the following table:
CC_NONE Device does not support curves.
CC_CHORD Device can draw chord arcs.
CC_CIRCLES Device can draw circles.
CC_ELLIPSES Device can draw ellipses.
CC_INTERIORS Device can draw interiors.
CC_PIE Device can draw pie wedges.
CC_ROUNDRECT Device can draw rounded rectangles.
CC_STYLED Device can draw styled borders.
CC_WIDE Device can draw wide borders.
CC_WIDESTYLED Device can draw borders that are wide and styled.
LINECAPS Value that indicates the line capabilities of the device, as shown in the following table:
LC_NONE Device does not support lines.
LC_INTERIORS Device can draw interiors.
LC_MARKER Device can draw a marker.
LC_POLYLINE Device can draw a polyline.
LC_POLYMARKER Device can draw multiple markers.
LC_STYLED Device can draw styled lines.
LC_WIDE Device can draw wide lines.
LC_WIDESTYLED Device can draw lines that are wide and styled.
POLYGONALCAPS Value that indicates the polygon capabilities of the device, as shown in the following table.
PC_NONE Device does not support polygons.
PC_INTERIORS Device can draw interiors.
PC_POLYGON Device can draw alternate-fill polygons.
PC_RECTANGLE Device can draw rectangles.
PC_SCANLINE Device can draw a single scanline.
PC_STYLED Device can draw styled borders.
PC_WIDE Device can draw wide borders.
PC_WIDESTYLED Device can draw borders that are wide and styled.
PC_WINDPOLYGON Device can draw winding-fill polygons.
TEXTCAPS Value that indicates the text capabilities of the device, as shown in the following table.
TC_OP_CHARACTER Device is capable of character output precision.
TC_OP_STROKE Device is capable of stroke output precision.
TC_CP_STROKE Device is capable of stroke clip precision.
TC_CR_90 Device is capable of 90-degree character rotation.
TC_CR_ANY Device is capable of any character rotation.
TC_SF_X_YINDEP Device can scale independently in the x- and y-directions.
TC_SA_DOUBLE Device is capable of doubled character for scaling.
TC_SA_INTEGER Device uses integer multiples only for character scaling.
TC_SA_CONTIN Device uses any multiples for exact character scaling.
TC_EA_DOUBLE Device can draw double-weight characters.
TC_IA_ABLE Device can italicize.
TC_UA_ABLE Device can underline.
TC_SO_ABLE Device can draw strikeouts.
TC_RA_ABLE Device can draw raster fonts.
TC_VA_ABLE Device can draw vector fonts.
TC_RESERVED Reserved; must be zero.
TC_SCROLLBLT Device cannot scroll using a bit-block transfer. Note that this meaning may be the opposite of what you expect.
COLORMGMTCAPS Windows 2000: Value that indicates the color management capabilities of the device.
CM_CMYK_COLOR Device can accept CMYK color space ICC color profile.
CM_DEVICE_ICM Device can perform ICM on either the device driver or the device itself.
CM_GAMMA_RAMP Device supports GetDeviceGammaRamp and SetDeviceGammaRamp
CM_NONE Device does not support ICM.


Return Values
The return value specifies the value of the desired item.

When nIndex is BITSPIXEL and the device has 15bpp or 16bpp, the return value is 16.

Remarks
GetDeviceCaps provides the following six indexes in place of printer escapes.

Index Printer escape replaced
PHYSICALWIDTH GETPHYSPAGESIZE
PHYSICALHEIGHT GETPHYSPAGESIZE
PHYSICALOFFSETX GETPRINTINGOFFSET
PHYSICALOFFSETY GETPHYSICALOFFSET
SCALINGFACTORX GETSCALINGFACTOR
SCALINGFACTORY GETSCALINGFACTOR


Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Gdi32.lib.

shawn_liu 2002-05-03
  • 打赏
  • 举报
回复
GetDeviceCaps
The GetDeviceCaps function retrieves device-specific information for the specified device.

int GetDeviceCaps(
HDC hdc, // handle to DC
int nIndex // index of capability
);
Parameters
hdc
[in] Handle to the DC.
nIndex
[in] Specifies the item to return. This parameter can be one of the following values. Index Meaning
DRIVERVERSION The device driver version.
TECHNOLOGY Device technology. It can be any one of the following values.
DT_PLOTTER Vector plotter
DT_RASDISPLAY Raster display
DT_RASPRINTER Raster printer
DT_RASCAMERA Raster camera
DT_CHARSTREAM Character stream
DT_METAFILE Metafile
DT_DISPFILE Display file
If the hdc parameter is a handle to the DC of an enhanced metafile, the device technology is that of the referenced device as specified to the CreateEnhMetaFile function. To determine whether it is an enhanced metafile DC, use the GetObjectType function.
HORZSIZE Width, in millimeters, of the physical screen.
VERTSIZE Height, in millimeters, of the physical screen.
HORZRES Width, in pixels, of the screen.
VERTRES Height, in raster lines, of the screen.
LOGPIXELSX Number of pixels per logical inch along the screen width. In a system with multiple display monitors, this value is the same for all monitors.
LOGPIXELSY Number of pixels per logical inch along the screen height. In a system with multiple display monitors, this value is the same for all monitors.
BITSPIXEL Number of adjacent color bits for each pixel.
PLANES Number of color planes.
NUMBRUSHES Number of device-specific brushes.
NUMPENS Number of device-specific pens.
NUMFONTS Number of device-specific fonts.
NUMCOLORS Number of entries in the device's color table, if the device has a color depth of no more than 8 bits per pixel. For devices with greater color depths, – 1 is returned.
ASPECTX Relative width of a device pixel used for line drawing.
ASPECTY Relative height of a device pixel used for line drawing.
ASPECTXY Diagonal width of the device pixel used for line drawing.
PDEVICESIZE Reserved.
CLIPCAPS Flag that indicates the clipping capabilities of the device. If the device can clip to a rectangle, it is 1. Otherwise, it is 0.
SIZEPALETTE Number of entries in the system palette. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with 16-bit Windows.
NUMRESERVED Number of reserved entries in the system palette. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with 16-bit Windows.
COLORRES Actual color resolution of the device, in bits per pixel. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with 16-bit Windows.
PHYSICALWIDTH For printing devices: the width of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5-x11-inch paper has a physical width value of 5100 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller.
PHYSICALHEIGHT For printing devices: the height of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5-by-11-inch paper has a physical height value of 6600 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller.
PHYSICALOFFSETX For printing devices: the distance from the left edge of the physical page to the left edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5-by-11-inch paper, that cannot print on the leftmost 0.25-inch of paper, has a horizontal physical offset of 150 device units.
PHYSICALOFFSETY For printing devices: the distance from the top edge of the physical page to the top edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5-by-11-inch paper, that cannot print on the topmost 0.5-inch of paper, has a vertical physical offset of 300 device units.
VREFRESH Windows NT/2000: For display devices: the current vertical refresh rate of the device, in cycles per second (Hz).
A vertical refresh rate value of 0 or 1 represents the display hardware's default refresh rate. This default rate is typically set by switches on a display card or computer motherboard, or by a configuration program that does not use Win32 display functions such as ChangeDisplaySettings.

SCALINGFACTORX Scaling factor for the x-axis of the printer.
SCALINGFACTORY Scaling factor for the y-axis of the printer.
BLTALIGNMENT Windows NT/2000: Preferred horizontal drawing alignment, expressed as a multiple of pixels. For best drawing performance, windows should be horizontally aligned to a multiple of this value. A value of zero indicates that the device is accelerated, and any alignment may be used.

16,473

社区成员

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

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

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