Mon but n'est pas vraiment de faire des bordures mais d'utiliser les procédures telles qu'elles sont. C'est à dire, je scanne l'image, si le pixel en cours est blanc et que le pixel suivant (ou précédent) est jaune alors je pose un pixel bleu (ou vert).
La procédure qui dessine une bordure à gauche fonctionne, même chose à droite mais si j'utilise les 2 en même temps ça ne fonctionne pas.
Voir le code
Code : Tout sélectionner
;{- Enumerations / DataSections
;{ Windows
Enumeration
#Window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
#Button_0
#Button_1
#Image_2
EndEnumeration
;}
;{ Images
Enumeration
#Image_Image_2
EndEnumeration
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
Global Dim tableau_pixel(500,500)
;Global image
;}
Procedure dessin()
image=CreateImage(#PB_Any,500,500)
StartDrawing(ImageOutput(image))
Box(0,0,500,500,#White) ; fond blanc
Circle(250,250,100,#Yellow) ; cercle jaune
For y=0 To 500-1
For x=0 To 500-1
couleur=Point(x,y)
tableau_pixel(x,y)=couleur
Next x
Next y
StopDrawing()
SetGadgetState(#Image_2, ImageID(image))
ProcedureReturn image
EndProcedure
Procedure bordure(coloris, imageid)
StartDrawing(ImageOutput(imageid))
For y=0 To ImageHeight(imageid)-1
For x=0 To ImageWidth(imageid)-1
couleur=Point(x,y)
Select couleur
Case #White;$ffffff
If x<ImageWidth(imageid)-1 And Point(x+1,y) <> #White And Point(x+1,y) <> coloris
tableau_pixel(x,y)=coloris
Else
tableau_pixel(x,y)=couleur
EndIf
Default
tableau_pixel(x,y)=couleur
EndSelect
Next x
Next y
StopDrawing()
EndProcedure
Procedure borduresensinverse(coloris, imageid)
StartDrawing(ImageOutput(imageid))
For y=0 To ImageHeight(imageid)-1
For x=ImageWidth(imageid)-1 To 0 Step -1
couleur=Point(x,y)
Select couleur
Case #White;$ffffff
If x>1 And Point(x-1,y) <> #White And Point(x-1,y) <> coloris
tableau_pixel(x,y)=coloris
Else
tableau_pixel(x,y)=couleur
EndIf
Default
tableau_pixel(x,y)=couleur
EndSelect
Next x
Next y
StopDrawing()
EndProcedure
Procedure miseajourdessin(imageid)
StartDrawing(ImageOutput(imageid))
For y=0 To ImageHeight(imageid)-1
For x=0 To ImageWidth(imageid)-1
Plot(x,y,tableau_pixel(x,y))
Next x
Next y
StopDrawing()
SetGadgetState(#Image_2, ImageID(imageid))
EndProcedure
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, 100, 84, 600, 600, "Test", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
ButtonGadget(#Button_0, 30, 10, 110, 35, "Dessin")
;ButtonGadget(#Button_1, 255, 10, 115, 35, "Sauver")
ImageGadget(#Image_2, 30, 65, 500, 500, 0, #PB_Image_Border)
EndIf
EndProcedure
OpenWindow_Window_0()
;{- Event loop
Repeat
Event = WaitWindowEvent()
Select Event
; ///////////////////
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
If EventGadget = #Button_0 ;dessin
image=dessin()
;===========================================================
; Je n'arrive pas à avoir les 2 bordures en même temps ! ! !
bordure(#Blue, image) ; dessine une bordure bleue à gauche du cercle
borduresensinverse(#Green, image) ; dessine une bordure verte à droite du cercle
miseajourdessin(image)
ElseIf EventGadget = #Button_1 ;sauve
EndIf
; ////////////////////////
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
CloseWindow(#Window_0)
Break
EndIf
EndSelect
ForEver
;
;}
Mesa.