CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  API

请问有没有办法将图片上所有的颜色值装入一个数组

楼主lingll(blog.csdn.net/lingll/)2003-06-03 00:51:39 在 VB / API 提问

不是使用循环的方法,那样太慢了  
   
  或者如果能知道内存中的位图某一点颜色值的地址也行 问题点数:100、回复次数:4Top

1 楼rainstormmaster(暴风雨 v2.0)回复于 2003-06-03 01:11:26 得分 100

'Create   a   new   project,   add   a   command   button   and   a   picture   box   to   the   project,   load   a   picture   into   the   picture   box.  
  'Paste   this   code   into   Form1  
  Private   Type   BITMAP  
          bmType   As   Long  
          bmWidth   As   Long  
          bmHeight   As   Long  
          bmWidthBytes   As   Long  
          bmPlanes   As   Integer  
          bmBitsPixel   As   Integer  
          bmBits   As   Long  
  End   Type  
  Private   Declare   Function   GetObject   Lib   "gdi32"   Alias   "GetObjectA"   (ByVal   hObject   As   Long,   ByVal   nCount   As   Long,   lpObject   As   Any)   As   Long  
  Private   Declare   Function   GetBitmapBits   Lib   "gdi32"   (ByVal   hBitmap   As   Long,   ByVal   dwCount   As   Long,   lpBits   As   Any)   As   Long  
  Private   Declare   Function   SetBitmapBits   Lib   "gdi32"   (ByVal   hBitmap   As   Long,   ByVal   dwCount   As   Long,   lpBits   As   Any)   As   Long  
  Dim   PicBits()   As   Byte,   PicInfo   As   BITMAP,   Cnt   As   Long  
  Private   Sub   Command1_Click()  
          'Get   information   (such   as   height   and   width)   about   the   picturebox  
          GetObject   Picture1.Image,   Len(PicInfo),   PicInfo  
          'reallocate   storage   space  
          ReDim   PicBits(1   To   PicInfo.bmWidthBytes   *   PicInfo.bmHeight)   As   Byte  
          '取出颜色信息到数组PicBits  
          GetBitmapBits   Picture1.Image,   UBound(PicBits),   PicBits(1)  
          '颜色反转  
          For   Cnt   =   1   To   UBound(PicBits)  
                  PicBits(Cnt)   =   255   -   PicBits(Cnt)  
          Next   Cnt  
          '传回picture  
          SetBitmapBits   Picture1.Image,   UBound(PicBits),   PicBits(1)  
          'refresh  
          Picture1.Refresh  
  End   SubTop

2 楼Surpass((本账户已更换主人))回复于 2003-06-03 08:53:47 得分 0

upTop

3 楼lingll(blog.csdn.net/lingll/)回复于 2003-06-03 11:01:21 得分 0

问题解决了,不过有个疑问  
  msdn   对   GetBitmapBits   有这么一句话  
   
  Note     This   function   is   provided   only   for   compatibility   with   16-bit   versions   of   Windows.   Win32-based   applications   should   use   the   GetDIBits   function.    
   
  也就是说GetBitmapBits只适合在16-bit的win下工作,而我在win2k下(这个应该是32-bit的win吧),依然能正常,何解?  
  是否应该使用GetDIBits?Top

4 楼rainstormmaster(暴风雨 v2.0)回复于 2003-06-03 20:52:49 得分 0

在win16和win32下函数的声明不同Top

相关问题

  • 如何将一个二维数组装入session?
  • c#如何用foreach()遍历一个数组中所有元素?
  • 如何清除动态数组所有元素的问题
  • 怎样在VC++6.0中查看一个数组的所有值?
  • 如何将field对象中的所有数据加入数组?
  • 如何清楚快速清除数组中的所有内容?
  • 求教一算法:从一个二维数组A[0..5,0..10]COPY出一个二维数组B,要求COPY时将数组A中所有全0行删除。
  • 求一个算法,有N个数组,每个数组长度不等,要求从每个数组取一个数,得到所有的组合。
  • 怎么把字符数组的所有字符赋给字符串?
  • 怎样初始化一个数组,使它所有成员都是'\0' ?????

关键词

  • longprivate
  • gdi32
  • byval
  • long
  • picture
  • lib
  • declare function

得分解答快速导航

  • 帖主:lingll
  • rainstormmaster

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo