×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    24

    display a bitmap?

    Hi,
    I have some problem with displaying a bitmap. heres my code

    // in ConstructL()


    iBitmap = new (ELeave) CFbsBitmap();
    _LIT(KPath,"C:\\new.mbm");
    TDesC file = KPath;
    iBitmap->Load(file); // return kerrnone


    // in Draw()

    CWindowGc& gc = SystemGc();
    gc.Clear(aRect);
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbBlack);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
    gc.Clear(Rect());

    gc.BitBlt(TPoint(10,10), iBitmap); // USER BREAKPOINT, WSERV ..7, WHICH IS, INVALID BITMAP HANDLE
    //gc.DrawBitmap(TPoint(10,10), iBitmap); // EVEN WITH THIS ALSO THE SAME CASE

    But I had created mbm file and i guess its correct, i dont know why it says invalid bitmap handle? Does the size of the bitmap has an effect on it?
    can anybody find any problem with this code?

    Thanks

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167
    the most propable cause is that your bitmap Load function fails, so add User::LeaveIfError() around it to make sure you get the error description there already.

    yucca

  3. #3
    Registered User
    Join Date
    May 2004
    Location
    Finland
    Posts
    14
    Have you checked your apps path?

    iBitmap = new (ELeave) CFbsBitmap();
    _LIT(KPath,"C:\\new.mbm");
    TDesC file = KPath;
    iBitmap->Load(file); // return kerrnone

    If you use _LIT(KPath, "Z:\\new.mbm"); above,
    your load method might work.

  4. #4
    Nokia Developer Expert
    Join Date
    Apr 2003
    Location
    Finland
    Posts
    425
    Hello,

    I have succeeded with this:

    Code:
    private:
        CFbsBitmap* iImageBitmap;
    <...>
    void CMyAboutControl::Draw(const TRect& aRect) const
    {
        CWindowGc& gc = SystemGc();
        gc.Clear( aRect );
        TRect imageRect ( 0, 0, iImageBitmap->SizeInPixels().iWidth, iImageBitmap->SizeInPixels().iHeight);
        if ( aRect.Intersects( imageRect ) )
        {
            imageRect.Intersection( aRect );
            gc.UseBrushPattern( iImageBitmap );
            gc.SetPenStyle( CGraphicsContext::ENullPen );
            gc.SetBrushStyle( CGraphicsContext::EPatternedBrush );
            gc.SetBrushOrigin( TPoint( 0,0 ) );
            gc.DrawRect( imageRect );
            gc.DiscardBrushPattern();
        }
    Br V

Posting Permissions

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