Post

 Resources 

Console


Alpha blending code... Mattman (3 replies, 0 views) (2000-Aug-4)
-
Okay, I'm having a little trouble with some alpha blending code...when I alphablend, it only blends the blue channel and not the red or green channels...It about midnight now and I'm too tired to think how to fix this on my own (I assume I'd need a third loop...for c = 0 To 2 or something), so could someone please give me a hand? Thanks in advance! Matt Huggins mattman@nobispro.com http://www.nobispro.com <PRE> Public Sub AlphaBlt(Dest As SurfaceType, DestX As Long, DestY As Long, nWidth As Long, nHeight As Long, Source As SurfaceType, SrcX As Long, SrcY As Long, ByVal SrcPercent As Byte) ' ------------------------------------------------ ' Copies (or blits) one portion of a surface ' onto another surface. ' ------------------------------------------------ If Not Init Then Exit Sub On Error Resume Next Dim SrcRect As RECT, DestRect As RECT ' Update RECTs With SrcRect .Top = SrcY .Bottom = SrcY + nHeight .Left = SrcX .Right = SrcX + nWidth End With With DestRect .Top = DestY .Bottom = DestY + nHeight .Left = DestX .Right = DestX + nWidth End With Dim a As Long, b As Long Dim DestPercent As Byte Dim ByteSrc() As Byte, ByteDest() As Byte Call Source.Surface.Lock(SrcRect, Source.Desc, DDLOCK_WAIT, 0) Call Dest.Surface.Lock(DestRect, Dest.Desc, DDLOCK_WAIT, 0) Call Source.Surface.GetLockedArray(ByteSrc) Call Dest.Surface.GetLockedArray(ByteDest) DestPercent = 100 - SrcPercent For a = DestRect.Left To DestRect.Right For b = DestRect.Top To DestRect.Bottom Call Dest.Surface.SetLockedPixel(a, b, (CInt(ByteSrc(a - DestRect.Left, b - DestRect.Top)) * SrcPercent + CInt(ByteDest(a, b)) * DestPercent) \ 100) ' Call Dest.Surface.SetLockedPixel(a, b, (CInt(ByteSrc(a - DestRect.Left + SrcRect.Left, b - DestRect.Top + SrcRect.Top)) * SrcPercent + CInt(ByteDest(a, b)) * DestPercent) \ 100) Next b Next a Call Dest.Surface.Unlock(DestRect) Call Source.Surface.Unlock(SrcRect) End Sub </PRE>


-
Back to Forum

RE: Alpha blending code... David Goodlad (2 replies) (2000-Aug-5)
or vbDABL *nt Peter (1 reply) (2000-Aug-5)
RE: or vbDABL *nt David Goodlad (0 replies) (2000-Aug-5)

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.
There have been 51 visitors within the last 20 minutes
RSS News Feed