×

Discussion Board

Results 1 to 4 of 4

Hybrid View

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    1

    dynamic image loading

    hi all,

    i want to create a slide show of all jpg images that is in my phone. is the Image class the appropriate class for this? if so how do i specify the location of the image file?

    so far, all examples i've read involves compiling the image together with the code to form one jar file in order to use Image.createImage().

    i have a N6020 (series 40) phone unit.

    thanks.

  2. #2
    Nokia Developer Expert
    Join Date
    Jun 2005
    Posts
    923

    Re: dynamic image loading

    Hello,

    Unless you phone supports the FileConnection and PIM API, you are not allowed to see the images in your gallery from Java code, that's why all the examples you've seen have the .jpg compiled along with the .jar file.

    In your specific case, the N6020, it does not have the FileConnection and PIM API implemented, so it is impossible.

    Daniel

  3. #3
    Registered User
    Join Date
    Nov 2005
    Location
    PHILIPPINES
    Posts
    16

    Re: dynamic image loading

    You can use this code:

    Code:
    /*
    ============================================================================
     Name        : ImageLoader.h
     Author      : 
     Version     :
     Copyright   : Your copyright notice
     Description : ImageLoader.h - header file
    ============================================================================
    */
    
    #ifndef IMAGELOADER_H
    #define IMAGELOADER_H
    
    #include <e32base.h> //CActive Scheduler
    #include <MdaImageConverter.h> //Image Conversion
    //#include <ImageConversion.h>
    
    class CImageLoader:/*public CActive,*/ public MMdaImageUtilObserver
    {
    
    	public:
    		CImageLoader();		
    		
    		~CImageLoader();
    	
    		CFbsBitmap* ReadImageL(const TDesC& aFileName);
    		void CImageLoader::SaveFile();
    		CFbsBitmap* ScaleDown(TInt newWidth, TInt newHeight);
    
    	public: //From MMdaImageUtilObserver
    
    		virtual void MiuoOpenComplete(TInt aError);
    		virtual void MiuoConvertComplete(TInt aError);
    		virtual void MiuoCreateComplete(TInt aError);
    		
    		
    	private: //Track conversion of image
    		enum TConvertState
    		{
    			EConvertStateNull,
    			EConvertStateConvertingFromPng,
    			EConvertStateReady,
    			EConvertStateScaling,
    		} iConvertState;
    
    	private: //Constructor, Destructor
    
    		//~CImageLoader();
    	
    	private:
    
    		//TDesC*				iFilename;
    		CMdaImageFileToBitmapUtility*		iConverter;
    		CFbsBitmap*			iBitmap;
    		//RTimer*				iTimer;
    		TInt				iErrorCode;
    		CMdaBitmapScaler*	iScaler;
    		TInt	aError;
    
    		// Image files saver
    		CImageEncoder* iEncoder;
    
    		// File server handle
    		//RFs& iFs;
    
    };
    
    #endif // IMAGELOADER_H
    
    // End of File
    Code:
    /*
    ============================================================================
     Name        : ImageLoader.cpp
     Author      : 
     Version     :
     Copyright   : Your copyright notice
     Description : ImageLoader.cpp - source file
    ============================================================================
    */
    
    // INCLUDE FILES
    // Class include
    #include "ImageLoader.h"
    #include <coemain.h>
    //#include <bautils.h>
    //#include <ImageConversion.h>
    
    #define IMAGEREAD_TIMEOUT 5 * 1000 * 1000
    
    static const TDisplayMode KDeviceColourDepth = EColor4K;
    static const TInt KPngFrameIndex = 0;
    
    
    CImageLoader::CImageLoader(/*const TDesC *aFilename*/)//:CActive(CActive::EPriorityStandard)
    {
       // make a local copy of the filename
       //iFilename = aFilename->Alloc();
    }
    
    CImageLoader::~CImageLoader()
    {
       // deallocate all data
       //delete iFilename;
       //delete iTimer;s
       delete iConverter;
       delete iBitmap;
       delete iScaler;
    }
    
    
    CFbsBitmap* CImageLoader::ReadImageL(const TDesC& aFileName)
    {
    
    	// create + initialize operation timeout timer
    	//iTimer = new RTimer();
    	//iTimer->CreateLocal();
    
    	// set timeout for the image read + conversion process
    	//iTimer->After(iStatus, IMAGEREAD_TIMEOUT);
    	//SetActive();
    
    	// start loading the image
    	//iFilename = aFilename->Alloc();
    
    	
    
    	iConverter = CMdaImageFileToBitmapUtility::NewL(*this);
    	iConverter->OpenL(aFileName);
    	
    
    	CActiveScheduler::Start();
    
    	/*if (iBitmap->IsLargeBitmap())
    	{	*/
    	//	ScaleDown(50, 50);
    	//}
       //iBitmap->Save(aFileName);
    	/*RFs fsSession = CCoeEnv::Static()->FsSession();
    
    	TInt err = BaflUtils::CopyFile(fsSession, aFileName, _L("c:\\Nokia\\Images\\simangot2.jpg"));
    
    	if (err = KErrNone)
    		return iBitmap;*/
    	return iBitmap;
    }
    
    
    // called when OpenL() finishses
    void CImageLoader::MiuoOpenComplete(TInt aError)
    {
       if( aError != KErrNone ) 
       {
           iErrorCode = aError;
           //Cancel();  //Called through CActiveScheduler
           return;
       }
    
       TFrameInfo info;
       iConverter->FrameInfo(0, info);
            
       // create a bitmap to write into 
       iBitmap = new (ELeave) CFbsBitmap();
       TInt rc = iBitmap->Create(info.iOverallSizeInPixels, KDeviceColourDepth);
       
       if( rc != KErrNone )
       {
         iErrorCode = rc;
         //Cancel();
         return;
    	}
    
        // convert the gif into a bitmap
        TRAPD(error, iConverter->ConvertL(*iBitmap));
        
        // handle the error
       if( error != KErrNone)
       {
         iErrorCode = error;
         //Cancel();
         return;
        }
    }
    
    
    // called when ConvertL() finishes
    void CImageLoader::MiuoConvertComplete(TInt aError)
    {
       if( aError != KErrNone )
       {
           iErrorCode = aError;
           //Cancel();
           return;
       }
    
       CActiveScheduler::Stop();
       //Cancel();
       iConverter->Close();
    
    }
    
    //Uncalled
    void CImageLoader::MiuoCreateComplete(TInt /*aError*/)
    {
    }
    
    //bitmap scaler
    CFbsBitmap* CImageLoader::ScaleDown(TInt newWidth, TInt newHeight)
    	{
    	TInt KNewImageWidth = newWidth;
    	TInt KNewImageHeight = newHeight;
    	iScaler = CMdaBitmapScaler::NewL();
    
    	TRAPD(err,iScaler->ScaleL(*this,*iBitmap,TSize(KNewImageWidth,KNewImageHeight)));
    	CActiveScheduler::Start();
    
    	if (err == KErrNone)
    		{
    		iConvertState = EConvertStateScaling;
    		}
    	
    	return iBitmap;
    	}
    
    
    void CImageLoader::SaveFile()
    {
    	//_LIT(KPictureDir,"c:\\Nokia\\Images\\simangot2.bmp");
    	////_LIT(KMimeType,"image/jpg");
    
    	//RFs fsSession = CCoeEnv::Static()->FsSession();
    	//iEncoder = CImageEncoder::FileNewL(*fsSession, KPictureDir, KMimeType);
    	//
    	//TJpegImageData* data = new (ELeave) TJpegImageData;
    	//// Set some format specific data
    	//data->iSampleScheme = TJpegImageData::EColor444;
    	//data->iQualityFactor = 80;
    
    	//CFrameImageData* iFrameImageData = CFrameImageData::NewL();
    
    	////frameData - ownership passed to iFrameImageData after AppendImageData
    	//User::LeaveIfError(iFrameImageData->AppendImageData(data));
    
    	//TRequestStatus iStatus;
    	//iEncoder->Convert( &iStatus, *iBitmap, iFrameImageData);
    
    	//BaflUtils::CopyFile(iFs, _L("C:\\a.txt"), _L("c:\\Nokia\\Images\\simangot2.bmp"));
    }
    	
    // End of File

  4. #4
    Nokia Developer Expert
    Join Date
    Jun 2005
    Posts
    923

    Re: dynamic image loading

    Uh, I think the original poster was referring to Java, as he posted his question in "Mobile Java" section.

    Daniel

Similar Threads

  1. HELP: Mutable Image to Immutable Image?
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-26, 09:58
  2. Replies: 0
    Last Post: 2005-03-08, 08:14
  3. loading images from device's image folder
    By dotcdotc in forum Symbian Media (Closed)
    Replies: 15
    Last Post: 2004-11-28, 06:58
  4. 3650 and Image loading
    By ross666 in forum Mobile Java General
    Replies: 6
    Last Post: 2003-09-30, 17:15
  5. Loading Image data from 'raw' bytes
    By LongSteve in forum Mobile Java General
    Replies: 2
    Last Post: 2002-11-20, 17:38

Posting Permissions

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