浅析如何用C#.NET做屏幕截图软件以及注册全局快捷键(上)
2010-09-30 22:42:43 来源:WEB开发网通过上面代码可知,类库里面最后调用的是windows 的API :BitBlt(),这就是我们要说的第二种方法。
2、平台调用,即调用windows的API函数。其中要用到的最主要的就是BitBlt()。在此,本人先给各位推荐个网站,它就是:www.pinvoke.net,一个包含几乎所有API的wiki,里面一般还含有示例代码~为了便于没有网络的情况下查询,本人已经把该网站拷贝下来了。。耗费了一天时间做成CHM。。。
先来看看BitBlt()的description:The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.
这里,我们只关心它的最后一个参数/// <param name="dwRop">A raster-operation code.</param>
中文翻译大概叫作:光栅操作码。大概就是控制从source device context 到 destination device context的拷贝方式。它是一个DWORD类型,取值在
// Summary:
// Determines how the source color in a copy pixel operation is combined with
// the destination color to result in a final color.
public enum CopyPixelOperation
{
// Summary:
// The bitmap is not mirrored.
NoMirrorBitmap = -2147483648,
//
// Summary:
// The destination area is filled by using the color associated with index 0
// in the physical palette. (This color is black for the default physical palette.)
Blackness = 66,
//
// Summary:
// The source and destination colors are combined using the Boolean OR operator,
// and then resultant color is then inverted.
NotSourceErase = 1114278,
//
// Summary:
// The inverted source area is copied to the destination.
NotSourceCopy = 3342344,
//
// Summary:
// The inverted colors of the destination area are combined with the colors
// of the source area using the Boolean AND operator.
SourceErase = 4457256,
//
// Summary:
// The destination area is inverted.
DestinationInvert = 5570569,
//
// Summary:
// The colors of the brush currently selected in the destination device context
// are combined with the colors of the destination are using the Boolean XOR
// operator.
PatInvert = 5898313,
//
// Summary:
// The colors of the source and destination areas are combined using the Boolean
// XOR operator.
SourceInvert = 6684742,
//
// Summary:
// The colors of the source and destination areas are combined using the Boolean
// AND operator.
SourceAnd = 8913094,
//
// Summary:
// The colors of the inverted source area are merged with the colors of the
// destination area by using the Boolean OR operator.
MergePaint = 12255782,
//
// Summary:
// The colors of the source area are merged with the colors of the selected
// brush of the destination device context using the Boolean AND operator.
MergeCopy = 12583114,
//
// Summary:
// The source area is copied directly to the destination area.
SourceCopy = 13369376,
//
// Summary:
// The colors of the source and destination areas are combined using the Boolean
// OR operator.
SourcePaint = 15597702,
//
// Summary:
// The brush currently selected in the destination device context is copied
// to the destination bitmap.
PatCopy = 15728673,
//
// Summary:
// The colors of the brush currently selected in the destination device context
// are combined with the colors of the inverted source area using the Boolean
// OR operator. The result of this operation is combined with the colors of
// the destination area using the Boolean OR operator.
PatPaint = 16452105,
//
// Summary:
// The destination area is filled by using the color associated with index 1
// in the physical palette. (This color is white for the default physical palette.)
Whiteness = 16711778,
//
// Summary:
// Windows that are layered on top of your window are included in the resulting
// image. By default, the image contains only your window. Note that this generally
// cannot be used for printing device contexts.
CaptureBlt = 1073741824,
}
更多精彩
赞助商链接