
Code : Tout sélectionner
;Comtois le 20/04/2006
;/SnapShot
ExamineDesktops()
;Première image
#Img_1 = 0
hBitmap = CreateImage(#Img_1, 400, 200)
hdc = StartDrawing(ImageOutput(#Img_1))
SelectObject_(hdc, hBitmap)
BitBlt_(hdc, 0, 0, 400, 200, GetDC_(GetDesktopWindow_()), 0, 0, #SRCCOPY)
StopDrawing()
DeleteDC_(hdc)
;Deuxième image
#Img_2 = 1
hBitmap = CreateImage(#Img_2, 400, 200)
hdc = StartDrawing(ImageOutput(#Img_2))
SelectObject_(hdc, hBitmap)
BitBlt_(hdc, 0, 0, 400, 200, GetDC_(GetDesktopWindow_()), 0, 200, #SRCCOPY)
StopDrawing()
DeleteDC_(hdc)
InitSprite()
InitKeyboard()
OpenScreen(800,600,32,"Transparence")
Structure s_pixel
P1.c
P2.c
P3.c
P4.c
EndStructure
#SpriteA=0
#SpriteB=1
#SpriteC=2
Global *memA, *memB, *memC, pitch
CreateSprite(#SpriteA,400,200)
CreateSprite(#SpriteB,400,200)
CreateSprite(#spriteC,SpriteWidth(#SpriteA),SpriteHeight(#SpriteA))
StartDrawing(SpriteOutput(#spriteA))
*memA=DrawingBuffer()
Pitch=DrawingBufferPitch()
DrawImage(ImageID(#Img_1),0,0)
StopDrawing()
StartDrawing(SpriteOutput(#spriteB))
*memB=DrawingBuffer()
Pitch1=DrawingBufferPitch()
DrawImage(ImageID(#Img_2),0,0)
StopDrawing()
StartDrawing(SpriteOutput(#spriteC))
*memC=DrawingBuffer()
StopDrawing()
Procedure Transparence1(*PtrA.s_pixel, *PtrB.s_pixel, *PtrC.s_pixel, trans)
;Principe de la transparence
;Le sprite C = le résultat de la fondue entre le sprite A et le Sprite B
;Valeur exacte
;CouleurC = (alphaB couleurB + (((255 - alphaB) alphaA CouleurA)/255))/255
;Plus rapide mais moins exacte
;CouleurC = (alphaB couleurB + (((255 - alphaB) alphaA CouleurA)>>8)) >>8
AlphaB=255-trans
AlphaA=trans
pos = 0
Fin = SpriteWidth(#SpriteA)+SpriteHeight(#SpriteA)*pitch
While pos <= Fin
;e=((a*v)/100)+((b*(100-v))/100)
*PtrC\P1 = ((alphaA * *PtrA\P1) + (alphaB * *PtrB\P1))>>8
*PtrC\P2 = ((alphaA * *PtrA\P2) + (alphaB * *PtrB\P2))>>8
*PtrC\P3 = ((alphaA * *PtrA\P3) + (alphaB * *PtrB\P3))>>8
*PtrA + 4
*PtrB + 4
*PtrC + 4
pos + 4
Wend
EndProcedure
I=0
p=2
Repeat
FlipBuffers()
ClearScreen(0)
If i < 255
Transparence1(*memA, *memB, *memC,I)
I + p
p + 1
EndIf
DisplaySprite(#SpriteC,0,0)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Correction d'un bug, c'est plus rapide maintenant.