SetPixel The SetPixel function sets the pixel at the specified coordinates to the specified color. COLORREF SetPixel( HDC hdc, // handle to DC int X, // x-coordinate of pixel int Y, // y-coordinate of pixel COLORREF crColor // pixel color ); Parameters hdc [in] Handle to the device context. X [in] Specifies the x-coordinate, in logical units, of the point to be set. Y [in] Specifies the y-coordinate, in logical units, of the point to be set. crColor [in] Specifies the color to be used to paint the point. To create a COLORREF color value, use the RGB macro. Return Values If the function succeeds, the return value is the RGB value that the function sets the pixel to. This value may differ from the color specified by crColor; that occurs when an exact match for the specified color cannot be found.
你是怎么算的?crColor是一个32位整形,对应VB6中的Long SetPixelV VB声明 Declare Function SetPixelV Lib "gdi32" Alias "SetPixelV" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long 说明 在指定的设备场景中设置一个像素的RGB值 返回值 Long,非零表示成功,零表示失败。会设置GetLastError 参数表 参数 类型及说明 hdc Long,一个设备场景的句柄 x,y Long,要设置的点,用逻辑坐标表示 crColor Long,指定像素的新RGB颜色值 注解 这个函数比SetPixel快一些,但不会返回设置的实际颜色。可用GetDeviceCaps判断设备是否支持这个函数
按你上邊的操作 用bitblt 是行不同的,因為bitblt是從內存中讀出圖形信息,然後復制到目標的
那我想想,我回家查查api 的書看有沒有,明天給你答復
The SetPixel function sets the pixel at the specified coordinates to the specified color. COLORREF SetPixel(
HDC hdc, // handle to DC
int X, // x-coordinate of pixel
int Y, // y-coordinate of pixel
COLORREF crColor // pixel color
);
Parameters
hdc
[in] Handle to the device context.
X
[in] Specifies the x-coordinate, in logical units, of the point to be set.
Y
[in] Specifies the y-coordinate, in logical units, of the point to be set.
crColor
[in] Specifies the color to be used to paint the point. To create a COLORREF color value, use the RGB macro.
Return Values
If the function succeeds, the return value is the RGB value that the function sets the pixel to. This value may differ from the color specified by crColor; that occurs when an exact match for the specified color cannot be found.
为什么crColor>32767时就会报错呀?
难道SetPixel只支持16位色?
有没有办法可以支持24位呀?
SetPixelV VB声明
Declare Function SetPixelV Lib "gdi32" Alias "SetPixelV" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
说明
在指定的设备场景中设置一个像素的RGB值
返回值
Long,非零表示成功,零表示失败。会设置GetLastError
参数表
参数 类型及说明
hdc Long,一个设备场景的句柄
x,y Long,要设置的点,用逻辑坐标表示
crColor Long,指定像素的新RGB颜色值
注解
这个函数比SetPixel快一些,但不会返回设置的实际颜色。可用GetDeviceCaps判断设备是否支持这个函数
SetPixelV hDC, x, y, RGB(R, G, B)
这比SetPixelV快100倍以上
我写的快速的图像处理程序:http://www.csdn.net/expert/topic/879/879364.xml?temp=.2010004