弘帝企业智能建站系统交流平台

 找回密码
 立即注册
查看: 1794|回复: 0

【ASP】Windows Image Acquisition (WIA) 的用法

[复制链接]
发表于 2020-11-4 11:01:43 | 显示全部楼层 |阅读模式
摘自:https://www.cnblogs.com/bjguanmu/articles/7559800.html

一、旋转翻转过滤器:旋转图片

[vb] view plain copy
Dim Img 'As ImageFile
Dim IP 'As ImageProcess

Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"

IP.Filters.Add IP.FilterInfos("RotateFlip").FilterID
IP.Filters(1).Properties("RotationAngle") = 90

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\Bliss90.bmp"


二、裁剪滤镜:裁剪图片
[vb] view plain copy
Dim Img 'As ImageFile
Dim IP 'As ImageProcess

Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"

IP.Filters.Add IP.FilterInfos("Crop").FilterID
IP.Filters(1).Properties("Left") = Img.Width \ 4
IP.Filters(1).Properties("Top") = Img.Height \ 4
IP.Filters(1).Properties("Right") = Img.Width \ 4
IP.Filters(1).Properties("Bottom") = Img.Height \ 4

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\BlissCrop.bmp"



三、缩放滤镜:调整图像的大小
[vb] view plain copy
Dim Img 'As ImageFile
Dim IP 'As ImageProcess

Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"

IP.Filters.Add IP.FilterInfos("Scale").FilterID
IP.Filters(1).Properties("MaximumWidth") = 100
IP.Filters(1).Properties("MaximumHeight") = 100

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\BlissThumb.bmp"


四、邮票过滤器:邮票在另一个图片一个图片
[vb] view plain copy
Dim Thumb 'As ImageFile
Dim Img 'As ImageFile
Dim IP 'As ImageProcess

Set Img = CreateObject("WIA.ImageFile")
Set Thumb = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"
Thumb.LoadFile "C:\WINDOWS\Web\Wallpaper\BlissThumb.bmp"

IP.Filters.Add IP.FilterInfos("Stamp").FilterID
Set IP.Filters(1).Properties("ImageFile") = Thumb
IP.Filters(1).Properties("Left") = Img.Width - Thumb.Width
IP.Filters(1).Properties("Top") = Img.Height - Thumb.Height

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\BlissStamp.bmp"


五、EXIF过滤器:写一个新的标题标签图像
[vb] view plain copy
Dim Img 'As ImageFile
Dim IP 'As ImageProcess
Dim v 'As Vector

Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")
Set v = CreateObject("WIA.Vector")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Autumn.jpg"

IP.Filters.Add IP.FilterInfos("Exif").FilterID
IP.Filters(1).Properties("ID") = 40091
IP.Filters(1).Properties("Type") = VectorOfBytesImagePropertyType '此处的VectorOfBytesImagePropertyType值应改为:1101

v.SetFromString "This Title tag written by Windows Image Acquisition Library v2.0"

IP.Filters(1).Properties("Value") = v

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\AutumnExif.jpg"


六、帧过滤器:创建一个多页TIFF三种图片
[vb] view plain copy
Dim Img 'As ImageFile
Dim Page2 'As ImageFile
Dim Page3 'As ImageFile
Dim IP 'As ImageProcess
Dim v 'As Vector

Set Img = CreateObject("WIA.ImageFile")
Set Page2 = CreateObject("WIA.ImageFile")
Set Page3 = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"
Page2.LoadFile "C:\WINDOWS\Web\Wallpaper\Azul.jpg"
Page3.LoadFile "C:\WINDOWS\Web\Wallpaper\Autumn.jpg"

IP.Filters.Add IP.FilterInfos("Frame").FilterID
Set IP.Filters(IP.Filters.Count).Properties("ImageFile") = Page2

IP.Filters.Add IP.FilterInfos("Frame").FilterID
Set IP.Filters(IP.Filters.Count).Properties("ImageFile") = Page3

IP.Filters.Add IP.FilterInfos("Convert").FilterID
IP.Filters(IP.Filters.Count).Properties("FormatID") = wiaFormatTIFF

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\Bliss.tif"

Img.ActiveFrame = Img.FrameCount

Set v = Img.ARGBData

Set Img = v.ImageFile(Img.Width, Img.Height)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\Autumn.bmp"


七、ARGB过滤器:创建一个修改版本的图片
[vb] view plain copy
Dim Img 'As ImageFile
Dim IP 'As ImageProcess
Dim v 'As Vector
Dim i 'As Long

Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"

Set v = Img.ARGBData

For i = 1 To v.Count Step 21
v(i) = &HFFFF00FF 'opaque pink (A=255,R=255,G=0,B=255)
Next

IP.Filters.Add IP.FilterInfos("ARGB").FilterID
Set IP.Filters(1).Properties("ARGBData") = v

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\BlissARGB.bmp"


八、从另一个文件转换过滤器:创建一个压缩的JPEG文件
[vb] view plain copy
Dim Img 'As ImageFile
Dim IP 'As ImageProcess

Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"

IP.Filters.Add IP.FilterInfos("Convert").FilterID
IP.Filters(1).Properties("FormatID").Value = wiaFormatJPEG
IP.Filters(1).Properties("Quality").Value = 5

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\BlissCompressed.jpg"

转自:http://technet.microsoft.com/zh-cn/ms630819(zh-cn,VS.85).aspx


来讲只有ghost xp系统会缺少这个组件。

下载地址:

http://pan.baidu.com/s/1bnGU5Nx
安装方法:

将下载后的WIAAutSDK.zip解压,复制wiaaut.dll到C:\Windows\System32,注册组件"regsvr32 wiaaut.dll"
测试代码:

复制代码
复制代码
'save as wia-installing-test.vbs
On Error Resume Next
    Set wia = CreateObject("WIA.ImageFile")
    If Err.Number = 0 Then
        MsgBox "wia installing ok",, "wia installing test"
        Set wia = Nothing
    Else
        MsgBox "wia installing failed",, "wia installing test"
    End If
复制代码
复制代码
WIA Property Constant Definitions
(@http://msdn.microsoft.com/en-us/library/windows/desktop/ms630202(v=vs.85).aspx):

const DeviceID = 2
const Manufacturer = 3
const Description = 4
const Type = 5
const Port = 6
const Name = 7
const Server = 8
const RemoteDevID = 9
const UIClassID = 10
const FirmwareVersion = 1026
const ConnectStatus = 1027
const DeviceTime = 1028
const PicturesTaken = 2050
const PicturesRemaining = 2051
const ExposureMode = 2052
const ExposureCompensation = 2053
const ExposureTime = 2054
const FNumber = 2055
const FlashMode = 2056
const FocusMode = 2057
const FocusManualDist = 2058
const ZoomPosition = 2059
const PanPosition = 2060
const TiltPostion = 2061
const TimerMode = 2062
const TimerValue = 2063
const PowerMode = 2064
const BatteryStatus = 2065
const Dimension = 2070
const HorizontalBedSize = 3074
const VerticalBedSize = 3075
const HorizontalSheetFeedSize = 3076
const VerticalSheetFeedSize = 3077
const SheetFeederRegistration = 3078
const HorizontalBedRegistration = 3079
const VerticalBedRegistraion = 3080
const PlatenColor = 3081
const PadColor = 3082
const FilterSelect = 3083
const DitherSelect = 3084
const DitherPatternData = 3085
const DocumentHandlingCapabilities = 3086
const DocumentHandlingStatus = 3087
const DocumentHandlingSelect = 3088
const DocumentHandlingCapacity = 3089
const HorizontalOpticalResolution = 3090
const VerticalOpticalResolution = 3091
const EndorserCharacters = 3092
const EndorserString = 3093
const ScanAheadPages = 3094
const MaxScanTime = 3095
const Pages = 3096
const PageSize = 3097
const PageWidth = 3098
const PageHeight = 3099
const Preview = 3100
const TransparencyAdapter = 3101
const TransparecnyAdapterSelect = 3102
const ItemName = 4098
const FullItemName = 4099
const ItemTimeStamp = 4100
const ItemFlags = 4101
const AccessRights = 4102
const DataType = 4103
const BitsPerPixel = 4104
const PreferredFormat = 4105
const Format = 4106
const Compression = 4107
const MediaType = 4108
const ChannelsPerPixel = 4109
const BitsPerChannel = 4110
const Planar = 4111
const PixelsPerLine = 4112
const BytesPerLine = 4113
const NumberOfLines = 4114
const GammaCurves = 4115
const ItemSize = 4116
const ColorProfiles = 4117
const BufferSize = 4118
const RegionType = 4119
const ColorProfileName = 4120
const ApplicationAppliesColorMapping = 4121
const StreamCompatibilityID = 4122
const ThumbData = 5122
const ThumbWidth = 5123
const ThumbHeight = 5124
const AudioAvailable = 5125
const AudioFormat = 5126
const AudioData = 5127
const PicturesPerRow = 5128
const SequenceNumber = 5129
const TimeDelay = 5130
const CurrentIntent = 6146
const HorizontalResolution = 6147
const VerticalResolution = 6148
const HorizontalStartPostion = 6149
const VerticalStartPosition = 6150
const HorizontalExtent = 6151
const VerticalExtent = 6152
const PhotometricInterpretation = 6153
const Brightness = 6154
const Contrast = 6155
const Orientation = 6156
const Rotation = 6157
const Mirror = 6158
const Threshold = 6159
const Invert= 6160
const LampWarmUpTime = 6161
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|弘帝企业智能建站系统 ( 皖ICP备07503252号 )

GMT+8, 2024-11-24 02:19 , Processed in 0.047720 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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