Results 1 to 3 of 3

Thread: AlphaBlend+BitBlt+ShapeAPI best way to...

  1. #1

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    AlphaBlend+BitBlt+ShapeAPI best way to...

    What's the best way to draw alpha blended shapes. Like Ellipse API, Rect API, etc.

    I was thinking Bitblt the source image, draw shape on it, alphablend back to source.

    But there has to be a beter way? Hopefully?

  2. #2
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I think thats probably the easiest way, it shouldn't be that processor hungry. I'm guessing your using DirectX? if you are the only way I can think of is if you create a blank surface, BitBlt the Shape to it then alpha blend it to the BackBuffer using either
    VB Code:
    1. Private Declare Function vbDABLalphablend16 Lib "vbDABL" (ByVal iMode As Integer, ByVal bColorKey As Integer, ByRef sPtr As Any, ByRef dPtr As Any, ByVal iAlphaVal As Integer, ByVal iWidth As Integer, ByVal iHeight As Integer, ByVal isPitch As Integer, ByVal idPitch As Integer, ByVal iColorKey As Integer) As Integer
    or if you use a Direct3D surface:
    VB Code:
    1. D3DDevice.SetRenderState D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA
    2. D3DDevice.SetRenderState D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA
    3. D3DDevice.SetRenderState D3DRENDERSTATE_TEXTUREFACTOR, DirectX.CreateColorRGBA(1, 1, 1, A)
    4. D3DDevice.SetTextureStageState 0, D3DTSS_ALPHAOP, D3DTA_TFACTOR
    5. 'Where A is a value between 0-1, the Alpha Blend value
    Notice that using the vbDABLalphablend16 API it will only work in 16bit mode.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  3. #3
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Use the second methid if you are using DX...thats my opinion...

Posting Permissions

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



Click Here to Expand Forum to Full Width