×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    convert bmp image to jpeg

    Hello All,
    I have bmp image, want to convert into jpeg and then again want to convert in byte array..
    Kindly help me.
    Its really urgent.
    Thank you.
    Nishant

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: convert bmp image to jpeg

    You could check image encoders & decoders example code from the wiki. Basically you would need to use image decoder to open bmp to CFbsBitmap, and then use image encoders to save it to JPG.

    What kind of byte array you are looking for ? if it is just jpg image in buffer, you could use RFile for reading the image as a file.

  3. #3
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: convert bmp image to jpeg

    I have bitmap type of image and want to send to the server...
    I dont store image in any file(as project requirement)
    kindly tell me how can i do it..
    Thank you

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: convert bmp image to jpeg

    You can also use the image encoder API for saving the jpg directly into buffer, which indeed you could then sent to your server. You could maybe check our wiki for examples, and try them out.

    And once you have tried, and if you still have problems, you should describe the problem in more details.

  5. #5
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: convert bmp image to jpeg

    I dont have jpg image I have only bitmap type image

  6. #6
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: convert bmp image to jpeg

    And as said you can use the API to save CFBsBitmap to JPG, and the API also offers possibility on saving it directly to a buffer. So please check wiki examples and try out codes, and please ask detailed questions. i.e. describe on what you have done, and what is expected to happen, and what is actually happening.

    Or if you don't know on how to do something, you should describe on what it is that you have done so far, and what you would want to do, and what should be the end result.

    Also please note that bmp, mbm, and bitmap images are very different things and might also depend on context, so please also describe things in a way that they should not have multiple ways on interpreting them.

  7. #7
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: convert bmp image to jpeg

    ok I understand...
    Now I am doing like this
    HBufC8* ibuffer = NULL;//HBufC8::NewL(1000);
    CImageEncoder* iencoder = CImageEncoder:ataNewL(ibuffer,_L8("image/bmp"),CImageEncoder::EOptionAlwaysThread);
    CleanupStack::PushL(iencoder);
    TRequestStatus aStatus = KErrNone;
    iencoder->Convert( &aStatus, *iBitmap );
    User::WaitForRequest( aStatus );
    CleanupStack::PopAndDestroy();
    // TBuf<1000> buffer;
    TPtr8 pt = ibuffer->Des();


    LIT8(KDataStart,"------------AaB03x");
    _LIT8(KCrlf,"\r\n");
    _LIT8(KContent,"Content-Disposition: form-data; name=\"userfile\"; filename=\"");
    _LIT8(KFileCompletion,"\"");

    _LIT(KContent2,"Content-Type: image/jpeg");
    _LIT(KContent3,"Content-Transfer-Encoding: binary");
    _LIT8(KDataEnd,"------------AaB03x--");
    //
    iPostData = HBufC8::NewL(1000+pt.Length());
    CleanupStack::PushL(iPostData);
    //
    TPtr8 iPostDataPtr = iPostData->Des();
    // iPostDataPtr.Copy(ibitmap);
    // iPostDataPtr.Copy(idecoder);
    iPostDataPtr.Zero();


    // iPostDataPtr.Append(KCrlf);
    iPostDataPtr.Append(KDataStart);
    iPostDataPtr.Append(KCrlf);
    iPostDataPtr.Append(KContent);
    iPostDataPtr.Append(_L("image.jpg"));
    iPostDataPtr.Append(KFileCompletion);
    iPostDataPtr.Append(KCrlf);
    iPostDataPtr.Append(KContent2);
    // iPostDataPtr.Append(KCrlf);
    // iPostDataPtr.Append(KContent3);
    iPostDataPtr.Append(KCrlf);
    iPostDataPtr.Append(KCrlf);

    iPostDataPtr.Append(pt);//(aPtr); //the file in binary
    iPostDataPtr.Append(KCrlf);
    iPostDataPtr.Append(KDataEnd);
    iPostDataPtr.Append(KCrlf);

    TRAPD(err, iEngine->IssueHTTPPostL(KUrl, KMimeType, /*tttPtr*/iPostDataPtr));
    // // TODO: Error handling
    if (err)
    {
    }
    but it crashes in IssueHTTPPostL
    at this line
    if (IsActive())
    {
    return;
    }
    what should i do?

  8. #8
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: convert bmp image to jpeg

    Firstly you would be a lot better off by using Real active object implementation, using WaitForRequest will be bad for user experience, anyway, I suppose you can keep that during development early phases.


    anyway for teh crash you should try getting the panic code: http://www.developer.nokia.com/Commu...ded_panic_code

  9. #9
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,987

    Re: convert bmp image to jpeg

    Where is iEngine object declared & the memory allocated for it..

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

    Re: convert bmp image to jpeg

    Code:
    CImageEncoder* iencoder = CImageEncoder::DataNewL(ibuffer,_L8("image/bmp"),CImageEncoder::EOptionAlwaysThread);
    Are you expecting this line to create a jpeg encoder?

    You may benefit from taking one step at a time. So prior to posting an image created on the fly, make sure that you can post an image at all. Copy a small .jpg file to the phone, load it with RFile, and post that first.

  11. #11
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: convert bmp image to jpeg

    no I am creating bmp encoder...

  12. #12
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: convert bmp image to jpeg

    Where is iEngine object declared & the memory allocated for it..
    allocate memory for iengine in constructL()
    IEngine = CClientEngine::NewL(*iview);

  13. #13
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: convert bmp image to jpeg

    You should not cherry-pick the answers, but it would be betetr to answer all of them . Also the suggestion made by Wizard would be good to try, so check first that your POST works, and after it works, then try converting the image to a buffer.

  14. #14
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: convert bmp image to jpeg

    Dear Wizard_hu as you have suggested.. I do and it is working fine.
    Now if at run time I have a Cfbsbitmap type image(not saved in file) how can i upload it.
    1. how can i encode - decode it
    2. uploading
    kindly help me
    Thank you

  15. #15
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: convert bmp image to jpeg

    basically you could use http://www.developer.nokia.com/Commu...mages_to_files in general just change FileNewL to DataNewL.

    As you got uploading already working, just use the code you have.

Similar Threads

  1. Convert MBM to JPEG
    By christopherlim83 in forum Symbian
    Replies: 1
    Last Post: 2009-06-03, 14:01
  2. How to convert a JPEG image to a PNG image using J2ME Code
    By hussain_afs in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2007-12-31, 16:48
  3. How to convert the jpeg image data to CFbsBitmap
    By whitewinds in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2007-04-17, 08:00
  4. convert png images to jpeg
    By adneimocne in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2004-05-30, 16:16
  5. Convert graphics to JPEG format
    By kwokt in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2003-06-23, 08:47

Posting Permissions

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