Skip to content

Instantly share code, notes, and snippets.

@stijnsanders
Created February 2, 2012 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stijnsanders/1724324 to your computer and use it in GitHub Desktop.
Save stijnsanders/1724324 to your computer and use it in GitHub Desktop.
Delphi: WIA to take image from digital Camera connected to USB
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;
@hairydisc
Copy link

Where are the declarations for the IWiaDeviceInfo and Iwia variables to be found, please?, also the cowia object?

@boomsya
Copy link

boomsya commented Jan 19, 2021

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