I've got some code that iterates through a list of files found on a WIA device attached to my laptop in order to copy them to my laptop.
It had been working just fine, but when I attached my son's iPhone, it started dying with an "out of memory" error. I was able to trace it to the fact my son had been making movies with his phone.
ImageEnView1.IO.WIAParams.GetItemPropertyAttrib(WIA_IPS_XRES,nil,attrib,values);
iImageEnIO := TImageEnIO.Create(nil);
try
Gauge1.MaxValue := TreeView1.Items.Count - 1;
for i := 1 to TreeView1.Items.Count - 1 do
begin
{ Get the node }
iNode := TreeView1.Items.Item[i];
{RIGHT HERE is where I'd like to test to see if the file is a jpg or not}
if (FileIsNotAJpg) then
Continue;
LabelProgress1.Caption := 'Transferring image to ' +
IncludeTrailingPathDelimiter(Folder1.Text) + iNode.Text + '.jpg';
{ Force to saveing as jpeg setting the desired image format }
iImageEnIO.WIAParams.TransferFormat := ietfJpeg;
iImageEnIO.WIAParams.ProcessingBitmap := iImageEnIO.IEBitmap;
iImageEnIO.WIAParams.GetItemPropertyAttrib();
{ After the image is loaded save the image to disk }
iImageEnIO.WIAParams.SaveTransferBufferAs :=
IncludeTrailingPathDelimiter(Folder1.Text) + iNode.Text + '.jpg';
{ Transfer the image from the camera to iImageEnIO }
iImageEnIO.WIAParams.Transfer(TIEWiaItem(iNode.Data), False);
{ Update progress gauge. }
Gauge1.Progress := i;
Gauge1.Update;
if ACancel then
Break;
end;
I'm stuck on what code will determine "FileIsNotAJpg". I'm thinking it involves WIAParams.GetItemPropertyAttrib(WIA_IPA_FORMAT,nil,attrib,values);
and WiaImgFmt_JPEG, but I have no clue as to what the syntax is to make this work.
Thanks for your help!