Retroceder   UASU Foros > Desarrollo (Guias, tutoriales y ayuda) > Programación

Respuesta
 
Herramientas Desplegado
Antiguo 28-oct-2008, 22:56   #1 (permalink)
Miembro Especíal
 
Avatar de <Juan●>
 
Ingreso: octubre-2008
Ubicación: Descargas
Mensajes: 81
Agradecimientos realizados: 13
Le han agradecido 8 veces en 7 Posts
Reportes: 1
Reportado 0 Veces en 0 Posts
Poder: 12 <Juan●> está en el buen camino
Predeterminado Como Implementar vbDABL para AlphaBlend/Color

Bueno aquí les traigo como usar esta libreria. La libreria se descarga de aca: [Solo Miembros registrados ven los enlaces. ] viene con ejemplo sobre como usarla incluido.

Version 11.5

CODIGO EN EL CLIENTE
En el mod Tileengine añadimos:

Código:
Public 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

Public Declare Function vbDABLcolorblend16555 Lib "vbDABL" (ByRef sPtr As Any, ByRef dPtr As Any, ByVal alpha_val%, _
     ByVal Width%, ByVal Height%, ByVal sPitch%, ByVal dPitch%, ByVal rVal%, ByVal gVal%, ByVal bVal%) As Long

Public Declare Function vbDABLcolorblend16565 Lib "vbDABL" (ByRef sPtr As Any, ByRef dPtr As Any, ByVal alpha_val%, _
     ByVal Width%, ByVal Height%, ByVal sPitch%, ByVal dPitch%, ByVal rVal%, ByVal gVal%, ByVal bVal%) As Long

Public Declare Function vbDABLcolorblend16555ck Lib "vbDABL" (ByRef sPtr As Any, ByRef dPtr As Any, ByVal alpha_val%, _
     ByVal Width%, ByVal Height%, ByVal sPitch%, ByVal dPitch%, ByVal rVal%, ByVal gVal%, ByVal bVal%) As Long

Public Declare Function vbDABLcolorblend16565ck Lib "vbDABL" (ByRef sPtr As Any, ByRef dPtr As Any, ByVal alpha_val%, _
     ByVal Width%, ByVal Height%, ByVal sPitch%, ByVal dPitch%, ByVal rVal%, ByVal gVal%, ByVal bVal%) As Long
Buscamos el:
Código:
Sub DDrawTransGrhtoSurface(Surface As Di
Y debajo del sub añadimos:

Código:
  Sub SurfaceConAB(Surface As DirectDrawSurface7, Grh As Grh, ByVal X As Integer, ByVal Y As Integer, center As Byte, Animate As Byte, Optional ByVal KillAnim As Integer = 0)

Dim iGrhIndex As Integer
Dim SourceRect As RECT
Dim QuitarAnimacion As Boolean


If Animate Then
    If Grh.Started = 1 Then
        If Grh.SpeedCounter > 0 Then
            Grh.SpeedCounter = Grh.SpeedCounter - 1
            If Grh.SpeedCounter = 0 Then
                Grh.SpeedCounter = GrhData(Grh.GrhIndex).Speed
                Grh.FrameCounter = Grh.FrameCounter + 1
                If Grh.FrameCounter > GrhData(Grh.GrhIndex).NumFrames Then
                    Grh.FrameCounter = 1
                    If KillAnim Then
                        If charlist(KillAnim).FxLoopTimes <> LoopAdEternum Then

                            If charlist(KillAnim).FxLoopTimes > 0 Then charlist(KillAnim).FxLoopTimes = charlist(KillAnim).FxLoopTimes - 1
                            If charlist(KillAnim).FxLoopTimes < 1 Then 'Matamos la anim del fx ;))
                                charlist(KillAnim).Fx = 0
                                Exit Sub
                            End If

                        End If
                    End If
               End If
            End If
        End If
    End If
End If

If Grh.GrhIndex = 0 Then Exit Sub

iGrhIndex = GrhData(Grh.GrhIndex).Frames(Grh.FrameCounter)

If center Then
    If GrhData(iGrhIndex).TileWidth <> 1 Then
        X = X - Int(GrhData(iGrhIndex).TileWidth * 16) + 16 'hard coded for speed
    End If
    If GrhData(iGrhIndex).TileHeight <> 1 Then
        Y = Y - Int(GrhData(iGrhIndex).TileHeight * 32) + 32 'hard coded for speed
    End If
End If

With SourceRect
    .Left = GrhData(iGrhIndex).sX + IIf(X < 0, Abs(X), 0)
    .Top = GrhData(iGrhIndex).sY + IIf(Y < 0, Abs(Y), 0)
    .Right = .Left + GrhData(iGrhIndex).pixelWidth
    .Bottom = .Top + GrhData(iGrhIndex).pixelHeight
End With

Dim Src As DirectDrawSurface7
Dim rDest As RECT
Dim dArray() As Byte, sArray() As Byte
Dim ddsdSrc As DDSURFACEDESC2, ddsdDest As DDSURFACEDESC2
Dim Modo As Long

Set Src = SurfaceDB.Surface(GrhData(iGrhIndex).FileNum)

Src.GetSurfaceDesc ddsdSrc
Surface.GetSurfaceDesc ddsdDest
With rDest
    .Left = X
    .Top = Y
    .Right = X + GrhData(iGrhIndex).pixelWidth
    .Bottom = Y + GrhData(iGrhIndex).pixelHeight
    
    If .Right > ddsdDest.lWidth Then
        .Right = ddsdDest.lWidth
    End If
    If .Bottom > ddsdDest.lHeight Then
        .Bottom = ddsdDest.lHeight
    End If
End With

Dim SrcLock As Boolean, DstLock As Boolean
SrcLock = False: DstLock = False

On Local Error GoTo HayErrorAlpha

Src.Lock SourceRect, ddsdSrc, DDLOCK_NOSYSLOCK Or DDLOCK_WAIT, 0
Surface.Lock rDest, ddsdDest, DDLOCK_NOSYSLOCK Or DDLOCK_WAIT, 0

Surface.GetLockedArray dArray()
Src.GetLockedArray sArray()
        
If ddsdDest.ddpfPixelFormat.lGBitMask = &H3E0 Then
  Modo = 555
ElseIf ddsdDest.ddpfPixelFormat.lGBitMask = &H7E0 Then
  Modo = 565
Else
  MsgBox "Modo de vídeo no esta en 555 o 565 o algo falló."
  End
End If

vbDABLalphablend16 Modo, 1, sArray(SourceRect.Left * 2, SourceRect.Top), dArray(X + X, Y), 160, rDest.Right - rDest.Left, rDest.Bottom - rDest.Top, ddsdSrc.lPitch, ddsdDest.lPitch, 0

Surface.Unlock rDest
Src.Unlock SourceRect



Exit Sub

HayErrorAlpha:
If SrcLock Then Src.Unlock SourceRect
If DstLock Then Surface.Unlock rDest

End Sub
Luego para aplicarlo busca cualquier:
Cita:
Call DDrawTransGrhtoSurface
Y o lo sustituyes o creas un if else llamado asi a al alphablend:
Código:
Call SurfaceConAB
Con eso aplicamos transparencia, para aplicar color en el SurfaceConAB
en lugar de poner:
Código:
vbDABLalphablend16 Modo, 1, sArray(SourceRect.Left * 2, SourceRect.Top), dArray(X + X, Y), 160, rDest.Right - rDest.Left, rDest.Bottom - rDest.Top, ddsdSrc.lPitch, ddsdDest.lPitch, 0

Explicacion: 160 es el grado de alpha que aplicamos
Pondriamos:

Código:
Call vbDABLcolorblend16565ck(ByVal VarPtr(sArray(SourceRect.Left * 2, SourceRect.Top)), ByVal VarPtr(dArray(X + X, Y)), 120, rDest.Right - rDest.Left, rDest.Bottom - rDest.Top, ddsdSrc.lPitch, ddsdDest.lPitch, 255, 255, 255)
120 es la opacidad que queremos meterle, y los 255 son R,G,B
Atte: Juan
__________________
*Programador*
"Aporto Códigos, Pero solo los Buenos
"
[Solo Miembros registrados ven los enlaces. ]
<Juan●> está desconectado  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Responder Citando
Sponsored Links
Antiguo 29-oct-2008, 00:32   #2 (permalink)
100% Negro Cumbiero
Administrador
 
Avatar de KoTox
 
Ingreso: octubre-2007
Ubicación: Villa Madero
Edad: 18
Mensajes: 1.689
Puntos: 18.994, Nivel: 18 Puntos: 18.994, Nivel: 18 Puntos: 18.994, Nivel: 18
Nivel máximo: 80% Nivel máximo: 80% Nivel máximo: 80%
Actividad: 59% Actividad: 59% Actividad: 59%
El usuario posee 1x Acceso Vip El usuario posee 1x Acceso a la Zona VIP
Poder: 236 KoTox es un glorioso faro de luzKoTox es un glorioso faro de luzKoTox es un glorioso faro de luzKoTox es un glorioso faro de luzKoTox es un glorioso faro de luzKoTox es un glorioso faro de luz
Predeterminado

Pone la fuente
KoTox esta en línea ahora  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Responder Citando
Antiguo 29-oct-2008, 17:55   #3 (permalink)
70% Programed
 
Avatar de Petin
 
Ingreso: junio-2008
Mensajes: 204
Puntos: 2.686, Nivel: 4 Puntos: 2.686, Nivel: 4 Puntos: 2.686, Nivel: 4
Nivel máximo: 84% Nivel máximo: 84% Nivel máximo: 84%
Actividad: 8% Actividad: 8% Actividad: 8%
Poder: 29 Petin está en el buen camino
Predeterminado

Gs zone, juan deja de joder y pone la fuente en todos, no haces eso vos ni ahi :S
Petin está desconectado  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Responder Citando
Respuesta

Marcadores

Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
caritas están Activado
[IMG] está Activado
Código HTML está Desactivado
Trackbacks are Desactivado
Pingbacks are Desactivado
Refbacks are Desactivado
Ir al Foro

Te recomendamos visitar estos sitios

PasionChat  Blogs  UASU lite  El Foro Latino  Argentum Online  Host Gratis  Bazar de dominios


La franja horaria es GMT -5. Ahora son las 17:00.



Desarrollado por: vBulletin® Versión 3.7.5
Derechos de Autor ©2000 - 2009, Jelsoft Enterprises Ltd.
Traducido por mcloud
Copyright UASU Group - Azmum Multimedios 2002-2008Ad Management by RedTyger
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.