The custom Symbian image control allows you to place images in any location.

Source: Internet
Author: User

First, this control class is provided:

Header file:

# Ifndef cmypicture_h
# Define cmypicture_h

// Des
# Include <e32std. h>
# Include <e32base. h>
# Include <f32file. h>
# Include <FBS. h>
# Include <coecntrl. h>

// Class declaration

// Class RFS;
Class cmypicture: Public ccoecontrol
{
Public: // constructors and destructor

/**
* Destructor.
*/
~ Cmypicture ();

/**
* Two-phased constructor.
*/
Static cmypicture * newl ();

/**
* Two-phased constructor.
*/
Static cmypicture * newlc ();

Public:

/**
* Constructor for Ming 1st Stage Construction
*/
Cmypicture ();

/**
* EPOC default constructor for faster Ming 2nd Stage Construction
*/
Void constructl ();

Virtual void draw (const trect & arect) const;
Void setpicture (tdesc & afilepath );
Void setvisiable (tbool avisiable );
Void getpng (RFS & AFS, const tdesc & afilepath, cfbsbitmap * ibitmap, cfbsbitmap * ibmpmask );
PRIVATE:
Tbuf <100> ifilepath;
Rfs fs;
Cfbsbitmap * ibitmapback;
Cfbsbitmap * ibitmapbackmask;
Tbool ibvisiable;

};

# Endif // cmypicture_h

Then the CPP file:

# Include "cmypicture. H"
# Include <eikenv. h>
# Include <imageconversion. h>

Cmypicture: cmypicture ()
{
// No implementation required
}

Cmypicture ::~ Cmypicture ()
{
}

Cmypicture * cmypicture: newlc ()
{
Cmypicture * Self = new (eleave) cmypicture ();
Cleanupstack: pushl (Self );
Self-> constructl ();
Return self;
}

Cmypicture * cmypicture: newl ()
{
Cmypicture * Self = cmypicture: newlc ();
Cleanupstack: Pop (); // self;
Return self;
}

Void cmypicture: constructl ()
{

Createmediawl ();
FS = ieikonenv-> fssession ();
Ibitmapback = new (eleave) cfbsbitmap ();
Ibitmapbackmask = new (eleave) cfbsbitmap ();
_ Configure (kbackpath, "C: \ System \ apps \ SG \ back2.png ");
Getpng (FS, kbackpath, ibitmapback, ibitmapbackmask );
Ibvisiable = etrue;
}

Void cmypicture: setpicture (tdesc & afilepath)

{
Ifilepath = afilepath;

}

Void cmypicture: setvisiable (tbool avisiable)

{
Ibvisiable = avisiable;
Drawnow ();
}

Void cmypicture: getpng (RFS & AFS, const tdesc & afilepath, cfbsbitmap * ibitmap, cfbsbitmap * ibmpmask)

{
_ Lit8 (mimetype, "image/PNG ");
Cimagedecoder * imagedecoder = cimagedecoder: filenewl (AFS, afilepath,
Mimetype,
Cimagedecoder: eoptionalwaysthread
);
Ibitmap-> Create (imagedecoder-> frameinfo (). ioverallsizeinpixels,
Imagedecoder-> frameinfo (). iframedisplaymode/* was ecolor4k */);
// Its a ecolor16m
Ibmpmask-> Create (imagedecoder-> frameinfo (). ioverallsizeinpixels, egray256/* was egray2 */);
Trequeststatus status;
Imagedecoder-> convert (& status, * ibitmap, * ibmpmask );
User: waitforrequest (Status );
Delete imagedecoder;

}

Void cmypicture: Draw (const trect & arect) const
{
Cwindowgc & GC = systemgc ();
If (ibvisiable)
{
Trect BMP emapiecerect (tpoint (0, 0), ibitmapback-> sizeinpixels ());
GC. bitbltmasked (tpoint (10, 10), ibitmapback, BMP emapiecerect, ibitmapbackmask, etrue );
}

}

You can use this class to implement custom image controls.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.