passing the data one function to another function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krishnasamy
    New Member
    • Jun 2007
    • 31

    passing the data one function to another function

    Hi,



    I am retrieving the image from DLL through vc++ dll. Actually Image is retrieving in Callback function of main function. When I writing that image file inside of the Callback function then no problem in retrieving. At the same I want to send the Imagedata to the another function and write the same which cause the error.



    Here I given that code,



    //Callback function



    prResponse prSTDCALL MyGetFileDataFu nction(

    prHandle CameraHandle,

    prObjectHandle ObjectHandle,

    prContext Context,

    prProgress* pProgress

    )

    {

    static ofstream out("capture.jp g", ios::out|ios::b inary);


    switch( pProgress->lMessage )

    {

    prUInt8 imgbuffer[1024];


    case prMSG_DATA_HEAD ER:

    break;

    case prMSG_DATA:

    for (prUInt32 index = 0; index < pProgress->lLength; index++)

    {

    imgbuffer[index] = pProgress->pbData[index];

    }





    PowershotDll::P owershotSdkDll: :Copy(imgbuffer ,pProgress->lLength); //Calling another function and send the data

    memcpy(CaptureI mage,imgbuffer, 1024L);

    out.write((cons t char*)CaptureIm age,1024L);


    break;

    case prMSG_TERMINATI ON:

    out.close();


    break;

    }





    return prOK;

    }



    Copy function:

    void PowershotSdkDll ::Copy(prUInt8 *pDataBuffer, prUInt32 dataLength)

    {

    // Byte managedDataBuff er __gc[] = new System::Byte[dataLength];

    BYTE managedDataBuff er[1024];


    for (prUInt32 index = 0; index < dataLength; index++)

    {

    managedDataBuff er[index] = pDataBuffer[index];

    }

    /// Write the data to the memoryStream

    //pMemoryStream->Write(managedD ataBuffer, 0, dataLength);

    static ofstream out1("Copycaptu re.jpg", ios::out|ios::b inary|ios::app) ;

    out1.write((con st char*)managedDa taBuffer, 1024L);

    out1.close();


    }



    I got the image capture.jpg but i didnt get the copycapture.jpg image which contain only 1024 bytes.

    How to re-assign the array for every data?

    Pleae give your suggestion.
  • krishnasamy
    New Member
    • Jun 2007
    • 31

    #2
    ----

    Now I have changed my function as follows,

    Default declaration:[code=cpp]
    static ofstream out("capture.jp g", ios::out|ios::b inary);

    void PowershotSdkDll ::Copy(prUInt8 *pDataBuffer, prUInt32 dataLength)
    {
    out.write((cons t char*)pDataBuff er, dataLength);
    out.close();


    }
    [/code]
    In Callback function:
    [code=cpp]
    prResponse prSTDCALL MyGetFileDataFu nction(
    prHandle CameraHandle,
    prObjectHandle ObjectHandle,
    prContext Context,
    prProgress* pProgress
    )
    {
    /* Display progress */


    switch( pProgress->lMessage )
    {
    //prUInt8 imgbuffer[1024];


    case prMSG_DATA_HEAD ER:
    break;
    case prMSG_DATA:



    PowershotDll::P owershotSdkDll: :Copy(pProgress->pbData,pProgre ss->lLength);
    break;

    case prMSG_TERMINATI ON:

    break;
    }



    return prOK;
    }
    [/code]


    But I have retrieved the last block image data only. What is the problem?
    Last edited by sicarie; Oct 17 '07, 01:13 PM. Reason: Code tags

    Comment

    Working...