Discussion Board

Results 1 to 10 of 10

Thread: convert bitmap

  1. #1
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    162

    convert bitmap

    Hi guys,

    I still have the problem, that I want to convert from class CFbsBitmap to class CWsBitmap, because I need a faster bitmap-handle.
    How to do that?
    Please help me.

    Best regards
    Christian

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

    I have not used CWsBitmap ever, but after quick peek to SDK help i think there is no way to convert to CWSBitmap. Instead you should create directly to this type.

    Instead createing of iBitmap create iWsBitmap, and becase CWsBitmap is derived from CFbsBitmap all functionality is available.

    Code:
        const TInt bitmapId = 0;
    
        CFbsBitmap* iBitmap = new(ELeave)CFbsBitmap;
        TInt err1 = iBitmap->Load(_L("c:\\mybitmaps.mbm"), bitmapId);
    
        CWsBitmap* iWsBitmap = new(ELeave)CWsBitmap;
        TInt err2 = iWsBitmap->Load(_L("c:\\mybitmaps.mbm"), bitmapId);
    
    link with:
    LIBRARY fbscli.lib
    LIBRARY ws32.lib
    Br V

  3. #3
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    162
    Hi veskola,
    many thanks for your reply.
    I feared, that it is impossible.
    Now I tried to simply load from file (*.mbm), but it always crashes.
    I made it as you wrote, and as the sdk says, but it crashes in line iWsBitmap->Load(_L("c:\\mybitmaps.mbm"), bitmapId);

    My code (constructor):

    iBitmap = new (ELeave) CWsBitmap();
    iBitmap->Load(_L("c:\\system\\apps\\myprog_3\\valo_vga.mbm"), 0);

    I can't believe it. Naturally it is simple, isn't it?
    Have you tried it?

    Best regards
    Christian

    p.s.: Besides it's strange, that the Load()-method is declared once again, although the CWsBitmap-class is derived from CFbsBitmap. The structure is the same.
    Why?
    Last edited by chrishawaii; 2005-07-28 at 11:12.

  4. #4
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    162
    O.K. only half an hour later I got it.
    Construction of class CWsBitmap has follow this rule:

    iBitmap = new (ELeave) CWsBitmap(iEikonEnv->WsSession());

    A connection to the server has to be started before.
    And don't forget to include eikenv.h.

    Best regards
    Christian

  5. #5
    Nokia Developer Expert
    Join Date
    Apr 2003
    Location
    Finland
    Posts
    425
    Hi,

    Yes, i just wrote to visual studio following after i found this:
    CWsBitmap()
    CWsBitmap();
    Description
    Default constructor. Developers should use the other constructor overload.
    Code:
        const TInt bitmapId = 0;
        CFbsBitmap* iBitmap = new(ELeave)CFbsBitmap;
        TInt err1 = iBitmap->Load(_L("c:\\epaimsgui.mbm"), bitmapId);
    
        RWsSession* wsSession = &(iEikonEnv->WsSession());
        CWsBitmap* iWsBitmap = new(ELeave)CWsBitmap(*wsSession);
        TInt err2 = iWsBitmap->Load(_L("c:\\epaimsgui.mbm"), bitmapId);
    
        CWsBitmap* iWsBitmap2 = new(ELeave)CWsBitmap();
        TInt err3 = iWsBitmap->Load(_L("c:\\epaimsgui.mbm"), bitmapId);
    There can be a good reason to overwrite that Load mathod in the CWsBitmap, consider:

    Code:
    CWsBitmap::Load()
    {
        <Some additional code>
        CFbsBitmap::Load ();
        <Some additional code>
    }
    If you are workin at Symbian (or at Nokia) you can see this additional code, but if not you can see only header and wonder why there is this same method again.

    Br V

  6. #6
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    162
    O.K. I accept your reason, why to overwrite this Load()-method.
    But nevertheless it's really a pity, that there doesn't seem to be a possibilty to convert class CFbsBitmap to class CWsBitmap.
    For example in my case, I have a listbox, where the user can choose a bitmap (jpeg, bmp, gif, whatever). Of course these files have to be converted into a bitmap. I use class CMdaImageFileToBitmapUtility. It's really nice., but it only can produce class CFbsBitmaps. And for processing (I have to display the bitmap nearly 10 times a second), class CWsBitmap is faster. And the redrawing take a lot of time.
    That's why I want to convert. To my mind there are lots of reasons for converting.
    O.K.
    Maybe somebody knows a way out...

    Best regards
    Christian

  7. #7
    Nokia Developer Expert
    Join Date
    Apr 2003
    Location
    Finland
    Posts
    425
    Morning,

    Maybe this could do what we wanna do:
    Code:
        const TInt bitmapId = 0;
        CFbsBitmap* iBitmap = new(ELeave)CFbsBitmap;
        TInt err1 = iBitmap->Load(_L("c:\\epaimsgui.mbm"), bitmapId);
    
        CWsBitmap* iWsBitmap2 = new(ELeave)CWsBitmap();
        iWsBitmap2->Duplicate(iBitmap->Handle());
    I have no application to show bitmap and test this code snap, but it compiles, hope it is able to 'transfer' bitmap between CFbsBitmap and CWsBitmap.

    Br V

  8. #8
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    162
    Hi Veskola,
    Thanks for your patience. Everything is alright. That's exactly what I wanted to know.
    Best regards

  9. #9
    Registered User
    Join Date
    Sep 2005
    Posts
    31

    Re: convert bitmap

    Hi ,

    I tried the following code as mentioned in the thread

    RWsSession* wsSession = &(iEikonEnv->WsSession());
    CWsBitmap* iWsBitmap = new(ELeave)CWsBitmap(*wsSession);
    TInt16 *daddress=(TInt16 *)iWsBitmap->DataAddress();

    The Value of the iwsBitmap is always zero.


    Even if i try

    CWsBitmap* iWsBitmap = new(ELeave)CWsBitmap();

    the return value of the iWsBitmap is always zero.

    Please, can anyone tell, why is so.
    Thanks
    Gilly

  10. #10
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    89

    Re: convert bitmap

    I know you guys already moved from the subject, but you can try CWsBitmap:uplicate(CFbsBitmap::Handle()) for converting CFbsBitmap to CWsBitmap, probably it will work.

Posting Permissions

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