×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    52

    jpg -> bmp conversion problem

    Hi,
    I am trying to convert a jpeg stored in the phones image gallery to a bitmap, so I can manipulate it in my application. My code compiles and runs fine, but the converted bmp doesn't appear to be saving properly. When I save it to the phone it is just a white square, so this makes me think that there is something wrong with my conversion code.

    Here is my class used for conversion:

    Code:
    #include "ImageConverter.h"
    
    #include <eikenv.h>
    
    CImageConverter::CImageConverter() : CActive(EPriorityStandard)
        {
        CActiveScheduler::Add(this) ; // add to active scheduler
        }
    
    CImageConverter::~CImageConverter()
    	{
    	delete iDecoder;
    	}
    
    
    void CImageConverter::Start() {
    	SetActive();
    }
    
    CFbsBitmap* CImageConverter::DecodeOpenAndConvertL(TFileName file) {
    
         CEikonEnv* env = CEikonEnv::Static();
    
          User::LeaveIfError(iFs.Connect());
    
         delete iDecoder;
        iDecoder = 0;
    
        iDecoder = CImageDecoder::FileNewL(iFs, file, CImageDecoder::EOptionAlwaysThread);
    
        TFrameInfo frmInfo = iDecoder->FrameInfo(0);
        TRect rectOfImage = frmInfo.iFrameCoordsInPixels;
    
        delete iBitmap;
        iBitmap = 0;
        iBitmap = new (ELeave) CFbsBitmap();
        iBitmap->Create(rectOfImage.Size(), env->DefaultDisplayMode());
    
        iDecoder->Convert(&iStatus, *iBitmap, 0);
    
        SetActive();
    
    	iFs.Close();
    
    	return iBitmap;
    }
    
    
    /**
    * From CActive derivation
    */
    void CImageConverter::RunL()
    	{
    	
    	}
    
    /**
    * From CActive derivation
    */
    
    void CImageConverter::DoCancel()
    	{
    	if (iDecoder)
    		{
    		iDecoder->Cancel();
    		}
    	}
    It is used like this:

    Code:
    CImageConverter* iConverter = new (ELeave) CImageConverter;
    iImage = iConverter->DecodeOpenAndConvertL(pixelFile);
    iImage->Save(KBitmap1);
    Can anyone see what I'm doing wrong here?

    Thanks,
    Miranda

  2. #2
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    52

    Unhappy Re: jpg -> bmp conversion problem

    No one has done image decoding???

  3. #3
    Regular Contributor
    Join Date
    Oct 2004
    Location
    india
    Posts
    306

    Re: jpg -> bmp conversion problem

    hi,
    miranda

    this is for u............. converting jpg --> bmp



    CFbsBitmap* iBitmap = new (ELeave) CFbsBitmap();
    TFileName filename,bmpfile;
    filename.Copy(_L("c:\\system\\apps\\1.jpg"));
    bmpfile.Copy(_L("c:\\system\\apps\\2.bmp"));
    CImageDecoder* idecoder = CImageDecoder::FileNewL(CEikonEnv::Static()->FsSession(),filename,_L8("image/jpeg"),CImageDecoder::EOptionAlwaysThread);
    TFrameInfo iFrameInfo = idecoder->FrameInfo(0);

    iBitmap->Create(iFrameInfo.iOverallSizeInPixels, iFrameInfo.iFrameDisplayMode );

    TRequestStatus aStatus = KErrNone;
    idecoder->Convert( &aStatus, *iBitmap );
    User::WaitForRequest( aStatus );
    if(aStatus == KErrNone)
    {

    CImageEncoder* iEncoder = CImageEncoder::FileNewL(CEikonEnv::Static()->FsSession(),bmpfile,_L8("image/bmp"),CImageEncoder::EOptionAlwaysThread);
    iEncoder->Convert(&aStatus,*iBitmap);
    User::WaitForRequest( aStatus );
    }

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    3

    Re: jpg -> bmp conversion problem

    Hello giridharn,

    I am attempting to convert from bmp to jpg using your code.

    an error occured below. Can you help me?Any idea?

    CFbsBitmap* iBitmap = new (ELeave) CFbsBitmap();
    TFileName filename,bmpfile;
    filename.Copy(_L("c:\\system\\apps\\1.jpg"));
    bmpfile.Copy(_L("c:\\system\\apps\\2.bmp"));
    CImageDecoder* idecoder = CImageDecoder::FileNewL(CEikonEnv::Static()->FsSession(),filename,_L8("image/jpeg"),CImageDecoder::EOptionAlwaysThread); <---
    ERROR: Unresolved symbol: _ZN13CImageDecoder8FileNewLER3RFsRK7TDesC16RK6TDesC8NS_8TOptionsE
    make[1]: *** [..\..\..\..\..\..\..\bin\TechView\EPOC32\RELEASE\ARMV5\UDEB\CameraApp.exe] Error -2


    Tkpk

  5. #5
    Registered User
    Join Date
    Oct 2005
    Posts
    3

    Re: jpg -> bmp conversion problem

    Hello giridharn,

    I am trying to convert from jpg to bmp using your code.

    I got an error occured below. Can you help me?Any idea?

    CFbsBitmap* iBitmap = new (ELeave) CFbsBitmap();
    TFileName filename,bmpfile;
    filename.Copy(_L("c:\\system\\apps\\1.jpg"));
    bmpfile.Copy(_L("c:\\system\\apps\\2.bmp"));
    CImageDecoder* idecoder = CImageDecoder::FileNewL(CEikonEnv::Static()->FsSession(),filename,_L8("image/jpeg"),CImageDecoder::EOptionAlwaysThread); <---
    ERROR: Unresolved symbol: _ZN13CImageDecoder8FileNewLER3RFsRK7TDesC16RK6TDesC8NS_8TOptionsE
    make[1]: *** [..\..\..\..\..\..\..\bin\TechView\EPOC32\RELEASE\ARMV5\UDEB\CameraApp.exe] Error -2


    Tkpk

  6. #6
    Regular Contributor
    Join Date
    Oct 2004
    Location
    india
    Posts
    306

    Re: jpg -> bmp conversion problem

    plzz chk thses
    1.)
    cimagedecoder supports from sdk 2.1 ...so,if ur using earlier version..it wont chk it.......

    2.)cimagedecoder .lib and .h files are to be mention in mmp and using classs respectively



    could u more precisely send the error!!!!!!!!!
    bye .......

  7. #7
    Registered User
    Join Date
    Oct 2005
    Posts
    3

    Re: jpg -> bmp conversion problem

    >2.)cimagedecoder .lib and .h files are to be mention in mmp and using classs respectively

    I added cimagedecoder.lib in mmp.It was solved.

    I had thought it was not necesary because it was omitted in Symbian9.1
    API Reference.

    Thanks,giridharn

Similar Threads

  1. how to get the width and height of a jpg or bmp
    By faqffq in forum Symbian User Interface
    Replies: 2
    Last Post: 2005-12-15, 10:49
  2. Replies: 1
    Last Post: 2003-03-05, 11:56
  3. Replies: 1
    Last Post: 2003-02-10, 16:15
  4. Problem with GPRS --> PC @ NOKIA 6510
    By kaer in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2002-10-15, 11:15
  5. Problem drawing a bmp in the View
    By yaney in forum Symbian User Interface
    Replies: 0
    Last Post: 2002-08-01, 12:19

Posting Permissions

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