×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    15

    How to display an image

    Hi

    I am trying to display an image and a label in one of my container. Though my program doesnt crashes I dont see any image on the phone screen.

    I have inherited my class from CCoeControl and gettting image from the resource file.

    Any help is appreciated.

    Here is the resource file:

    RESOURCE IMAGE welcome_image
    {
    horiz_align=EEikLabelAlignHCenter;
    vert_align=EEikLabelAlignVTop;
    bmpfile="c:\\calypsosplash.mbm";
    bmpid=0;
    }

    Here is the .cpp file

    void CDirectionsWelcomeContainer::ConstructL(const TRect& aRect)
    {

    CreateWindowL();
    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( _L("Mapping") );
    iLabel->SetExtent(EDWIN_LABEL_POS, iLabel->MinimumSize());

    iImage=new (ELeave)CEikImage;
    iImage->SetContainerWindowL(*this);
    TResourceReader reader;
    iCoeEnv->CreateResourceReaderLC(reader, WELCOME_IMAGE);
    iImage->ConstructFromResourceL(reader);
    CleanupStack::PopAndDestroy(); // Resource reader
    SetRect(aRect);
    ActivateL();
    }

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

    Have you implemented your CountComponentControls() & ComponentControl()-functions correctly, so they would return both of your controls.

    And are you sure your image for CEikImage, is in right path and can be found correctly ?

    You could also try first loading your images & checking that they are loaded correctly and then use SetBitmap() & SetMask()-functions to set them to your CEikImage, then at least you would know that everything is working correctly.

    yucca

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    15
    Thanks for replying

    I do have CountComponentControls() & ComponentControl() functions implemented correctly. The code is pasted below for the container.

    Also I have kepy the imamge c:\symbian\6.1\series60\Epoc32\Wins\C directory. I copied calypsosplash.mbm from one of the examples.

    Can you tell me how can I first load the image and then use setBitmap & then use setmask to my CEikImage.

    Sorry if I am being naive.

    Regards

    Sunil.


    Here is the code:

    // ================= MEMBER FUNCTIONS =======================

    // ---------------------------------------------------------
    // CDirectionsContainer::ConstructL(const TRect& aRect)
    // EPOC two phased constructor
    // ---------------------------------------------------------
    //

    void CDirectionsWelcomeContainer::ConstructL(const TRect& aRect)
    {

    CreateWindowL();
    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( _L("Mapping") );
    iLabel->SetExtent(EDWIN_LABEL_POS, iLabel->MinimumSize());

    iImage=new (ELeave)CEikImage;
    iImage->SetContainerWindowL(*this);
    TResourceReader reader;
    iCoeEnv->CreateResourceReaderLC(reader, WELCOME_IMAGE);
    iImage->ConstructFromResourceL(reader);
    CleanupStack::PopAndDestroy(); // Resource reader

    //iImage->SetExtent(EDWIN_POS2, iImage->MinimumSize());

    iLabel1 = new (ELeave) CEikLabel;
    iLabel1->SetContainerWindowL( *this );
    iLabel1->SetTextL( _L("Test") );
    iLabel1->SetExtent(EDWIN_LABEL_POS2, iLabel1->MinimumSize());

    SetRect(aRect);
    ActivateL();
    }

    // Destructor
    CDirectionsWelcomeContainer::~CDirectionsWelcomeContainer()
    {
    delete iLabel;
    delete iLabel1;
    delete iImage;
    }

    // ---------------------------------------------------------
    // CDirectionsContainer::SizeChanged()
    // Called by framework when the view size is changed
    // ---------------------------------------------------------
    //
    void CDirectionsWelcomeContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    //iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
    //iToDoLabel->SetExtent( TPoint(10,100), iToDoLabel->MinimumSize() );
    }

    // ---------------------------------------------------------
    // CDirectionsContainer::CountComponentControls() const
    // ---------------------------------------------------------
    //
    TInt CDirectionsWelcomeContainer::CountComponentControls() const
    {
    return 3; // return nbr of controls inside this container
    }

    // ---------------------------------------------------------
    // CDirectionsContainer::ComponentControl(TInt aIndex) const
    // ---------------------------------------------------------
    //
    CCoeControl* CDirectionsWelcomeContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
    {
    case 0:
    return iLabel;
    case 1:
    return iImage;
    case 2:
    return iLabel1;
    default:
    return NULL;
    }
    }

    // ---------------------------------------------------------
    // CDirectionsContainer::Draw(const TRect& aRect) const
    // ---------------------------------------------------------
    //
    void CDirectionsWelcomeContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbGray);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
    }

    // ---------------------------------------------------------
    // CDirectionsContainer::HandleControlEventL(
    // CCoeControl* aControl,TCoeEvent aEventType)
    // ---------------------------------------------------------
    //
    void CDirectionsWelcomeContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    // TODO: Add your control event handler code here
    }

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

    Your code looks good to me, dunno really why you are not getting anything to the screen. Anyway to load the images just use CFbsBitmap-object, it's well documented & easy to use and after succesfull loading just set it by using the functions provided by CEikImage (well documented as well).

    yucca

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    15
    Yucca

    do I need to put anything in .mpp file in order to make my image to work?

    regards

    Sunil

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    15
    Yucca

    I just checked that I am able to load the bitmap using CFbsBitmap function. bitmap->Load(imagen,0) returns zero which means success. The data.mbm file contain one bit map file only.

    However I am still not able to load the image using SetBitmap and SetMask functions. Do I need to overwrite the Draw function of the container?

    regards

    Sunil

    the new code is pasted below:

    CreateWindowL();
    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( _L("Mapping") );
    iLabel->SetExtent(EDWIN_LABEL_POS, iLabel->MinimumSize());

    _LIT (imagen,"c:\\system\\apps\\data.mbm");

    // load the bitmap from an .mbm file
    bitmap = new (ELeave) CFbsBitmap();
    CleanupStack::PushL(bitmap);
    TInt ret = bitmap->Load(imagen,0);
    CleanupStack::PopAndDestroy();

    iImage=new (ELeave)CEikImage;
    iImage->SetContainerWindowL(*this);
    iImage->SetBitmap(bitmap);
    iImage->SetMask(0);
    /*
    TResourceReader reader;
    iCoeEnv->CreateResourceReaderLC(reader, WELCOME_IMAGE);
    iImage->ConstructFromResourceL(reader);
    CleanupStack::PopAndDestroy(); // Resource reader
    */

    iLabel1 = new (ELeave) CEikLabel;
    iLabel1->SetContainerWindowL( *this );
    iLabel1->SetTextL( _L("by V-Enable") );
    iLabel1->SetExtent(EDWIN_LABEL_POS2, iLabel1->MinimumSize());

    SetRect(aRect);
    ActivateL();
    }

  7. #7
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166
    Hi Sunil

    I'm still puzzled why it doesn't work, your code looks good enough. Anyway in case you want, you could send project to me (jusilven@hotmail.com) and I'll look into it, propably can get it fixed a lot faster that way.

    yucca

  8. #8
    Registered User
    Join Date
    Nov 2003
    Posts
    26

    performing image processing

    reading the messages in this post , i was wondering how to capture the displayed image's data and apply some standard perform image processing algorithms on it

  9. #9
    Registered User
    Join Date
    Nov 2005
    Posts
    23

    Re: How to display an image

    can u tell me how to access pixels in bitmaps?
    using which api's can we read and write bmpfiles?

Posting Permissions

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