| Reply | « Previous Thread | Next Thread » |
|
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);
}
}
|
|
Yippee !! , I fixed it :).
Thanks. :) |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| 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 |