Created
February 2, 2012 16:17
-
-
Save stijnsanders/1724324 to your computer and use it in GitHub Desktop.
Delphi: WIA to take image from digital Camera connected to USB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uses WIALib_TLB; | |
procedure TForm1.Button1Click(Sender: TObject); | |
var | |
wia:IWia; | |
wiad:OleVariant; | |
wiax:IWiaDispatchItem; | |
i:integer; | |
tc1,tc2:cardinal; | |
begin | |
tc1:=GetTickCount; | |
wia:=CoWia.Create; | |
if ComboBox1.ItemIndex=-1 then | |
begin | |
for i:=0 to wia.Devices.Count-1 do | |
ComboBox1.Items.Add((wia.Devices.Item[i] as IWiaDeviceInfo).Name); | |
end | |
else | |
begin | |
wiad:=wia.Devices.Item[ComboBox1.ItemIndex] as IWiaDeviceInfo; | |
wiax:=wia.Create(wiad).TakePicture; | |
wiax.Transfer('C:\Data\R&D\Delphi\WIA\test.bmp',false); | |
tc2:=GetTickCount; | |
Image1.Picture.LoadFromFile('C:\Data\R&D\Delphi\WIA\test.bmp'); | |
Caption:=IntToStr(tc2-tc1)+'ms '+IntToStr(Image1.Picture.Width)+'x'+IntToStr(Image1.Picture.Height); | |
end; | |
end; |
Select "Project > Import Type Library" from the Menu
Select ""Microsoft Windows Image Acquisition 1.01 Type Library" from the list
Choose "Create Unit"
You will then get the unit "WIALib_TLB.pas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where are the declarations for the IWiaDeviceInfo and Iwia variables to be found, please?, also the cowia object?