# 为甚么得不到完美1bit 解像度 ????? 柳哥, 小吴请救我吧!!!!!!

Posted by 杀手 on December 14, 1998 at 18:51:12:

为甚么得不到完美1bit 解像度 ????? 柳哥, 小吴请救我吧!!!!!!
我把PixtureBox 里的图案转成1bit 解像度, 但效果完全和PaintShopPro 里的 Color Depth Decrease (1bit color) 完全不同.
究竟我做错了甚么?? 怎样才可以得到PaintShopPro 的效果?? 我的程式如下.
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount
As Long, lpBits As Any) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

Private Sub Command1_Click()
Dim mBit As Long, mDC As Long
'Set the maskcolor
Const nMaskColor = vbWhite
'API uses pixels
Picture1.ScaleMode = vbPixels
'Create mem DC
mDC = CreateCompatibleDC(Picture1.hdc)
'Create new Black and White bitmap
mBit = CreateBitmap(Picture1.ScaleWidth, Picture1.ScaleHeight, 1, 1, ByVal 0&)
'link them
SelectObject mDC, mBit
Picture1.BackColor = nMaskColor
'copy picture from picturebox to memDC
'Windows will convert all pixels with the maskcolor to white,
'and all other pixels to black
BitBlt mDC, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture1.hdc, 0, 0, vbSrcCopy
Picture1.BackColor = vbWhite
Picture1.ForeColor = vbBlack
'copt form memDC to the picturebox
BitBlt Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, mDC, 0, 0, vbSrcCopy
'clean up
DeleteObject mBit
DeleteDC mDC
'if autoredraw form Picture1 is set to true, refresh the picturebox
If Picture1.AutoRedraw = True Then Picture1.Refresh
End Sub

Follow Ups:

- Dear恨情天...Sorry,最近太忙了 帅帅阿柳 13:25:03 12/17/98 (0)
- 要山做出Mask图吧？ cww 13:44:12 12/16/98 (0)