Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

hairydisc commented Nov 1, 2014

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