Ejemplo n.º 1
0
/*static*/ void Surface::Blit( const Surface& Src, Surface& Dest, int dx, int dy, int w, int h, int sx, int sy, uint Flags, uint ColorKey /*= DEFAULT_COLOR_KEY*/, float Alpha /*= 0.5f*/ )
{
    PROFILE_FUNCTION;

    if( Flags & BLIT_ADDITIVE )
    {
        AdditiveBlit( Src, Dest, dx, dy, w, h, sx, sy );
    }
    else if( ( Flags & ( BLIT_MASK | BLIT_BLEND ) ) == ( BLIT_MASK | BLIT_BLEND ) )
    {
        MaskBlendBlit( Src, Dest, dx, dy, w, h, sx, sy, ColorKey );
    }
    else if( ( Flags & ( BLIT_MASK | BLIT_ALPHA ) ) == ( BLIT_MASK | BLIT_ALPHA ) )
    {
        MaskAlphaBlit( Src, Dest, dx, dy, w, h, sx, sy, ColorKey, Alpha );
    }
    else if( Flags & BLIT_MASK )
    {
        MaskBlit( Src, Dest, dx, dy, w, h, sx, sy, ColorKey );
    }
    else if( Flags & BLIT_BLEND )
    {
        BlendBlit( Src, Dest, dx, dy, w, h, sx, sy );
    }
    else if( Flags & BLIT_ALPHA )
    {
        AlphaBlit( Src, Dest, dx, dy, w, h, sx, sy, Alpha );
    }
    else
    {
        StandardBlit( Src, Dest, dx, dy, w, h, sx, sy );
    }
}
Ejemplo n.º 2
0
void CGraphView::Blit(const Canvas& src,int x,int y,bool trans)
{
    if (trans)
    {
        AlphaBlit(src,x,y);
        return;
    }
    
    const int bpp=4;
    
    int nDestwidth=pDib->Width();
    int nDestheight=pDib->Height();
    
    int xstart=0;
    int ystart=0;
    int xlen=src.Width();
    int ylen=src.Height();
    int ox=x;
    int oy=y;
    
    DoClipping(x,y,xstart,xlen,ystart,ylen);

    if (xlen<1 || ylen<1)   return; // offscreen
    
    u32* pDest=(u32*)(pDib->GetPixels())+(y*nDestwidth+x);
    u32* pSrc =(u32*)src.GetPixels() +(ystart*src.Width()+xstart);
    
    while (ylen)
    {
        int x=xlen;
        while (x)
        {
            // convert from ARGB to ABGR
            /*
            u32 c=*pSrc++;
            u8 r=(u8)((c>>16)&255);
            u8 b=(u8)(c&255);
            c&=0xFF00FF00;                              // the alpha and green channels don't move, keep them intact                        
            *pDest++=c|(b<<16)|r;
            /*/
            // Did I need to convert this to ASM?  Doubt it. ;D
            __asm
            {
                mov     ebx,[pSrc]
                mov     eax,[ebx]
                
                mov     ebx,[pDest]
                mov     [ebx],eax
                
                mov     al,[ebx]
                mov     ah,[ebx+2]
                mov     [ebx],ah                        // have to switch from BGRA to RGBA
                mov     [ebx+2],al
            }
            ++pSrc; ++pDest;
            //*/
            x--;
        }
        pDest+=nDestwidth-xlen;
        pSrc+=src.Width()-xlen;
        --ylen;
    }
}