×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    36

    Byte Array to Image conversion

    Hi All,

    I am sending an image file in byte array to the phone application. Now I want to convert this byte array to Image using carbide c++.

    Can Someone guide and Suggest me the approch.

    Regards

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,748

    Re: Byte Array to Image conversion

    CImageDecoder::DataNewL works from byte arrays (8-bit descriptors) - if that array happens to be in some standard file format (.bmp, .gif, .jpg, etc.)
    If your byte array is of raw image data, you can still use TBitmapUtil, or access bitmap directly via CFbsBitmap::DataAddress.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    1,236

    Re: Byte Array to Image conversion

    Hi,

    If you problem is solved then you need not bother for your information the same topic is discussed in the follwing thread http://discussion.forum.nokia.com/fo...d.php?t=146934
    Regards,
    Sriky

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    36

    Re: Byte Array to Image conversion

    Hi,

    Thx for the suggetions, They are really helpful.
    Now I am sending the Byte array as a base64String to the emulator but the problem is that i am not getting the full data.
    It gives me around 50% data of base64String when I write it to a file.

    I am using code like this...

    User::WaitForRequest(status);

    if(status != KErrNone) iEikonEnv->InfoWinL(_L("ooooops! Some Problem :("), _L(""));
    else iEikonEnv->InfoWinL(_L("Got the image :)"), _L(""));

    TBuf8<524288> buffer;
    blank.RecvOneOrMore(buffer, 0, status, dummyLength) ;

    //////convert Base64String /////
    //have to write the conversion logic for Base64String
    //////

    //saving to an image file
    RFs fs ;
    User::LeaveIfError(fs.Connect());RFile file ;
    _LIT(KDesName,"c:\\System\\Apps\\testfolder\\new.jpg");
    file.Create(fs,KDesName,EFileWrite);
    CleanupClosePushL(file);
    file.Write(buffer);
    CleanupStack::PopAndDestroy(2);


    Please Guide me.

  5. #5
    Registered User
    Join Date
    Dec 2005
    Posts
    1,236

    Re: Byte Array to Image conversion

    Hi,

    I am not sure in TBuf8<524288> buffer; statement that much stack space is available or not. You better try HBufC8* buffer = HBufC8::NewL( 524288 ); and also try increasing the heap and stack size in your project mmp.
    Regards,
    Sriky

  6. #6
    Registered User
    Join Date
    Oct 2008
    Posts
    36

    Re: Byte Array to Image conversion

    Thanks for the quick reply.

    now I am using it like .....

    HBufC8* buffer = HBufC8::NewL( 524288 );
    TPtr8 ptr = buffer->Des();
    blank.RecvOneOrMore(ptr, 0, status, dummyLength) ;

    but still it gives me same ammount of data... :(
    Last edited by kumar_a; 2008-10-15 at 12:25. Reason: Solved the last one

  7. #7
    Registered User
    Join Date
    Dec 2005
    Posts
    1,236

    Re: Byte Array to Image conversion

    Hi,

    We could check couple of things
    What is
    1. Value of dummyLength passed after the call returns
    2. Value of status.Int() after the call returns
    3. What is the length you are actually passing

    I am not quite sure whether you could send such a huge data in one shot may be you should consider sending it in chuncks.
    Regards,
    Sriky

  8. #8
    Registered User
    Join Date
    Oct 2008
    Posts
    36

    Re: Byte Array to Image conversion

    ok......but i am not sure how much data we can send in one shot.

    I am sending 1.5 KB data and getting 1 KB at the other end.
    but when I am sending 37 KB data I am getting 8kb.

    so if I can get 8kb of data then why I am not getting 1.5 data (first case).

    Regards

  9. #9
    Registered User
    Join Date
    Dec 2005
    Posts
    1,236

    Re: Byte Array to Image conversion

    Hi,

    I am not quite sure kumar why it is happening.
    Regards,
    Sriky

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,748

    Re: Byte Array to Image conversion

    RecvOneOrMore is about getting some data and returning quickly. You should re-issue RecvOneOrMore for getting all the data (in the meantime collect the individual data fragments into a larger descriptor or a CBufFlat). In order to know the amount of data to be expected, send its length first.

  11. #11
    Registered User
    Join Date
    Oct 2008
    Posts
    36

    Re: Byte Array to Image conversion

    Hi All,

    Thx for the help.I am able to render the image.
    Now I am sending the byte array object instead of base64string and directly convering it to "jpeg".

    For small GIF images it is doing good but when I am sending a file like 23 KB it renders 1/4 th of the image.

    I think I can not send data more than 8 kb in one shot so I want to send them in chunks.

    what I have to do for that right now my code is like...

    HBufC8* buffer = HBufC8::NewL( 524288 );
    HBufC8* buffer1 = HBufC8::NewL( 524288 );
    TPtr8 ptr = buffer->Des();
    TPtr8 ptr1 = buffer1->Des();
    blank.RecvOneOrMore(ptr, 0, status, dummyLength) ;
    User::WaitForRequest(status);
    blank.RecvOneOrMore(ptr1, 0, status, dummyLength) ;
    ptr.Append(ptr1);
    RFs fs ;
    User::LeaveIfError(fs.Connect());RFile file ;
    _LIT(KDesName,"c:\\System\\Apps\\testfolder\\new.jpg");
    file.Create(fs,KDesName,EFileWrite);
    CleanupClosePushL(file);
    file.Write(ptr);
    CleanupStack::PopAndDestroy(2);

    but At run time it gives me error that memory is full.
    I tried CBufFlat too but same error in that case too.

    Please guide me.

    Regards

  12. #12
    Registered User
    Join Date
    Oct 2008
    Posts
    36

    Re: Byte Array to Image conversion

    I think I need to send and recieve the data in chuncks.
    Can someone help me in that area ?

    Regards
    Last edited by kumar_a; 2008-10-17 at 07:35.

Similar Threads

  1. image -> byte array -> image
    By kolada in forum Mobile Java Media (Graphics & Sounds)
    Replies: 7
    Last Post: 2011-02-28, 00:23
  2. what is an APDU
    By pawangjain in forum Near Field Communication
    Replies: 0
    Last Post: 2007-07-02, 07:42
  3. how to cut some part of Image
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-08-04, 09:05
  4. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31
  5. Loading images from byte array on 6130i
    By enlightment in forum Mobile Java General
    Replies: 2
    Last Post: 2002-06-05, 19:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×