in

Archived Data Techniques Forums

using the imagecontrol SaveAs method in c++

Last post 07-30-2007 2:56 PM by support. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 05-11-2007 5:04 PM

    • silent
    • Top 200 Contributor
    • Joined on 05-11-2007
    • Posts 6

    using the imagecontrol SaveAs method in c++

    Hi,

    i'm having a problem in my c++ application using the axtiveX image control.

    When i try to use the method Savas like this:

    im1->SaveAs(strImageFile);

    The code does compile but at runtime i'm getting this error:

     

    A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

    at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

    at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)

    at AxIMActX8.AxImageControl.SaveAs(String fileName)

    at ScanOcr.ScanOcrControl.ScanImages(ValueType bIsPurchase, AxImTwain imtwain, AxImageControl im1, String g_strOcrTempPath) in d:\code\mfc_docking_winform_control_view_test\scanocr\scanocrcontrol.cpp:line 106

    at IMActX8.IImageControl.SaveAs(String FileName, Object& SaveAttributes)

     

    Im breaking my head and teeth on this one.

    Someone any idea to solve this ?

     

    I've searched for some more information and got the HRESULT from the operation:

    0x800A81B3

  • 05-14-2007 7:23 AM In reply to

    Re: using the imagecontrol SaveAs method in c++

    Hi,

    Have you tried passing an Attributes object as the 2nd parameter to the SaveAs call ? C# doesnt support calling methods without all the params so thats likely the problem. I would also suggest you look at our ImageMan.Net toolkit for use in managed .net code, its a much nicer interface and easier to call/use.

  • 05-14-2007 8:44 AM In reply to

    • silent
    • Top 200 Contributor
    • Joined on 05-11-2007
    • Posts 6

    Re: using the imagecontrol SaveAs method in c++

    Hi,

     I've already tried with the two parameters:

    im1->SaveAs(strImageFile, im1->ImageAttributes);

    But I keep getting the same error.

    In fact I've gotten this code in c# from another company and I'm sure it has worked, but

    now at the moment I keep having the same error all the time on the same line.

     

    In fact this is wath I'm doing with the component:

    All the lines pass except the im1->saveas....

    hDIB = imtwain->ScanPage(false);

    while ((hDIB != 0) && (i < 1000))

    {

    im1->hDIB = hDIB;

    im1->Refresh();

    im1->Overwrite = IMActX8::enumOverwrite::Yes;

    if (im1->ImageColors == 2)

    {

    im1->Compression = IMActX8::enumCompression::Group4;

    } else

    {

    im1->Compression = IMActX8::enumCompression::LZW;

    }

    String^ strImageFile = g_strOcrTempPath + "\\" + System::Guid::NewGuid().ToString("N") + ".tiff";

    try

    {

    im1->SaveAs(strImageFile, im1->ImageAttributes);

    }

    catch(COMException^ e)

    {

    Trace::WriteLine(e->StackTrace);

    Trace::WriteLine(e->HelpLink);

    Trace::WriteLine(e->Source);

    Trace::WriteLine(e->Message);

    Trace::WriteLine(e->ErrorCode);

    }

     

    sImageFiles->Add(strImageFile);

    i+=1;

    hDIB = imtwain->ScanPage(false);

    }

     

  • 07-30-2007 2:14 AM In reply to

    • silent
    • Top 200 Contributor
    • Joined on 05-11-2007
    • Posts 6

    Re: using the imagecontrol SaveAs method in c++

    Hi,

     

    I' ve solved the problem in the meanwhile,

    in fact c++ seems to make axinterop wrapper classes when u add them to the toolbox

    And if I use these dll's inside my project I get the error,

    but whe I change the project to use the dll's that are with the suite the error doesn't appear.

  • 07-30-2007 2:56 PM In reply to

    Re: using the imagecontrol SaveAs method in c++

    Thanks for the update, sounds like the automatically generated wrappers had the method types incorrectly.
    Sean
    Data Techniques Online Support
Page 1 of 1 (5 items)
Copyright 2009 Data Techniques, Inc. All Rights Reserved.