×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    7

    add some essential comments for a function of "Draw CBitmap"

    //I can't understand how does it work
    //Please add some essential comments for the function

    void CBitmap:: Draw( CBitmap& aTarget, const TPoint& aPosition )
    {
    if( iMode != EColor4K )
    {
    return;
    }

    TUint16* sp = (TUint16*)iData;

    TSize tsize = aTarget.Size();

    TSize drawSize = iDrawRect.Size();
    TPoint drawPos = iDrawRect.iTl;

    TInt w = drawSize.iWidth;
    TInt h = drawSize.iHeight;
    TInt x = aPosition.iX;
    TInt y = aPosition.iY;
    TInt sx = drawPos.iX;
    TInt sy = drawPos.iY;
    //
    // Clip
    //
    //what's the meaning of these codes?
    if( x < 0 )
    {
    w += x;
    sx -= x;
    x = 0;
    }
    if( y < 0 )
    {
    h += y;
    sy -= y;
    y = 0;
    }
    if( x + w >= tsize.iWidth )
    {
    w = tsize.iWidth - x;
    }
    if( y + h >= tsize.iHeight )
    {
    h = tsize.iHeight - y;
    }

    //
    // If clipped away, just return
    //
    if( w <= 0 )
    {
    return;
    };
    if( h <= 0 )
    {
    return;
    };
    //
    // Add source offset to source pointer
    //
    sp += sx;
    sp += sy * iSize.iWidth;
    //
    // Calculate modulo ( how much add pointers between horizontal lines )
    //
    TInt smod = iSize.iWidth - w;
    TInt tmod = tsize.iWidth - w;

    TInt tMode = aTarget.Mode();

    TUint16* tp = (TUint16*)aTarget.Data();
    tp += x;
    tp += y * tsize.iWidth;

    for( TInt yy=0; yy<h; yy++ )
    {
    for( TInt xx=0; xx<w; xx++ )
    {
    TUint16 c = *sp++;
    if( c != iMaskColor )
    {
    *tp = c;
    }
    tp++;
    }
    tp += tmod;
    sp += smod;
    }
    }

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,671

    Re: add some essential comments for a function of "Draw CBitmap"

    It is a color-keyed blitter for 16-bit bitmaps with an esoteric feature. The bitmap apparently has its own source coordinates, which seems to be combined with aPosition to produce the "final" target position. It might cause problems, I do not know.

Similar Threads

  1. Undeclared (first use this function) - Problem
    By max_gudluck in forum Symbian
    Replies: 10
    Last Post: 2009-04-20, 16:34
  2. How can I add a function to my project?
    By cassioli in forum Symbian
    Replies: 7
    Last Post: 2007-02-05, 04:58
  3. Please add bluetooth function
    By my_pbox in forum General Development Questions
    Replies: 0
    Last Post: 2003-09-07, 20:09
  4. Cannot compile SDK's examples for 7650 platform...
    By midletsoft in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2003-08-12, 19:11
  5. Problem with Nokia D211 Linux Drivers
    By fiveam in forum Multimodecards
    Replies: 1
    Last Post: 1970-01-01, 02:00

Posting Permissions

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