récupérer l'alpha d'une image
Publié : lun. 04/juil./2011 18:02
salut
savez-vous s'il y a moyen de récupérer la couche alpha d'une image ?
Je suis parti du tutoriel de G-rom, et j'ai essayé de l'adapter, mais je n'ai pas encore réussi
En fait, j'essaie de créer un système tout simple de calque, donc, j'imagine que cela devrait être possible en utilisant ce tutoriel 
Merci d'avance
savez-vous s'il y a moyen de récupérer la couche alpha d'une image ?
Je suis parti du tutoriel de G-rom, et j'ai essayé de l'adapter, mais je n'ai pas encore réussi

Code : Tout sélectionner
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
UsePNGImageEncoder()
Image_A = LoadImage(#PB_Any,"1.jpg")
Image_B = LoadImage(#PB_Any,"2.png")
alpha_b = LoadImage(#PB_Any,"2.png")
Reference_SizeX = ImageWidth(Image_a)
Reference_SizeY = ImageHeight(Image_a)
ResizeImage(Image_A,Reference_SizeX,Reference_SizeY)
ResizeImage(Image_B,Reference_SizeX,Reference_SizeY)
ResizeImage(alpha_b,Reference_SizeX,Reference_SizeY)
Dim Image_A_Color(Reference_SizeX,Reference_SizeY)
Dim Image_B_Color(Reference_SizeX,Reference_SizeY)
Dim Image_C_Color(Reference_SizeX,Reference_SizeY)
StartDrawing(ImageOutput(Image_A))
For y = 0 To Reference_SizeY - 1
For x = 0 To Reference_SizeX - 1
Image_A_Color(x,y) = Point(x,y)
Next
Next
StopDrawing()
StartDrawing(ImageOutput(Image_B))
For y = 0 To Reference_SizeY - 1
For x = 0 To Reference_SizeX - 1
Image_B_Color(x,y) = Point(x,y)
Next
Next
StopDrawing()
StartDrawing(ImageOutput(alpha_b))
For y = 0 To Reference_SizeY - 1
For x = 0 To Reference_SizeX - 1
Color = Point(x,y)
Image_C_Color(x,y) = Alpha(color)
;Image_C_Color(x,y) = (Red(Color) + Green(Color) + Blue(Color) ) / 3
Next
Next
StopDrawing()
Sortie = CreateImage(#PB_Any,Reference_SizeX,Reference_SizeY,32)
StartDrawing(ImageOutput(Sortie))
For y = 0 To Reference_SizeY - 1
For x = 0 To Reference_SizeX - 1
Red_A = Red(Image_A_Color(x,y))
Green_A = Green(Image_A_Color(x,y))
Blue_A = Blue(Image_A_Color(x,y))
Red_B = Red(Image_B_Color(x,y))
Green_B = Green(Image_B_Color(x,y))
Blue_B = Blue(Image_B_Color(x,y))
Value.f = Image_c_Color(x,y);Image_c_Color(x,y) / 255
;
Red = (Red_A *value ) + (Red_B * (1-Value))
Green = (Green_A *value) + (Green_B * (1-Value))
Blue = (Blue_A * value ) + (Blue_B * (1-Value))
Plot(x,y,RGBA(Red,Green,Blue,value))
Next
Next
StopDrawing()
SaveImage(Sortie,"Sortie.png",#PB_ImagePlugin_PNG,32)

Merci d'avance
