Saving WIA-acquired pictures

Hello,

i have an application allowing to take pictures with a (web)cam and select the ones to be saved. These are stored in a IWiaDataTransfer pointer. However, i don't know how to save them, and how to choose the desired file type (bmp,jgp,tiff,gif).
Can someone give me some advice

Thanks a lot!


Answer this question

Saving WIA-acquired pictures

  • Mydotnet

    You transfer the image from the camera with the idGetData() method. The pMedia argument should reference a properly created STGMEDIUM whose tymed member should be TYMED_GDI. After the transfer is done, you have a bitmap in memory. From there, you can save the picture in any desired format. Like .NET 2.0's Bitmap.FromHbitmap() and Bitmap.Save().


  • nictan

    Ok, i already called the idGetData method, so now i'ld should call one of the bmp methods as suggested.
    But i recall myself having red something in the mdsn documentation that wia provides functionality for saving images in the desired format as well. Sow how should i call these methods It would seem more logic to use these methodes than to use the Bitmap methods. Although i'm not for sure since i don't have many experience with programming for graphical purposes.

    Regards

    Flor

  • MDiCarlo

    Dear nobugz,

    thanks a lot for your replies so far. They have been really useful.
    But now i have one very last remaining question. I hope you/someone can help me out on this one.


    i have made a application using WIA to grab pictures and store them on disk. But after a lot of use, there remain a lot of captured pictures in the right part of the wia image selection dialog.

    I would like to be able to delete these. The method which seems most appropriate is the IWiaItem::DeleteItem method. If i call this method after storing pictures, i can also delete those. However, i would also like to be able to use the DeleteItem button at whatever time i want it to. And not only to delete the pictures which i might have selected. No, i would like to delete all of the pictures which once were taken with the camera using this button.

    One can tell me how this should be done

    Regards


  • GIScoobe

    I think you're right. This example shows how to save an image directly into a file. Just change the assignment to guidOutputFormat. Look here to see which WiaImgFmt_* constants you can use.



  • SQL Pro

    You don't have to double up the backslashes. It's a bit hard to explain but you only need two backslashes in string literals because a the compiler treats it like an escape character to write stuff like \n or \r. Once you have the path in a CString variable, you're a-ok with a single backslash.

    To convert from a CString to an OLESTR, use the ATL A2OLE macro like this:
    #include <atlbase.h>
    ...
    USES_CONVERSION;
    LPOLESTR p = A2OLE(str);



  • S&amp;#38;&amp;#35;248&amp;#59;ren Spelling Lund

    I don't see where the file name and saving directory is set. How is this done
    And what do you mean by "changing the assignment" Which assignment

    Regards

  • JimJams

    Hi there,

    Thanks!
    indeed, setting the lpszFileName with exact path and extension does the job.
    But now i still want to process the user input: a normal string for the path, and this has to become a LPOLESTR with always double backslashes. Any idea
    a)if there is a method that adds these slashes
    b)how i can convert a cstring tot lpolstr

    Regards.

  • Viborito

    Make sure you look at the example at the bottom of the web page. Change this assignment:
    GUID guidOutputFormat = WiaImgFmt_BMP;

    The example lets WIA determine the filename. I'm not up to speed on STGMEDIUM but assume you can set the path for the file to save by assigning stgMedium.lpszFileName. Google for this, I'm not sure how the string needs to be allocated.



  • rene-poepperl

    Sorry, I've been winging it and don't know what "right part of the wia image selection dialog" means. Please start a new thread, this one is old and already marked answered so you'll get very few people taking a look at it.



  • rajesh_vellore123

    Hi,

    the string thing (conversion to olestr) is know resolved.
    But as you suggested it's pretty hard to understand how to handle the backslashes. Could you explain it in an other way so it becomes more clear or otherwise refer me to a more detailed explication (site) As for now, if i use single backslashes, the path isn't recognised. That might be because of the conversion from cstring to LPTOLESTR but i'm not sure on that.

    Regards

  • Saving WIA-acquired pictures