J'ai réussi à obtenir un résultat prometteur mais j'ai c'est pas encore parfait.
Si vous avez la solution je suis preneur. J'ai essayé mille et un bidouillage sur les pixels pour en revenir à un truc simple à partir de la composante grise.

Les 2 images à mélanger et le code sont dans cette archive.
Sinon le code seul :
Code : Tout sélectionner
; Tentative de superposition d'images par Ar-S sans jouer sur la couche alpha des images.
; ************ INITIALISATION **********************
UsePNGImageDecoder()
UsePNGImageEncoder()
Enumeration 10
#i1
#i2
#Image_FX
EndEnumeration
Global.s PicFile = GetCurrentDirectory()+"image_temp.png"
Declare StockPixel(IMGA, List ListChainee())
Declare MagicMix(List ListChainee1(), List ListChainee2())
Lwin = 741 : Hwin = 480
Global Canvas_MAX_L = Lwin - 101
Global Canvas_MAX_H = Hwin
Global NewList Col_img1()
Global NewList Col_img2()
LoadImage(#i1,GetCurrentDirectory()+"10.png")
LoadImage(#i2,GetCurrentDirectory()+"11.png")
StockPixel(#i1, Col_img1())
StockPixel(#i2, Col_img2())
CreateImage(#Image_FX, Canvas_MAX_L, Canvas_MAX_H)
FX = 0
; ************ PROGRAMME **********************
hwnd = OpenWindow(0, #PB_Any, #PB_Any, Lwin, Hwin, "test 2 sup img Ar-S", #PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
StickyWindow(0,1)
CanvasGadget(1, 101, 1, Canvas_MAX_L, Canvas_MAX_H , #PB_Canvas_DrawFocus|#PB_Canvas_ClipMouse)
StartDrawing(CanvasOutput(1))
DrawingMode(#PB_2DDrawing_AlphaBlend)
Box(0,0, Canvas_MAX_L, Canvas_MAX_H, $FFFFFF)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(5,5, "Vide", $0)
StopDrawing()
ButtonGadget(2,1,1,100,29,"Voir image 1")
ButtonGadget(3,1,30,100,29,"Voir image 2")
ButtonGadget(4,1,60,100,29,"Mixer les 2")
DisableGadget(3,1) : DisableGadget(4,1)
; ************ EVENT et BOUCLE **********************
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 2 ; Voir Image 1
StartDrawing(CanvasOutput(1))
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawImage(ImageID(#i1),0,0)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(5,5, "Image 1", $0)
StopDrawing()
DisableGadget(2,1)
DisableGadget(3,0)
Case 3 ; Voir Image 2
StartDrawing(CanvasOutput(1))
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawImage(ImageID(#i2),0,0)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(5,5, "Image 2", $0)
StopDrawing()
DisableGadget(3,1)
DisableGadget(4,0)
Case 4 ; Mixer
MagicMix(Col_img1(), Col_img2())
StartDrawing(CanvasOutput(1))
DrawingMode(#PB_2DDrawing_AlphaBlend)
;DrawingMode(#PB_2DDrawing_AlphaChannel)
;DrawingMode(#PB_2DDrawing_AlphaClip)
Box(0,0,Canvas_MAX_L, Canvas_MAX_H, $FFFFFF)
DrawAlphaImage(ImageID(#image_FX),0,0,255)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(5,5, "Mix", $0)
StopDrawing()
DisableGadget(2,0)
DisableGadget(3,1)
DisableGadget(4,1)
;
EndSelect
Case #PB_Event_CloseWindow
Select EventWindow()
Case 0
quite=1
EndSelect
StopDrawing()
EndSelect
Until quite=1
ClearList(Col_img1())
ClearList(Col_img2())
For i = #i1 To #Image_FX
If IsImage(i)
FreeImage(i)
EndIf
Next
End
; ************ PROCEDURES **********************
Procedure StockPixel(IMGA, List ListChainee())
Protected Couleur
StartDrawing(ImageOutput(IMGA))
For y = 0 To ImageHeight(IMGA)-1
For x = 0 To ImageWidth(IMGA)-1
Couleur = Point (x,y)
AddElement (ListChainee())
ListChainee() = Couleur
Next x
Next y
StopDrawing()
EndProcedure
Procedure MagicMix(List ListChainee1(), List ListChainee2())
ResetList (ListChainee1())
ResetList (ListChainee2())
DisableDebugger
StartDrawing(ImageOutput(#IMAGE_FX))
P = 0
DrawImage(ImageID(#i1),0,0)
For y = 0 To ImageHeight(#IMAGE_FX)-1
For x = 0 To ImageWidth(#IMAGE_FX)-1
SelectElement (ListChainee1(), P)
Couleur1 = ListChainee1()
R1 = Red(Couleur1)
G1 = Green(Couleur1)
B1 = Blue(Couleur1)
A1 = Alpha(Couleur1)
Gray1 = (R1+G1+B1)/3
SelectElement (ListChainee2(), P)
Couleur2 = ListChainee2()
R2 = Red(Couleur2)
G2 = Green(Couleur2)
B2 = Blue(Couleur2)
A2 = Alpha(Couleur2)
Gray2 = (R2+G2+B2)/3
If Gray2 < Gray1
R = R2
G = G2
B = B2
A = 255
NewCOLOR = RGBA(R, G, B, A)
Plot (x, y , NewCOLOR)
EndIf
P+1
Next x
Next y
StopDrawing()
EnableDebugger
EndProcedure