×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    108

    How to open .gif files only ?

    Hi, I want to open .gif files only.
    I tried this:
    Code:
    	RDir dir;
    	User::LeaveIfError(dir.Open(iCoeEnv->FsSession(), framePath, KImageTypeGIFUid ));
    But it didn't work. Nothing was read in.
    What's the problem with it?

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

    Re: How to open .gif files only ?

    AFAIK RDir does not have any UI's implemented.

  3. #3
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    108

    Re: How to open .gif files only ?

    Then how do achieve that ?
    BTW, when I open the dir with KEntryAttNormal and read from it, the count of files read is less than what it should be. What's wrong here ?

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

    Re: How to open .gif files only ?

    Sorry I might have misunderstood your original post, anyway, the read should inceed have something in there that is filtered accordingly, so what it is that you have in the KImageTypeGIFUid ?

  5. #5
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,348

    Re: How to open .gif files only ?

    Then how do achieve that ?
    Can you explain your question more detailed?

    Also try to check these links:
    - Find Files
    - How to fetch media files

  6. #6
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: How to open .gif files only ?

    Use this active object:
    Code:
    // INCLUDES
    #ifndef CLOADIMAGE_H
    #define CLOADIMAGE_H
    
    #include <aknappui.h>
    #include <aknutils.h>
    #include <ImageConversion.h>
    #include "mobilepaint/cbitmaprotatorao.h"
    #include "prefs/LocaNoteGeneric.h"
    
    class CLocaNotePaint;
    
    
    class MLoadImageObserver
        {
        public:
            virtual void ImageLoaded()=0;
        };
    
    
    class CLoadImage : public CActive, MBitmapRotatorObserver
        {
        public:
            static CLoadImage* NewL(MLoadImageObserver* iContainer);
            static CLoadImage* NewLC(MLoadImageObserver* iContainer);
            virtual ~CLoadImage();
    
        public:
        	void LoadL(CFbsBitmap* aBitmap, TFileName& aFileName);
            void DoCancel();
            void RunL();
            TInt RunError(TInt aError);
            void GetEncoderImageTypesL(RImageTypeDescriptionArray& aImageTypeArray);
            TBool INRI();
            void LoadAndRotateL(CFbsBitmap* aBitmap, TFileName& aFileName);
            
        private:
            void ConstructL();
            CLoadImage();
         
        //Darn MBitmapRotatorObserver    
        private:
        	void RotationCompletedL(TInt aError);
        	
        private:
            CImageDecoder*          iImageDecoder;
            CBitmapRotatorAO* iBackBufferRotator;
            CFbsBitmap* targetBitmap;
            CFbsBitmap* localBitmap;
            RFs                     iFs;
            MLoadImageObserver*         iContainer;
            
            };
    
    #endif


    Code:
    /*
     * cloadimage.cpp
     *
     *  Created on: 09.02.2009
     *      Author: TAMHAN
     */
    
    #include "mobilepaint/cloadimage.h"
    
    #include "LocaNotePaint.h"
    
    CLoadImage* CLoadImage::NewL(MLoadImageObserver* iContainer)
        {
        CLoadImage* self = CLoadImage::NewLC(iContainer);
        CleanupStack::Pop (self );
        return self;
        }
    
    CLoadImage* CLoadImage::NewLC(MLoadImageObserver* iContainer)
        {
        CLoadImage* self = new ( ELeave ) CLoadImage();
        CleanupStack::PushL (self );
        self->iContainer=iContainer;
        self->ConstructL();
        self->iBackBufferRotator=NULL;
        self->iImageDecoder=NULL;
        return self;
        }
    
    CLoadImage::~CLoadImage()
        {
    	Cancel();
        if(iImageDecoder!=NULL)
        {
        	delete iImageDecoder;
        	iImageDecoder=NULL;
        }
        	iFs.Close();
        }
    
    void CLoadImage::LoadAndRotateL(CFbsBitmap* aBitmap, TFileName& aFileName)
    {
    	if (!IsActive())
    	{
    		if (iImageDecoder)
    		{
    			delete iImageDecoder;
    			iImageDecoder = NULL;
    		}
    
    		targetBitmap=aBitmap; //persist bitmap
            localBitmap = new (ELeave) CFbsBitmap;
    		iImageDecoder = CImageDecoder::FileNewL(iFs, aFileName);
            
    		localBitmap->Create(iImageDecoder->FrameInfo().iOverallSizeInPixels,EColor64K);
            
    		iImageDecoder->Convert(&iStatus, *localBitmap);
    		SetActive();
    	}
    }
    
    void CLoadImage::RotationCompletedL(TInt /*aError*/)
    {
    	TSize bmpSize = localBitmap->SizeInPixels();
    	
    	int scanLineLength = CFbsBitmap::ScanLineLength( bmpSize.iWidth, EColor4K );
    	   
    	if (targetBitmap && targetBitmap->DataAddress() )
    	{
    	   memcpy( (void*)targetBitmap->DataAddress(), (void*)localBitmap->DataAddress(), scanLineLength * bmpSize.iHeight );
    	}
    	
    	delete localBitmap;
    	localBitmap=NULL;
    	this->RunL();
    
    }
    
    void CLoadImage::LoadL(CFbsBitmap* aBitmap, TFileName& aFileName)
        {
        if (!IsActive())
            {    
            if (iImageDecoder)
                {
                delete iImageDecoder; 
                iImageDecoder = NULL;
                }
    		
    			localBitmap=NULL; //Just in case
    			iImageDecoder = CImageDecoder::FileNewL( iFs, aFileName);
            	iImageDecoder->Convert( &iStatus, *aBitmap);
            	SetActive();
            }
        }
    
    void CLoadImage::DoCancel()
        {
    	if(iBackBufferRotator!=NULL && iBackBufferRotator->IsActive())
    	{
    		iBackBufferRotator->Cancel();
    	}
    	if(iImageDecoder)
    	iImageDecoder->Cancel();
    	//cleanup moved to destructor
        }
    
    void CLoadImage::RunL()
        {
       //call iObserver - called when done
    	if(localBitmap==NULL)
    	{
    		iContainer->ImageLoaded();
    	}
    	else
    	{//rotate and call observer from there
    		if(localBitmap->SizeInPixels()==targetBitmap->SizeInPixels())
    		{
    			this->RotationCompletedL(KErrNone);
    		}
    		else
    		{
    		iBackBufferRotator=CBitmapRotatorAO::NewL(this);
    	    if (localBitmap->SizeInPixels().iWidth < localBitmap->SizeInPixels().iHeight)
    	        {
    	        iBackBufferRotator->Rotate(CBitmapRotator::ERotation270DegreesClockwise,localBitmap);
    	        }
    	    else
    	        {
    	        iBackBufferRotator->Rotate(CBitmapRotator::ERotation90DegreesClockwise,localBitmap);
    	        }
    		}
    	}
    	}
    
    TInt CLoadImage::RunError(TInt /*aError*/)
        {
        //call iObserver
        return KErrNone;
        }
        
    void CLoadImage::ConstructL()
        {
    	this->localBitmap=NULL;
        CActiveScheduler::Add(this);
        User::LeaveIfError( iFs.Connect() );
        }
    
    CLoadImage::CLoadImage(): CActive(EPriorityStandard)
        {
        }
    
    void CLoadImage::GetEncoderImageTypesL( 
        RImageTypeDescriptionArray& aImageTypeArray )
        {
        CImageEncoder::GetImageTypesL( aImageTypeArray );
        }
    
    TBool CLoadImage::INRI()
    {//when Jesus christ died, he said INRI. So does CLoadImage
     if(iImageDecoder!=NULL)
    	 return false;
     else
    	 return true;
    }
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

Similar Threads

  1. How to open .fep files
    By btt0128 in forum Symbian
    Replies: 1
    Last Post: 2006-08-08, 03:48
  2. Read and Open files with Series60
    By pablovara in forum Mobile Java General
    Replies: 2
    Last Post: 2006-06-14, 17:08
  3. open files list
    By irongate in forum Symbian
    Replies: 1
    Last Post: 2004-12-13, 14:37
  4. series 60 and .gif files
    By trishift in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2004-10-29, 09:19
  5. Replies: 1
    Last Post: 2004-10-14, 08:53

Posting Permissions

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