| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1082 人关注过本帖
标题:[求助]怎样读出picture控件中的像素!
只看楼主 加入收藏
风雨巛
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-4-30
收藏
 问题点数:0 回复次数:7 
[求助]怎样读出picture控件中的像素!
把数字图象从picture中读出来以后,怎样获得他的像素.
搜索更多相关主题的帖子: picture 像素 控件 数字图象 
2007-04-30 19:51
zhulei1978
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
收藏
得分:0 

Option Explicit
Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
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
Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long

Dim ImageR() As Integer
Dim ImageG() As Integer
Dim ImageB() As Integer
Dim x As Long, y As Long
Dim i As Long, j As Long, p As Long
Dim r As Long, g As Long, b As Long
Dim hBmp As Long, hDestDc As Long
Dim hdc As Long
hdc = Picture1.hdc
x = Picture1.ScaleWidth
y = Picture1.ScaleHeight
ReDim ImageR(y - 1, x - 1)
ReDim ImageG(y - 1, x - 1)
ReDim ImageB(y - 1, x - 1)
hBmp = CreateCompatibleBitmap(hdc, Picture1.ScaleWidth, Picture1.ScaleHeight)
hDestDc = CreateCompatibleDC(hdc)
SelectObject hDestDc, hBmp
For i = 0 To y - 1
For j = 0 To x - 1
p = GetPixel(hdc, j, i)
r = p And 255
g = (p And &HFF00FF00) / 256
b = ((p And &HFF0000) / 65536)
ImageR(i, j) = r
ImageG(i, j) = g
ImageB(i, j) = b
Next j
Next i
Call DeleteDC(hDestDc)
Call DeleteObject(hBmp)


其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2007-04-30 21:29
风雨巛
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-4-30
收藏
得分:0 
为什么在编译的时候会出现编译错误,错误如下:
在end sub,end function属性后面只能出现注释.
出错在下面几行:
Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
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
Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
2007-05-01 18:40
zhulei1978
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
收藏
得分:0 
Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
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
Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
把这些放在一个模块里

其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2007-05-01 20:43
风雨巛
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-4-30
收藏
得分:0 

需要用到那些控件!!!

2007-05-01 23:07
zhulei1978
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
收藏
得分:0 
图片框

其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2007-05-02 16:04
风雨巛
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-4-30
收藏
得分:0 
非常感谢了!
2007-05-02 16:33
风雨巛
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-4-30
收藏
得分:0 
怎样把像素点在图上表现出来.比如,这一点的RGB=(0,0,0),那么,把这点的值负为0,否则为1.
2007-05-04 15:08
快速回复:[求助]怎样读出picture控件中的像素!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.053554 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved