请问怎样用ALPHA BLEND画线,效果要消除锯齿的,请各位高手教教我。给我一份原代码。完了用一千分报答。

解决方案 »

  1.   

    alphablend不是化位图的吗,用屏幕缓冲好了
      

  2.   

    用ALPHA BLEND画线??
    我只知道用AlphaBlend混合设备文本
      

  3.   

    这是类代码,但是我还没有编译出来,请各位大虾帮帮忙。
    class KAirBrush
    {
    HBITMAP m_hBrush;
    HDC m_hMemDC;
    HBITMAP m_hOld;
    int m_nWidth;
    int     m_nHeight; void Release(void)
    {
    SelectObject(m_hMemDC, m_hOld);
    DeleteObject(m_hMemDC);
    DeleteObject(m_hBrush); m_hOld = NULL; m_hMemDC = NULL; m_hBrush = NULL;
    }public:
    KAirBrush()
    {
    m_hBrush = NULL;
    m_hMemDC = NULL;
    m_hOld   = NULL;
    } ~KAirBrush()
    {
    Release();
    } void Create(int width, int height, COLORREF color);
    void Apply(HDC hDC, int x, int y);
    };
    void KAirBrush::Apply(HDC hDC, int x, int y)
    {
    BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; AlphaBlend(hDC, x-m_nWidth/2, y-m_nHeight/2, m_nWidth, m_nHeight, m_hMemDC, 0, 0, m_nWidth, m_nHeight, blend);
    }
    void KAirBrush::Create(int width, int height, COLORREF color)
    {
    Release(); BYTE * pBits;
    BITMAPINFO Bmi = { { sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB } }; m_hBrush  = CreateDIBSection(NULL, & Bmi, DIB_RGB_COLORS, (void **) & pBits, NULL, NULL);
    m_hMemDC  = CreateCompatibleDC(NULL);
    m_hOld    = (HBITMAP) SelectObject(m_hMemDC, m_hBrush);
    m_nWidth  = width;
    m_nHeight = height;
    // solid color circle, on white background
    {
    PatBlt(m_hMemDC, 0, 0, width, height, WHITENESS); HBRUSH hBrush = CreateSolidBrush(color);
    SelectObject(m_hMemDC, hBrush);
    SelectObject(m_hMemDC, GetStockObject(NULL_PEN));

    Ellipse(m_hMemDC, 0, 0, width, height);

    SelectObject(m_hMemDC, GetStockObject(WHITE_BRUSH));
    DeleteObject(hBrush);
    }

    BYTE * pPixel = pBits; for (int y=0; y<height; y++)
    for (int x=0; x<width;  x++, pPixel+=4)
    {
    int  dis   = (int) ( sqrt( (x-width/2) * (x-width/2) + (y-height/2) * (y-height/2) ) * 255 / (max(width, height)/2) ); BYTE alpha = (BYTE) max(min(255-dis, 255), 0); pPixel[0] = pPixel[0] * alpha / 255;
    pPixel[1] = pPixel[1] * alpha / 255;
    pPixel[2] = pPixel[2] * alpha / 255;
    pPixel[3] = alpha;
    }
    } switch( uMsg )
    {
        case WM_CREATE:
    m_hBrush.Create(32,32,RGB(0,0xFF,0));
    return 0;
    case WM_LBUTTONDOWN:
    wParam = MK_LBUTTON;//fall through
    case WM_MOUSEMOVE:
    if(wParam & MK_LBUTTON)
    {
    m_brush.Apply(m_hDCBitmap,LOWORD    (lParam),HIWORD(lParam));
    Refresh(LOWORD(lParam),HIWORD(lParam));
    }
    return 0;
      

  4.   

    我有源码,想要的话,给我发个[email protected]