8298.html
来自「VB技巧问答10000例 VB技巧问答10000例」· HTML 代码 · 共 30 行
HTML
30 行
<html>
<head>
<title>为甚么得不到完美1bit 解像度 ????? 柳哥, 小吴请救我吧!!!!!!</title>
</head>
<body bgcolor="#FFFFFF" vlink="#808080">
<center>
<h1>为甚么得不到完美1bit 解像度 ????? 柳哥, 小吴请救我吧!!!!!!</h1>
</center>
<hr size=7 width=75%>
<hr size=7 width=75%><p>
Posted by 杀手 on December 14, 1998 at 18:51:12:<p>
为甚么得不到完美1bit 解像度 ????? 柳哥, 小吴请救我吧!!!!!!<br>我把PixtureBox 里的图案转成1bit 解像度, 但效果完全和PaintShopPro 里的 Color Depth Decrease (1bit color) 完全不同.<br>究竟我做错了甚么?? 怎样才可以得到PaintShopPro 的效果?? 我的程式如下.<br>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<br>Private Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount <br>As Long, lpBits As Any) As Long<br>Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long<br>Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long<br>Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long<br>Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long<br>Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long<p>Private Sub Command1_Click()<br> Dim mBit As Long, mDC As Long<br> 'Set the maskcolor<br> Const nMaskColor = vbWhite<br> 'API uses pixels<br> Picture1.ScaleMode = vbPixels<br> 'Create mem DC<br> mDC = CreateCompatibleDC(Picture1.hdc)<br> 'Create new Black and White bitmap<br> mBit = CreateBitmap(Picture1.ScaleWidth, Picture1.ScaleHeight, 1, 1, ByVal 0&)<br> 'link them<br> SelectObject mDC, mBit<br> Picture1.BackColor = nMaskColor<br> 'copy picture from picturebox to memDC<br> 'Windows will convert all pixels with the maskcolor to white,<br> 'and all other pixels to black<br> BitBlt mDC, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture1.hdc, 0, 0, vbSrcCopy<br> Picture1.BackColor = vbWhite<br> Picture1.ForeColor = vbBlack<br> 'copt form memDC to the picturebox<br> BitBlt Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, mDC, 0, 0, vbSrcCopy<br> 'clean up<br> DeleteObject mBit<br> DeleteDC mDC<br> 'if autoredraw form Picture1 is set to true, refresh the picturebox<br> If Picture1.AutoRedraw = True Then Picture1.Refresh<br>End Sub
<br>
<br><hr size=7 width=75%><p>
<a name="followups">Follow Ups:</a><br>
<ul><!--insert: 8298-->
<!--top: 8381--><li><a href="8381.html">Dear恨情天...Sorry,最近太忙了</a> <b>帅帅阿柳</b> <i>13:25:03 12/17/98</i>
(<!--responses: 8381-->0)
<ul><!--insert: 8381-->
</ul><!--end: 8381-->
<!--top: 8356--><li><a href="8356.html">要山做出Mask图吧?</a> <b>cww</b> <i>13:44:12 12/16/98</i>
(<!--responses: 8356-->0)
<ul><!--insert: 8356-->
</ul><!--end: 8356-->
</ul><!--end: 8298-->
<br><hr size=7 width=75%><p>
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?