ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to determine file type on WIA device?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
skippix Posted - Jun 29 2014 : 13:08:55
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!
4   L A T E S T    R E P L I E S    (Newest First)
skippix Posted - Jul 01 2014 : 03:25:25
quote:
Why not just model the code of TIEWia.FillTreeView?

until you suggested it, i didn't realize i had the source code! since the debugger stepped over the call to FillTreeView, i didn't think to look. that will be very handy in the future...thanks!
xequte Posted - Jun 30 2014 : 19:22:24
Why not just model the code of TIEWia.FillTreeView?

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
skippix Posted - Jun 30 2014 : 14:00:52
Thanks! It took a bit to figure it out, but the following is what I came up with and it seems to be working.


        SelectedItem := TIEWiaItem(iNode.Data);
        with ImageEnView1.IO.WIAParams do
          s := GetItemProperty(WIA_IPA_FILENAME_EXTENSION, SelectedItem);

        if (LowerCase(s) <> 'jpg') then
          Continue;


What would really be useful, though, would be knowing how you populate a TreeView...
xequte Posted - Jun 29 2014 : 22:07:28
Hi

Have you tried using the WIAScanner demo, selecting the problematic item and reviewing what item properties are returned for it? (You might also want to add a line item for WIA_IPA_FORMAT, though note that this is already assigned by setting TransferFormat to ietfJPEG to WiaImgFmt_JPEG).



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com