You don't have to use GDI.
Code: Select all
DisableDebugger
Structure LW ; Cf Procédures >> Alphablending >> Layered Window
WindowID.L ; Handle du DC de la fenêtre translucide (WindowID)
*ptWnd ;#Pointe vers une structure POINT (Position de la fenêtre, 0 = inchangée)
*szWnd ;#Pointe vers une structure SIZE (Taille de la fenêtre, 0 = inchangée)
hdcAIm.L ; Handle du DC source (Image Alpha)
*ptAIm ;#Pointe vers une structure POINT
crKey.L ; Couleur clé (transparence)
*Blend ;#Pointe vers la structure BLENDFUNCTION (fBlend plus bas)
*AImArea ;#Pointe vers 1 struc RECT spécifiant la zone à copier depuis le DC source
X.L ; Coordonnées X de la fenêtre
Y.L ; Coordonnées Y de la fenêtre
W.L ; Largeur de la fenêtre
H.L ; Hauteur de la fenêtre
XA.L ; Coordonnées X dans l'image
YA.L ; Coordonnées Y dans l'image
fBlend.L ; Fonction Blend (toujours $01FF0000)
X1.L ; Vista
Y1.L ; Vista
X2.L ; Vista
Y2.L ; Vista
Window.L ; n° de fenêtre
ImageID.L ; ID de l'image
VX.F
VY.F
AA.F
V.F
Flip.L
EndStructure
Procedure LayeredWindow(Window.L, Stat.L)
Protected NewFlag.L = GetWindowLong_(WindowID(Window), #GWL_EXSTYLE) | (#WS_EX_LAYERED * Stat)
SetWindowLong_(WindowID(Window), #GWL_EXSTYLE, NewFlag)
EndProcedure
Procedure OpenLW(*LW.LW, X, Y, ImageID)
Protected Bmp.BITMAP
Protected PosiSrc.POINT
With *LW
\ImageID = ImageID
GetObject_(\ImageID, SizeOf(BITMAP), @Bmp)
\W = Bmp\BmWidth
\H = Bmp\BmHeight
\Window = OpenWindow(-1, X, Y, W, H, "", $90000000)
\WindowID = WindowID(\Window)
If \Window
StickyWindow(\Window, 1)
LayeredWindow(\Window, 1)
\hdcAIm = CreateCompatibleDC_(StartDrawing(WindowOutput(\Window) ) )
SelectObject_(\hdcAIm, \ImageID)
Blend.L = $1FF0000
Result.L = UpdateLayeredWindow_(\WindowID, 0, 0, @\W, \HdcAIm, PosiSrc, 0, @Blend, 2)
StopDrawing()
DeleteDC_(\hdcAIm)
HideWindow(\Window, 0)
EndIf
If Result = 0: CloseWindow(\Window): EndIf
EndWith
ProcedureReturn Result
EndProcedure
InitSprite()
InitSprite3D()
InitKeyboard()
OpenWindow(0, 0, 0, 1024, 768, "", $90000000)
OpenWindowedScreen(WindowID(0), 0, 0, 1024, 768, 0, 0, 0)
CreateSprite(0, 4, 4, #PB_Sprite_Texture)
StartDrawing(SpriteOutput(0) )
Box(0, 1, 2, 2, #White)
Box(2, 1, 2, 2, #Blue)
StopDrawing()
CreateSprite3D(0, 0)
Sprite3DQuality(1)
Distance.F = 256.0
Thickness.F = 8.0
;Repeat
Delay(1)
ClearScreen(0)
If Start3D()
Sprite3DBlendingMode(3, 9)
Angle.F = 0
For A = 0 To 360 Step 10
cx.F = 256
cy.F = 256
Angle = A * #PI / 180.0 + AngleR.F
ix.F = Cos(Angle)
iy.F = Sin(Angle)
jx.F = Cos(Angle + #PI / 2.0)
jy.F = Sin(Angle + #PI / 2.0)
ex1.F = 0.0
ey1.F = 0.0 - Thickness
ex2.F = Distance
ey2.F = 0.0 - Thickness
ex3.F = Distance
ey3.F = Thickness
ex4.F = 0.0
ey4.F = Thickness
gx1.F = ex1 * ix + ey1 * iy
gy1.F = ex1 * jx + ey1 * jy
gx2.F = ex2 * ix + ey2 * iy
gy2.F = ex2 * jx + ey2 * jy
gx3.F = ex3 * ix + ey3 * iy
gy3.F = ex3 * jx + ey3 * jy
gx4.F = ex4 * ix + ey4 * iy
gy4.F = ex4 * jx + ey4 * jy
DisplaySprite3D(0, 0, 0)
TransformSprite3D(0, cx+gx1, cy+gy1, cx+gx2, cy+gy2, cx+gx3, cy+gy3, cx+gx4, cy+gy4)
Next
Stop3D()
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left): AngleR = (AngleR + 0.005): EndIf
If KeyboardPushed(#PB_Key_Right): AngleR = (AngleR - 0.005): EndIf
FlipBuffers()
*X = AllocateMemory(1024 * 768 * 4 + 8)
PokeL(*X, 1024)
PokeL(*X + 4, 768)
If StartDrawing(ScreenOutput())
Buffer = DrawingBuffer() ; Get the start address of the screen buffer
Pitch = DrawingBufferPitch() ; Get the length (in byte) took by one horizontal line
PixelFormat = DrawingBufferPixelFormat() ; Get the pixel format.
*Ecran = Buffer
*Start = *X + 8
Qty = 1024 * 768
! mov esi, [p_Ecran]
! mov edi, [p_Start]
! mov ecx, [v_Qty]
Transfert:
! lodsd
! mov edx, eax
! xor ebx,ebx
! cmp bl, dl
! ja l_ici0
! mov bl, dl
ici0:
! shr edx, 8
! cmp bl, dl
! ja l_ici1
! mov bl, dl
ici1:
! shr edx, 8
! cmp bl, dl
! ja l_ici2
! mov bl, dl
ici2:
! shl ebx, 24
! or eax, ebx
! stosd
! loop l_transfert
; CopyMemory(*Ecran, *Start, 1024 * 768 * 4)
StopDrawing()
EndIf
AlphaImage.L = CreateBitmap_(1024, 768, 1, 32, *X + 8)
; OpenWindow(10, 100, 100, 512, 512, "Lissage", $CF0001)
ULW.LW
OpenLW(ULW, 100, 100, AlphaImage)
;ImageGadget(0, 0, 0, 1024, 768, AlphaImage)
; HideWindow(0, 1)
;Repeat
; Delay(1)
;Until WindowEvent() = 16
Delay(8000)
;Until KeyboardPushed(#PB_Key_Escape)
CloseScreen()
CloseWindow(0)
End