To draw .PNG files

Login to reply to this topic.
Thu, 2006-03-09 10:07
Joined: 2006-03-03
Forum posts: 9
Hello all,

Is it possible to draw the PNG files to screen using the gc.DrawBitmap(..  method

Pls share with me , how to make it...
=>gc is CWindowGC

Thanx in adv

Thu, 2006-03-09 11:30
Joined: 2003-12-20
Forum posts: 85
Re: To draw .PNG files
hi,

yes u can draw a .png by using CWindowGC -> gc

try to use and read
CMdaImageFileToBitmapUtility
MMdaImageUtilObserver


   void MiuoCreateComplete(TInt aError);
   void MiuoOpenComplete(TInt aError);
   void MiuoConvertComplete(TInt aError);


u can not only draw the .PNG but u can alos draw the

   _LIT(KWildName1, "*.bmp");
   _LIT(KWildName2, "*.mbm");
   _LIT(KWildName3, "*.jpg");
   _LIT(KWildName4, "*.wbmp");
   _LIT(KWildName5, "*.ota");
   _LIT(KWildName6, "*.gif");
   _LIT(KWildName7, "*.tiff");
   _LIT(KWildName8, "*.png");
   _LIT(KWildName9, "*.wmf");

u just need to read the above classes and try to find about abt them

plz feel free if u have any problem

with regards
kmsoomro
Sat, 2006-03-11 16:44
Joined: 2004-11-29
Forum posts: 1155
Re: To draw .PNG files
Just remember to NOT load the file in the Draw function.

load it to a CFbsBitmap in ConstructL and reuse it in Draw

Loading it in draw would make your program very slow and eat batteries.
Thu, 2006-12-21 08:48
Joined: 2006-03-01
Forum posts: 11
Re: To draw .PNG files
Use the following function to decode png image.
call it like this

_LIT(KImagePath,"\\system\\apps\\mobiletv\\bird1.png");
CFbsBitmap *iBitmap = new(ELeave) CFbsBitmap;
iurObject->GetPng(iBitmap,KImagePath);


For displaying the image use inside ur cocecontrol::Draw()
method as:
gc.BitBlt( Tpoint(10,70), iBitmap);
//
//
//
///// Make the function defination for GetPng Like this/////

GetPng(const TDesC& afilepath,CFbsBitmap* iBitmap,CFbsBitmap* iBmpMask )
{
   
   TFileName filename(afilepath);   
   User::LeaveIfError (CompleteWithAppPath (filename));
   filename.TrimAll();
   
   
   CImageDecoder* idecoder;
   
   TRAPD(err,idecoder = CImageDecoder::FileNewL(CEikonEnv::Static()->FsSession(),
      filename ,_L8("image/png"),
      CImageDecoder::EOptionAlwaysThread));
   if(err !=KErrNone)
   {
      //do something
   }
   TFrameInfo iFrameInfo = idecoder->FrameInfo(0);
   
   iBitmap->Create(iFrameInfo.iOverallSizeInPixels,iFrameInfo.iFrameDisplayMode );
   
   TRequestStatus aStatus = KRequestPending;
   
TRAPD(err1,idecoder->Convert( &aStatus, *iBitmap,0 ));
   User::WaitForRequest( aStatus );   
   delete idecoder;
   
}
/////////////////////////////////////////////////////////////////////
Tue, 2007-10-09 09:33
Joined: 2007-10-01
Forum posts: 42
Re: To draw .PNG files

Hi

can u give me the code of CompleteWithAppPath (filename) method.

thanks
Hidayath

Thu, 2007-10-11 10:00
Joined: 2004-11-29
Forum posts: 1155
Re: To draw .PNG files

No he can't, because that is S60 code.

You can use it by including the "aknutils.h" header file.

Wed, 2008-06-18 13:15
Joined: 2007-07-31
Forum posts: 140
Re: To draw .PNG files

can we not draw the png file direct?
i.e Without converting it into CFbsBitmap and then drawing using bitblt? because when i display the png image using above method , it does not give masking effect...

please paste some code to display png file direct.
Brajesh....


Life is too short ! so do as many good things as you can do...
Brajesh Kumar...
Beginner in Symbian C++

Wed, 2008-06-18 13:29
Joined: 2005-11-20
Forum posts: 1145
Re: To draw .PNG files

I am pretty sure that Symbian does not offer a way to display PNG directly. That would simply not make sense, from the viewpoint of display system architecture.

Anyway, what exactly do you mean with "masking effect"?


René Brunner

Wed, 2008-06-18 13:44
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 1913
Re: To draw .PNG files

You cannot draw a PNG "directly" as rbrunner said. So you need to convert it to two CFbs Bitmap: one for the data and one for the mask so that you can have the transparency effect.


Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Wed, 2008-06-18 16:04
Joined: 2004-11-29
Forum posts: 1155
Re: To draw .PNG files

I assume the problem is you do something wrong so that you lose the alpha (transparency) information when you decode your image.

You have to let CImageDecoder create the mask for you too, and then use BitBltMasked

Edit: As eric says... Smiling well, I guess I contributed by noting you need to use BitBltMasked too Smiling

Thu, 2008-06-19 06:40
Joined: 2007-07-31
Forum posts: 140
Re: To draw .PNG files

how the CImageDecoder will handle for masking ?

please give me some fully functional code to draw png file with masking property.

i will be thankfull to you...

Brajesh


Life is too short ! so do as many good things as you can do...
Brajesh Kumar...
Beginner in Symbian C++

  • Login to reply to this topic.