设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 3289|回复: 4
打印 上一主题 下一主题

[个人工具] vb的代码 把灰度图像转伪彩

[复制链接]
跳转到指定楼层
1#
发表于 2009-5-6 07:21:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
请教,vb的代码,把灰度图像转伪彩,在ACCESS中应如何改
谢谢!!!
Private   Declare   Function   GetPixel   Lib   "gdi32"   _   
            (ByVal   hdc   As   Long,   ByVal   x   As   Long,   ByVal   Y   As   Long)   As   Long   
  Private   Declare   Function   SetPixelV   Lib   "gdi32"   _   
            (ByVal   hdc   As   Long,   ByVal   x   As   Long,   _   
              ByVal   Y   As   Long,   ByVal   crColor   As   Long)   As   Long   
  Private   tmpPic   As   Picture   
  Private   Sub   Command1_click()   
          Dim   width5     As   Long,   heigh5   As   Long,   rgb5   As   Long   
          Dim   hdc5   As   Long,   i   As   Long,   j   As   Long   
          Dim   bBlue   As   Long,   bRed   As   Long,   bGreen   As   Long   
          Dim   Y   As   Long   
            
          width5   =   Picture1.ScaleWidth   
          heigh5   =   Picture1.ScaleHeight   
          hdc5   =   Picture1.hdc   
          For   i   =   1   To   width5   
                  For   j   =   1   To   heigh5   
                          rgb5   =   GetPixel(hdc5,   i,   j)   
                          bBlue   =   Blue(rgb5)             '获得兰色值   
                          bRed   =   Red(rgb5)                 '获得红色值   
                          bGreen   =   Green(rgb5)         '获得绿色值   
                          '将三原色转换为灰度   
                          Y   =   (9798   *   bRed   +   19235   *   bGreen   +   3735   *   bBlue)   \   32768   
                          '将灰度转换为RGB   
                          rgb5   =   RGB(Y,   Y,   Y)   
                          SetPixelV   hdc5,   i,   j,   rgb5   
                  Next   j   
          Next   i   
          Set   Picture1.Picture   =   Picture1.Image   
  End   Sub   
   
  Private   Function   Red(ByVal   mlColor   As   Long)   As   Long   
          '从RGB值中获得红色值   
          Red   =   mlColor   And   &HFF   
  End   Function   
  Private   Function   Green(ByVal   mlColor   As   Long)   As   Long   
          '从RGB值中获得绿色值   
          Green   =   (mlColor   \   &H100)   And   &HFF   
  End   Function   
  Private   Function   Blue(ByVal   mlColor   As   Long)   As   Long   
          ''从RGB值中获得蓝色值   
          Blue   =   (mlColor   \   &H10000)   And   &HFF   
  End   Function
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2009-5-6 12:33:33 | 只看该作者
有没一个例
3#
 楼主| 发表于 2009-5-7 05:36:24 | 只看该作者
这是别人做的,我需要在ACCESS中实现

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
4#
 楼主| 发表于 2009-5-7 06:41:28 | 只看该作者
还有一个代码,只是没弄明白,请帮忙

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
5#
发表于 2009-5-16 20:40:26 | 只看该作者
还有一个代码,只是没弄明白,请帮忙
灵芝 发表于 2009-5-7 06:41

是用VB做了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-9 07:52 , Processed in 0.099597 second(s), 29 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表