Displaying bitmap without using mbm file ! Please help me ! Thanks very much !

Login to reply to this topic.
Mon, 2006-02-13 11:45
Joined: 2005-06-21
Forum posts: 107
Hi all!
At the present, I have a problem : " Displaying bitmap without using mbm file " . I try to search and do it but I can't. Have you finished this problem ? If you can do that, please give me a way for doing it or send example for me to search thanghq@unisoft.jp ! Thanks very much !

This is my source but It didn't perform. The emulator will close immediately when program is opened .

/************* CTopView.cpp *************************/
void CTopView::ConstructL( const TRect& aRect )
{
    //-----   create window-owning control
    CreateWindowL();
    SetRect( aRect );

    //-----   enable dragging
    EnableDragEvents();

    //-----   Create bitmap
    CFbsBitmap * aBmp = new CFbsBitmap;
    CleanupStack::PushL( aBmp );
    TSize iSz( 134,38 );
    aBmp->Create( iSz, EColor16M ); // 16bit
    // Get address of bitmap
    TUint8* pData = ( TUint8* )aBmp->DataAddress( );

    // Open the file and read its data
    _LIT( KBitmapFileName, "C:\\system\\data\\navigis\\map.bmp" );

    // Open a RFs
    RFs aFs;
    User::LeaveIfError( aFs.Connect() );
    CleanupClosePushL( aFs );
    // Open the file
    RFile file;
    file.Open( aFs, KBitmapFileName, EFileRead );
    CleanupClosePushL( file );

    // Read from the file
    TInt iSize;
    file.Size( iSize );
    HBufC8* buf = HBufC8::NewLC( iSize );
    TPtr8  pBuf = buf->Des();
    pBuf.Set( pData, iSize, iSize );
    file.Read( pBuf );

    //----   Views should be made invisible until ViewActivated has been called
    MakeVisible( EFalse );
    SetComponentsToInheritVisibility();
    ActivateL();
}

void CTopView::Draw(const TRect& aRect) const
{
      CWindowGc& gc = SystemGc();
      //-----   Area in which we shall draw
      TRect drawRect = Rect();
      gc.Clear();
      //-----   Draw an outline rectangle (the default pen
      //-----       and brush styles ensure this) slightly
      //-----       smaller than the drawing area.
      drawRect.Shrink( 10,10 );
      gc.DrawRect( drawRect );

      //-----      Draw file bmp
      gc.DrawBitmap( drawRect, aBmp );

}



Mon, 2006-02-13 17:23
Joined: 2005-07-28
Forum posts: 121
Re: Displaying bitmap without using mbm file ! Please help me !
Ok, do a search for the image conversion lib in the SDK docs.

You can load the image by supplying a file name, and the OS will convert it to a CFbsBitmap, which you can then use to draw on the screen.

I think the class your after might be CImageDecoder .

Good luck
Tue, 2006-02-14 03:06
Joined: 2005-06-21
Forum posts: 107
Re: Displaying bitmap without using mbm file ! Please help me !
Thanks very much ! But my bitmap is very large . If I use class CFbsBitmap for convert bitmap to mbm file, my program will occupy more memory. So I want to read .bmp from file. Please give me a way ! Thanks very much !
Tue, 2006-02-14 04:53
Joined: 2005-09-01
Forum posts: 15
Re: Displaying bitmap without using mbm file ! Please help me !
If you want to display it without converting it first, you must know the file format of the bmp file. So you can draw it to the screen pixel by pixel. but i think it will take a lot longer than you use the image decoder.

best regards
Ronald

best regards,
Ronald Stevanus

Tue, 2006-02-14 05:24
Joined: 2005-06-21
Forum posts: 107
Re: Displaying bitmap without using mbm file ! Please help me !
Thanks very much ! I want to use this way for load image but I didn't have example for search . Do you have example about this , please share to me . Thanks very much !
Wed, 2006-02-15 12:28
Joined: 2005-09-01
Forum posts: 15
Re: Displaying bitmap without using mbm file ! Please help me !
you can googling with keyword "bmp format", you'll find a lot of links that explain the bmp file format. good luck

best regards
Ronald

best regards,
Ronald Stevanus

Wed, 2006-02-15 17:43
Joined: 2004-06-08
Forum posts: 148
Re: Displaying bitmap without using mbm file ! Please help me !
you can find the example here

\UIQ_21\examples\MultiMedia\ImageConv
  • Login to reply to this topic.