You Are Here:

Community: Developer Discussion Boards

#1 Old Encoding GIF - 2005-09-19, 12:28

Join Date: Jul 2005
Posts: 95
razas's Avatar
razas
Offline
Regular Contributor
I am trying to write a screen capture app . In the program when the screen is captured it gets saved in a .mbm format . The program then opens that file and encodes it in a format that is read from a file located on disk . The problem is that say for example I try to convert the .mbm file to a gif format or whetever other format for that matter, it does get converted but the .gif file does not show the actual image.
Below is my code and Ill really appreciate it if you could suggest any corrections in my code . If you need to look at some more code of mine to solve the problem Ill be glad to share that.


Thanks a lot :)

Code:
_LIT(KFormatGif,"GIF");

TBuf8 <4> gif ;

gif.Copy(KFormatGif);

void CMyAppContainer::ConstructL(const TRect& aRect)
{
    CreateWindowL();
    SetRect(aRect);
    InitComponentsL();
    ActivateL();

    iConverter = CMdaImageFileToBitmapUtility::NewL(*this);

    iFileSaver = CMdaImageBitmapToFileUtility::NewL(*this);
        
           
        


}


void CMyAppContainer::EncodeImage()
{


	//Read the required format from the file

	...

	...

	//If the format is GIF encode for GIF


	if(buf.Compare(gif) == 0) //Encode the image as gif
	{

          

           targetfilename.Append(_L(".gif"));
                    
           iConverter->OpenL(FileFullName);
                              
           iConvertState = EConvertStateReady ;
                 
           SaveL(); 

           ShowConfirmation(_L("Screen has been saved in the images folder")); 

//ShowConfirmation() shows a global message containing the text of its parameter.
           
           iConverter->Close();

	}

}

void CMyAppContainer::SaveL()
        {


          iLog.Write(_L("SaveL() entered"));
        if (iConvertState != EConvertStateReady)
                {
                return;
                }

  


              
        iFileSaver->CreateL(targetfilename,&iClipFormat,&iCodec,&iCodec);
      
            
        iConvertState = EConvertStateSaving;

        }


void CMyAppContainer::MiuoConvertComplete(TInt aError)
        {

           iLog.Write(_L("MiuoConvertComplete() entered"));
        switch (iConvertState)
                {
                //Finished converting gif file to bitmap
                case EConvertStateConvertingFromGif:
                        ConvertingFromGifFinished(aError);
                        break;
                //Finished saving file
                case EConvertStateSaving:
                        SavingFinished(aError);
                        break;
                //Finished Scaling file
                case EConvertStateScaling:
                        ScalingFinished(aError);
                        break;
                //Finished Rotating file
                case EConvertStateRotating:
                        RotatingFinished(aError);
                        break;
                case EConvertStateNull:
                default:
                        ASSERT(FALSE);
                }

        }

void CMyAppContainer::MiuoCreateComplete(TInt aError)
        {

          
    _LIT(KConvertErrTxt,              "Conversion could not be started");
    _LIT(KCreateErrTxt,               "File Could not be created");

        if (aError == KErrNone)
                {
                //Now the bitmap file has been created, write the bitmap to it
                TRAPD(err,iFileSaver->ConvertL(*iBitmap1));

                if (err != KErrNone)
                        {
                        ShowConfirmation(KConvertErrTxt);
                        }
                }
        else
                {
                //Reset state so that other operations can still be performed
                iConvertState = EConvertStateReady;
                ShowConfirmation(KCreateErrTxt);
                }


                iConverter->Close();
                
                iLog.Write(_L("MiuoCreateComplete() ends"));
        }

void CMyAppContainer::MiuoOpenComplete(TInt aError)
{

          iLog.Write(_L("MiuoOpenComplete() entered"));
    _LIT(KConnectErrTxt,            "Could not connect to font and bitmap server");
    _LIT(KSizeErrTxt,               "Illegal Gif file size");
    _LIT(KConverterErrTxt,          "Cannot initiate converter");
    _LIT(KInsufficientInfoErrTxt,   "Gif file contains insufficient information, cannot 

retry");
    _LIT(KFileErrTxt,               "Error opening file");

        if (aError == KErrNone)
                {
                iConvertState = EConvertStateConvertingFromGif;

                TFrameInfo frameInfo;
                //Get the frame info
                iConverter->FrameInfo(KGifFrameIndex,frameInfo);

                //Create a bitmap based on the size of the gif
                TInt err = 

iBitmap1->Create(frameInfo.iOverallSizeInPixels,KDeviceColourDepth);
                if (err == KErrCouldNotConnect)
                        {
                        ShowConfirmation(KConnectErrTxt);
                        return;
                        }
                if (err == KErrArgument)
                        {
                        ShowConfirmation(KSizeErrTxt);
                        return;
                        }
                        
                

                //Convert the gif into a bitmap
                TRAPD(convertErr,iConverter->ConvertL(*iBitmap1,KGifFrameIndex));

                //Trap error as this function cannot leave
                if (convertErr != KErrNone)
                        {
                        ShowConfirmation(KConverterErrTxt);
                        }

                }

        else if (aError == KErrUnderflow)
                {
                //This error occurs if the gif file contains insufficient information
                //This is usually because the file is being opened in a cache so a futher 

attempt to open
                //should be performed
                TRAPD(err,iConverter->OpenL(FileFullName));
                if (err !=KErrNone)
                        {
                        ShowConfirmation(KInsufficientInfoErrTxt);
                        }
                }

        else
                {
                ShowConfirmation(KFileErrTxt);
                }

        }

void CMyAppContainer::SavingFinished(TInt aError)
        {

           iLog.Write(_L("SavingFinished() entered"));
    _LIT(KFileSaveTxt,                  "File Saved");
    _LIT(KFileSaveErrTxt,               "Error saving image");

        if (aError == KErrNone)
                {
                iConvertState = EConvertStateReady;
                ShowConfirmation(KFileSaveTxt);
                }
        else
                {
                ShowConfirmation(KFileSaveErrTxt);
                }
        }
Reply With Quote

#2 Old Re: Encoding GIF - 2005-09-20, 12:37

Join Date: Jul 2005
Posts: 95
razas's Avatar
razas
Offline
Regular Contributor
Yippee !! , I fixed it :).

Thanks. :)
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
gif animations+smil file Haaki General Messaging 1 2003-10-24 14:50
Animated GIF for MMS Specifications handtap General Messaging 2 2003-08-22 10:46
Animated GIF in 7650 martinlee18 General Messaging 5 2003-08-22 07:48
embed color gif file in wml page cannot load hsinyee Browsing and Mark-ups 2 2003-05-30 04:35
image format - gif 87a, gif 89a valia General Browsing 1 2003-05-08 09:50

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ