Voici un code qui me sert pour retailler des images... si cela peut donner des idées, sinon vous le zapper.
Code : Tout sélectionner
Procedure Rotation_Image_90_horaire(idgadget)
;UseImage(idgadget)
; récupère la dimension de l'image
ImageX = ImageWidth(idgadget)
ImageY = ImageHeight(idgadget)
;
; On récupère l'image
Dim Pixel.l(ImageX, ImageY)
;UseImage(#img)
StartDrawing(ImageOutput(idgadget))
For Px = 0 To ImageX
For Py = 0 To ImageY
Pixel(Px, Py) = Point(Px, Py)
Next
; on fait progresser la barre
; SetGadgetState(#Barre, Px)
Next
StopDrawing()
ResizeImage(idgadget, ImageY, ImageX)
StartDrawing(ImageOutput(idgadget)) ; on dessine sur l'image
x = 0 ; on se place en x=0 sur l'image
y_base=ImageY
Repeat
y = 0 ; on se place en y=0 sur l'image
x_base=0
Repeat
Plot(x, y, Pixel(x_base, y_base)) ; on dessine un carré qui fait le nouveau pixel de la même couleur que celle récupéré en x et y
; on se déplace sur l'image en y de la taille d'un pixel
y = y + 1
x_base = x_base+1
Until y >= ImageX ; si on a finit la colonne de l'image placé en x
; on se déplace sur l'image en x de la taille d'un pixel
x = x + 1
y_base = y_base-1
; on fait progresser la barre
;SetGadgetState(#Barre, X)
Until x >= ImageY ; si on a traité toutes les lignes de l'image
;SaveImage(0, "d:\ess.jpg", #PB_ImagePlugin_JPEG, 7)
StopDrawing()
EndProcedure
Procedure Rotation_Image_90_anti_horaire(idgadget)
;UseImage(idgadget)
; récupère la dimension de l'image
ImageX = ImageWidth(idgadget)
ImageY = ImageHeight(idgadget)
;
; On récupère l'image
Dim Pixel.l(ImageX, ImageY)
;UseImage(#img)
StartDrawing(ImageOutput(idgadget))
For Px = 0 To ImageX
For Py = 0 To ImageY
Pixel(Px, Py) = Point(Px, Py)
Next
Next
StopDrawing()
ResizeImage(idgadget, ImageY, ImageX)
StartDrawing(ImageOutput(idgadget)) ; on dessine sur l'image
x = ImageY-1 ; on se place en x=0 sur l'image
y_base=ImageY
Repeat
y = ImageX-1 ; on se place en y=0 sur l'image
x_base=0
Repeat
Plot(x, y, Pixel(x_base, y_base)) ; on dessine un carré qui fait le nouveau pixel de la même couleur que celle récupéré en x et y
; on se déplace sur l'image en y de la taille d'un pixel
y = y - 1
x_base = x_base+1
Until y <= -1 ; si on a finit la colonne de l'image placé en x
; on se déplace sur l'image en x de la taille d'un pixel
x = x - 1
y_base = y_base-1
; on fait progresser la barre
;SetGadgetState(#Barre, X)
Until x <= -1 ; si on a traité toutes les lignes de l'image
;SaveImage(0, "d:\ess.jpg", #PB_ImagePlugin_JPEG, 7)
StopDrawing()
EndProcedure
Procedure retaille_image_dans_cadre(id_image,Largeur_fenetre,Hauteur_fenetre)
Hauteur_image.f = ImageHeight(id_image)
Largeur_image.f = ImageWidth(id_image)
rapport_fenetre.f = Hauteur_fenetre /Largeur_fenetre
rapport_image.f = Hauteur_image /Largeur_image
If rapport_image=rapport_fenetre
h=Hauteur_fenetre
l=Largeur_fenetre
EndIf
If rapport_image>rapport_fenetre
h=Hauteur_fenetre
l=Hauteur_fenetre/rapport_image
sens_image=0
EndIf
If rapport_image<rapport_fenetre
h=Largeur_fenetre*rapport_image
l=Largeur_fenetre
sens_image=1
EndIf
ResizeImage(id_image, l, h)
EndProcedure
Procedure retaille_image_dans_cadre_centrer(id_fenetre,id_image,id_gadget,x,y,Largeur_fenetre,Hauteur_fenetre,type=0)
;type=0 : ne pas retailler si plus petite
; type=1 : retailler même si plus petite
If IsImage(id_image)
rapx.f=WindowWidth(id_fenetre)/800
rapy.f=WindowHeight(id_fenetre)/600
x =x*rapx
y =y*rapy
Largeur_fenetre =Largeur_fenetre*rapx
Hauteur_fenetre =Hauteur_fenetre*rapy
Hauteur_image.f = ImageHeight(id_image)
Largeur_image.f = ImageWidth(id_image)
rapport_fenetre.f = Hauteur_fenetre /Largeur_fenetre
rapport_image.f = Hauteur_image /Largeur_image
If Hauteur_image<Hauteur_fenetre And Largeur_image<Largeur_fenetre And type=0
h=Hauteur_image
l=Largeur_image
Else
If rapport_image=rapport_fenetre
h=Hauteur_fenetre
l=Largeur_fenetre
EndIf
If rapport_image>rapport_fenetre
h=Hauteur_fenetre
l=Hauteur_fenetre/rapport_image
sens_image=0
EndIf
If rapport_image<rapport_fenetre
h=Largeur_fenetre*rapport_image
l=Largeur_fenetre
sens_image=1
EndIf
EndIf
ResizeImage(id_image, l, h)
xa=(Largeur_fenetre-l)/2+x
ya=(Hauteur_fenetre-h)/2+y
;debug xa
;debug ya
ResizeGadget(id_gadget,xa,ya,10,10)
SetGadgetState(id_gadget,ImageID(id_image))
EndIf
EndProcedure
Procedure retaille_image_dans_cadre_centrer_fenetre_fixe(id_image,id_gadget,x,y,Largeur_fenetre,Hauteur_fenetre,type=0)
;type=0 : ne pas retailler si plus petite
; type=1 : retailler même si plus petite
If IsImage(id_image)
Hauteur_image.f = ImageHeight(id_image)
Largeur_image.f = ImageWidth(id_image)
rapport_fenetre.f = Hauteur_fenetre /Largeur_fenetre
rapport_image.f = Hauteur_image /Largeur_image
If Hauteur_image<Hauteur_fenetre And Largeur_image<Largeur_fenetre And type=0
h=Hauteur_image
l=Largeur_image
Else
If rapport_image=rapport_fenetre
h=Hauteur_fenetre
l=Largeur_fenetre
EndIf
If rapport_image>rapport_fenetre
h=Hauteur_fenetre
l=Hauteur_fenetre/rapport_image
sens_image=0
EndIf
If rapport_image<rapport_fenetre
h=Largeur_fenetre*rapport_image
l=Largeur_fenetre
sens_image=1
EndIf
EndIf
ResizeImage(id_image, l, h)
xa=(Largeur_fenetre-l)/2+x
ya=(Hauteur_fenetre-h)/2+y
;debug xa
;debug ya
ResizeGadget(id_gadget,xa,ya,#PB_Ignore,#PB_Ignore)
SetGadgetState(id_gadget,ImageID(id_image))
EndIf
EndProcedure
Procedure Is_point_in_cercle(x_m,y_m,x,y,r)
;debug "Procedure Is_point_in_cercle(x_m,y_m,x,y,r)"
;debug Str(x_m)+" : "+Str(y_m)+" / "+Str(x)+" : "+Str(y)
If x_m<=x+r And x_m>=x-r And y_m<=y+r And y_m>=y-r
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
EndProcedure
Procedure change_contrast(id_image,Niveau.f = 0.1,id_progress_barre=-1)
;debug "Procedure change_contrast(id_image,id_progress_barre=-1)"
;debug id_image
ImageX = ImageWidth(id_image)
ImageY = ImageHeight(id_image)
StartDrawing(ImageOutput(id_image))
For x=0 To ImageX
For y=0 To ImageY
;Debug "x= "+Str(x)+" : y= "+Str(y)
; on récupère la couleur du point en x et y
Couleur = Point(x, y);Pixel(x, y)
Rouge.f = Red(Couleur)
Vert.f = Green(Couleur)
Bleu.f = Blue(Couleur)
; On augmente le contraste
Rouge = Rouge * (Niveau * Rouge / 255 + 1 - Niveau / 2)
If Rouge > 255 : Rouge = 255 : EndIf
Vert = Vert * (Niveau * Vert / 255 + 1 - Niveau / 2)
If Vert > 255 : Vert = 255 : EndIf
Bleu = Bleu * (Niveau * Bleu / 255 + 1 - Niveau / 2)
If Bleu > 255 : Bleu = 255 : EndIf
; On recalcule la nouvelle couleur
Couleur = RGB(Rouge, Vert, Bleu)
; si la taille du nouveau pixel est positive
Plot(x, y, Couleur) ; on dessine un carré qui fait le nouveau pixel de la même couleur que celle récupéré en x et y
Next
If id_progress_barre<>-1
SetGadgetState(id_progress_barre, x*100/ImageX)
EndIf
Next
StopDrawing()
SetGadgetState(id_progress_barre, 0)
EndProcedure
Procedure change_lumiere(id_image,Niveau.f = 0.1,id_progress_barre=-1)
;debug "Procedure change_contrast(id_image,id_progress_barre=-1)"
;debug id_image
ImageX = ImageWidth(id_image)
ImageY = ImageHeight(id_image)
StartDrawing(ImageOutput(id_image))
For x=0 To ImageX
For y=0 To ImageY
;Debug "x= "+Str(x)+" : y= "+Str(y)
; on récupère la couleur du point en x et y
Couleur = Point(x, y);Pixel(x, y)
Rouge.f = Red(Couleur)
Vert.f = Green(Couleur)
Bleu.f = Blue(Couleur)
; On augmente la luminosité
Rouge = Rouge * (Niveau + 1)
If Rouge > 255 : Rouge = 255 : EndIf
Vert = Vert * (Niveau + 1)
If Vert > 255 : Vert = 255 : EndIf
Bleu = Bleu * (Niveau + 1)
If Bleu > 255 : Bleu = 255 : EndIf
; On recalcule la nouvelle couleur
Couleur = RGB(Rouge, Vert, Bleu)
; si la taille du nouveau pixel est positive
Plot(x, y, Couleur) ; on dessine un carré qui fait le nouveau pixel de la même couleur que celle récupéré en x et y
Next
If id_progress_barre<>-1
SetGadgetState(id_progress_barre, x*100/ImageX)
EndIf
Next
StopDrawing()
SetGadgetState(id_progress_barre, 0)
EndProcedure
Procedure affiche_rectangle_retaille(id_fenetre,id_gadget_image,id_image,x,y,l,h,coin_sel$="")
Debug "affiche_rectangle_retaille(id_fenetre,id_gadget"
SetGadgetState(id_gadget_image,ImageID(id_image))
StartDrawing(WindowOutput(id_fenetre) )
DrawingMode(#PB_2DDrawing_Outlined )
Box(x,y,l,h,$000000)
Box(x+1,y+1,l-2,h-2,$BFFFF8)
DrawingMode(#PB_2DDrawing_Default)
r=8
Box(x,y,r,r,$D737D7)
Box(x+l-r,y+h-r,r,r,$D737D7)
Box(x+l-r,y,r,r,$D737D7)
Box(x,y+h-r,r,r,$D737D7)
Select coin_sel$
Case "hg"
Box(x,y,r,r,$33DB4D)
Case "hd"
Box(x+l-r,y,r,r,$33DB4D)
Case "bg"
Box(x,y+h-r,r,r,$33DB4D)
Case "bd"
Box(x+l-r,y+h-r,r,r,$33DB4D)
EndSelect
StopDrawing()
EndProcedure
Procedure fenetre_retaille_image(id_fenetre_appelante_retouche_image,id_image,id_image_retour,l_recadre_demander=-1,h_recadre_demander=-1)
cr_nesw= LoadCursor_(0, #IDC_SIZENWSE )
cr_nwse = LoadCursor_(0, #IDC_SIZENESW )
Enumeration #PB_Compiler_EnumerationValue
#id_image_retour_temp
#im_retouche_image
EndEnumeration
;{Définition de la fenetre
retaille_image.b=0
If id_fenetre_appelante_retouche_image>=0
Fenetre_retouche_image=OpenWindow(#PB_Any,0,0,400,400,"Retouche image",#PB_Window_Maximize | #PB_Window_SystemMenu ,WindowID(id_fenetre_appelante_retouche_image))
Else
Fenetre_retouche_image=OpenWindow(#PB_Any,0,0,400,400,"Retouche image",#PB_Window_Maximize | #PB_Window_SystemMenu )
EndIf
SetWindowColor(Fenetre_retouche_image,$000000)
x_im_gadget=10
y_im_gadget=45
l_image_aff=WindowWidth(Fenetre_retouche_image)-x_im_gadget-10
h_image_aff=WindowHeight(Fenetre_retouche_image)-y_im_gadget-20
CopyImage(id_image,#id_image_retour_temp)
CopyImage(#id_image_retour_temp,#im_retouche_image)
;debug #im_retouche_image
retaille_image_dans_cadre(#im_retouche_image,l_image_aff,h_image_aff)
;ResizeImage(#im_retouche_image,l_image_aff,h_image_aff)
CreateGadgetList(WindowID(Fenetre_retouche_image))
im_gadget_retouche_image=ImageGadget(#PB_Any,x_im_gadget,y_im_gadget,10,10,ImageID(#im_retouche_image))
Barre_retouche_image=ProgressBarGadget(#PB_Any, 10, WindowHeight(Fenetre_retouche_image)-20, WindowWidth(Fenetre_retouche_image)-20, 18, 0, 100)
SetGadgetColor(Barre_retouche_image,#PB_Gadget_FrontColor,$DF6871)
SetGadgetColor(Barre_retouche_image,#PB_Gadget_BackColor,$821C23)
x=2
y=1
l=60
txt1=TextGadget(#PB_Any,x,y,150,16,"1) Retailler l'image (déplacer le")
txt2=TextGadget(#PB_Any,x,y+18,150,16," cadre en glissant les coins."): x=x+160
btn_retaille_retouche_image=ButtonGadget(#PB_Any,x,y+10,l,20,"Retaille") : x=x+l+30
txt3=TextGadget(#PB_Any,x,y,2200,16,"2) Ajuster, si besoin, la lumière et le contrast.") :x=x+5
txt5=TextGadget(#PB_Any,x,y+20,50,20,"Contrast :"): x=x+52
btn_contrast_moins_retouche_image=ButtonGadget(#PB_Any,x,y+20,20,20,"-") : x=x+22
btn_contrast_plus_retouche_image=ButtonGadget( #PB_Any,x,y+20,20,20,"+") : x=x+30
txt6=TextGadget(#PB_Any,x,y+20,50,20,"Lumière :"): x=x+52
btn_lumiere_moins_retouche_image=ButtonGadget(#PB_Any,x,y+20,20,20,"-") : x=x+22
btn_lumiere_plus_retouche_image=ButtonGadget(#PB_Any,x,y+20,20,20,"+") : x=x+70
txt7=TextGadget(#PB_Any,x,y,2200,16,"3) Tourner l'image à 90 °.") :x=x+5
btn_tourne_anti_horaire_retouche_image=ButtonGadget( #PB_Any,x,y+20,60,20,"Anti Horaire") : x=x+62
btn_tourne_horaire_retouche_image=ButtonGadget(#PB_Any,x,y+20,40,20,"Horaire") : x=x+80
txt4=TextGadget(#PB_Any,x,y,180,16,"4) Valider ou recommencer.")
btn_fin_retouche_image=ButtonGadget(#PB_Any,x,y+20,l,20,"Valider") : x=x+l+10
btn_retour_retouche_image=ButtonGadget(#PB_Any,x,y+20,l+15,20,"Recommencer") : x=x+l+10
DisableGadget(btn_contrast_moins_retouche_image,1)
DisableGadget(btn_contrast_plus_retouche_image,1)
DisableGadget(btn_lumiere_moins_retouche_image,1)
DisableGadget(btn_lumiere_plus_retouche_image,1)
DisableGadget(btn_fin_retouche_image,1)
DisableGadget(btn_retour_retouche_image,1)
DisableGadget(btn_tourne_horaire_retouche_image,1)
DisableGadget(btn_tourne_anti_horaire_retouche_image,1)
DisableGadget(btn_retaille_retouche_image,0)
couleur_text=$FFFFFF
couleur_fond=$000000
SetGadgetColor( txt1 ,#PB_Gadget_FrontColor , couleur_text )
SetGadgetColor( txt1 ,#PB_Gadget_BackColor ,couleur_fond)
SetGadgetColor( txt2 ,#PB_Gadget_FrontColor,couleur_text)
SetGadgetColor( txt2 ,#PB_Gadget_BackColor ,couleur_fond)
SetGadgetColor( txt3 ,#PB_Gadget_FrontColor,couleur_text)
SetGadgetColor( txt3 ,#PB_Gadget_BackColor ,couleur_fond)
SetGadgetColor( txt4 ,#PB_Gadget_FrontColor,couleur_text)
SetGadgetColor( txt4 ,#PB_Gadget_BackColor ,couleur_fond)
SetGadgetColor( txt7 ,#PB_Gadget_FrontColor,couleur_text)
SetGadgetColor( txt7 ,#PB_Gadget_BackColor ,couleur_fond)
couleur_text=$ED6F54
SetGadgetColor( txt5 ,#PB_Gadget_FrontColor,couleur_text)
SetGadgetColor( txt5 ,#PB_Gadget_BackColor ,couleur_fond)
SetGadgetColor( txt6 ,#PB_Gadget_FrontColor,couleur_text)
SetGadgetColor( txt6 ,#PB_Gadget_BackColor ,couleur_fond)
; SetGadgetColor( ,#PB_Gadget_FrontColor,couleur_text)
; SetGadgetColor( ,#PB_Gadget_BackColor ,couleur_fond)
; SetGadgetColor( ,#PB_Gadget_FrontColor,couleur_text)
; SetGadgetColor( ,#PB_Gadget_BackColor ,couleur_fond)
; SetGadgetColor( ,#PB_Gadget_FrontColor,couleur_text)
; SetGadgetColor( ,#PB_Gadget_BackColor ,couleur_fond)
;}
;{initialisation des longueur
contrast.f=0
lumiere.f=0
x_recadre=GadgetX(im_gadget_retouche_image)
y_recadre=GadgetY(im_gadget_retouche_image)
l_recadre=GadgetWidth(im_gadget_retouche_image)
h_recadre=GadgetHeight(im_gadget_retouche_image)
x_d =x_recadre
y_d=y_recadre
l_d =l_recadre
h_d =h_recadre
; If l_recadre_demander<>-1 And h_recadre_demander<>-1
; rap.f=h_recadre_demander/l_recadre_demander
; l_recadre=l_recadre_demander
; Else
; rap=600/800
; l_recadre=100
; EndIf
;
; h_recadre=l_recadre*rap
;}
affiche_rectangle_retaille(Fenetre_retouche_image,im_gadget_retouche_image,#im_retouche_image,x_recadre,y_recadre,l_recadre,h_recadre)
Repeat
event=WaitWindowEvent()
id_window=EventWindow()
Select id_window
Case Fenetre_retouche_image;{
;MessageRequester("Information", Str(WaitWindowEvent()), 0)
Select event
Case #WM_KEYDOWN ;{touche clavier
;debug "Appuye touche "+Str(EventwParam())
id_touche=EventwParam()
Select id_touche
Case 107 ;{+
l_recadre+10
h_recadre=l_recadre*rap
affiche_rectangle_retaille( Fenetre_retouche_image, im_gadget_retouche_image, #im_retouche_image,x_recadre,y_recadre,l_recadre,h_recadre)
;}
Case 109 ;{-
l_recadre-10
h_recadre=l_recadre*rap
affiche_rectangle_retaille( Fenetre_retouche_image, im_gadget_retouche_image, #im_retouche_image,x_recadre,y_recadre,l_recadre,h_recadre)
;}
EndSelect
;}
Case #WM_LBUTTONUP;{
If debut_drag_retaille_image=1 And retaille_image=0;{ fin de drag un coin
x_recadre=x_d
y_recadre= y_d
l_recadre=l_d
h_recadre=h_d
affiche_rectangle_retaille( Fenetre_retouche_image, im_gadget_retouche_image, #im_retouche_image,x_recadre,y_recadre,l_recadre,h_recadre,coin_drag$)
EndIf
debut_drag_retaille_image=0
;}
;}
Case #WM_MOUSEMOVE ;{
If retaille_image=0
xc=WindowMouseX( Fenetre_retouche_image);+GadgetX(im_gadget_retouche_image)
yc=WindowMouseY( Fenetre_retouche_image)
If debut_drag_retaille_image=0
;{Changement des icones aux quatres coins
r=8
coin$=""
If Is_point_in_cercle(xc,yc,x_recadre,y_recadre,r) : SetCursor_(cr_nesw) : coin$="hg" : EndIf
If Is_point_in_cercle(xc,yc,x_recadre+l_recadre,y_recadre,r) : SetCursor_(cr_nwse) : coin$="hd" : EndIf
If Is_point_in_cercle(xc,yc,x_recadre,y_recadre+h_recadre,r) : SetCursor_(cr_nwse) : coin$="bg" : EndIf
If Is_point_in_cercle(xc,yc,x_recadre+l_recadre,y_recadre+h_recadre,r) : SetCursor_(cr_nesw) : coin$="bd" : EndIf
If coin$<>der_coin$
der_coin$=coin$
affiche_rectangle_retaille( Fenetre_retouche_image, im_gadget_retouche_image, #im_retouche_image,x_recadre,y_recadre,l_recadre,h_recadre,coin$)
EndIf
;}
Else
;{calcul des deltas deplacements
dx=xdd-xc
dy=ydd-yc
dmini=20
gx=GadgetX(im_gadget_retouche_image)
gy=GadgetY(im_gadget_retouche_image)
gx2=GadgetX(im_gadget_retouche_image)+GadgetWidth(im_gadget_retouche_image)
gy2=GadgetY(im_gadget_retouche_image)+GadgetHeight(im_gadget_retouche_image)
;}
Select coin_drag$
Case "hg" ;{haut gauche
SetCursor_(cr_nesw)
x_d=x_recadre-dx
y_d=y_recadre-dy
l_d=l_recadre+dx
h_d=h_recadre+dy
If x_d<gx : l_d=x_recadre+l_recadre-gx :x_d=gx : EndIf
If x_d>x_recadre+l_recadre-dmini : l_d=dmini : x_d=x_recadre+l_recadre-dmini : EndIf
If y_d<gy : h_d=y_recadre+h_recadre-gy :y_d=gy : EndIf
If y_d>y_recadre+h_recadre-dmini : h_d=dmini : y_d=y_recadre+h_recadre-dmini : EndIf
;}
Case "hd" ;{haut droit
SetCursor_(cr_nwse)
x_d=x_recadre
y_d=y_recadre-dy
l_d=l_recadre-dx
h_d=h_recadre+dy
If x_d+l_d>gx2 : l_d=gx2-x_recadre : EndIf
If l_d<dmini : l_d=dmini : EndIf
If y_d<gy : h_d=y_recadre+h_recadre-gy :y_d=gy : EndIf
If y_d>y_recadre+h_recadre-dmini : h_d=dmini : y_d=y_recadre+h_recadre-dmini : EndIf
;}
Case "bg" ;{bas gauche
SetCursor_(cr_nwse)
x_d=x_recadre-dx
y_d=y_recadre
l_d=l_recadre+dx
h_d=h_recadre-dy
If x_d<gx : l_d=x_recadre+l_recadre-gx :x_d=gx : EndIf
If x_d>x_recadre+l_recadre-dmini : l_d=dmini : x_d=x_recadre+l_recadre-dmini : EndIf
If y_d+h_d>gy2 : h_d=gy2-y_recadre : EndIf
If h_d<dmini : h_d=dmini : EndIf
;}
Case "bd" ;{bas droit
SetCursor_(cr_nesw)
x_d=x_recadre
y_d=y_recadre
l_d=l_recadre-dx
h_d=h_recadre-dy
If x_d+l_d>gx2 : l_d=gx2-x_recadre : EndIf
If l_d<dmini : l_d=dmini : EndIf
If y_d+h_d>gy2 : h_d=gy2-y_recadre : EndIf
If h_d<dmini : h_d=dmini : EndIf
;}
EndSelect
affiche_rectangle_retaille( Fenetre_retouche_image, im_gadget_retouche_image, #im_retouche_image,x_d,y_d,l_d,h_d,coin_drag$)
EndIf
EndIf
;}
Case #PB_Event_Gadget;{*****************Choix d'un bouton
id_gadget=EventGadget()
;Debug id_gadget
Select id_gadget
Case btn_retour_retouche_image;{
retaille_image=0
CopyImage(id_image, #id_image_retour_temp)
CopyImage(#id_image_retour_temp, #im_retouche_image)
retaille_image_dans_cadre( #im_retouche_image,l_image_aff,h_image_aff)
ResizeGadget(im_gadget_retouche_image,x_im_gadget,y_im_gadget,#PB_Ignore,#PB_Ignore)
SetGadgetState(im_gadget_retouche_image,ImageID( #im_retouche_image))
affiche_rectangle_retaille( Fenetre_retouche_image, im_gadget_retouche_image, #im_retouche_image,x_recadre,y_recadre,l_recadre,h_recadre)
DisableGadget(btn_contrast_moins_retouche_image,1)
DisableGadget(btn_contrast_plus_retouche_image,1)
DisableGadget(btn_lumiere_moins_retouche_image,1)
DisableGadget(btn_lumiere_plus_retouche_image,1)
DisableGadget(btn_fin_retouche_image,1)
DisableGadget(btn_retour_retouche_image,1)
DisableGadget(btn_tourne_horaire_retouche_image,1)
DisableGadget(btn_tourne_anti_horaire_retouche_image,1)
DisableGadget(btn_retaille_retouche_image,0)
;}
Case im_gadget_retouche_image ;{Clic sur l'image
x_im=WindowMouseX( Fenetre_retouche_image);+GadgetX(im_gadget_retouche_image)
y_im=WindowMouseY( Fenetre_retouche_image);+GadgetY(im_gadget_retouche_image)
;Debug EventType()
;Debug EventlParam()
;Debug EventwParam()
Select EventType()
Case 0
xdd=x_im
ydd=y_im
coin_drag$=coin$
Case 1
Case #PB_EventType_DragStart
debut_drag_retaille_image=1
;debug "debut drag "+ coin_drag$ +" en : "+Str(xdd)+" / "+Str(ydd)
EndSelect
;affiche_rectangle_retaille( Fenetre_retouche_image, im_gadget_retouche_image, #im_retouche_image,x_recadre,y_recadre,l_recadre,h_recadre,x_im,y_im)
;}
Case btn_contrast_plus_retouche_image, btn_contrast_moins_retouche_image ;{Contraste
If id_gadget= btn_contrast_moins_retouche_image
contrast=-0.1
Else
contrast=0.1
EndIf
;debug contrast
;CopyImage( #id_image_retour_temp, #im_retouche_image)
change_contrast( #id_image_retour_temp,contrast, Barre_retouche_image)
CopyImage( #id_image_retour_temp, #im_retouche_image)
retaille_image_dans_cadre_centrer_fenetre_fixe(#im_retouche_image,im_gadget_retouche_image,x_im_gadget,y_im_gadget,l_image_aff,h_image_aff)
;affiche_rectangle_retaille( Fenetre_retouche_image, im_gadget_retouche_image, #im_retouche_image,x_recadre,y_recadre,l_recadre,h_recadre,coin_drag$)
;}
Case btn_lumiere_plus_retouche_image, btn_lumiere_moins_retouche_image ;{lumière
If id_gadget= btn_lumiere_moins_retouche_image
lumiere=-0.1
Else
lumiere=0.1
EndIf
;debug lumiere
;CopyImage(##id_image_retour_temp,##im_retouche_image)
change_lumiere( #id_image_retour_temp,lumiere, Barre_retouche_image)
CopyImage( #id_image_retour_temp, #im_retouche_image)
retaille_image_dans_cadre_centrer_fenetre_fixe(#im_retouche_image,im_gadget_retouche_image,x_im_gadget,y_im_gadget,l_image_aff,h_image_aff)
;}
Case btn_tourne_horaire_retouche_image
Rotation_Image_90_horaire(#id_image_retour_temp)
CopyImage( #id_image_retour_temp, #im_retouche_image)
retaille_image_dans_cadre_centrer_fenetre_fixe(#im_retouche_image,im_gadget_retouche_image,x_im_gadget,y_im_gadget,l_image_aff,h_image_aff)
Case btn_tourne_anti_horaire_retouche_image
Rotation_Image_90_anti_horaire(#id_image_retour_temp)
CopyImage( #id_image_retour_temp, #im_retouche_image)
retaille_image_dans_cadre_centrer_fenetre_fixe(#im_retouche_image,im_gadget_retouche_image,x_im_gadget,y_im_gadget,l_image_aff,h_image_aff)
Case btn_retaille_retouche_image;{
rap_image.f=ImageWidth( #id_image_retour_temp)/GadgetWidth(im_gadget_retouche_image)
x=x_recadre-GadgetX( im_gadget_retouche_image)
y=y_recadre-GadgetY( im_gadget_retouche_image)
GrabImage( #id_image_retour_temp, #id_image_retour_temp, x*rap_image, y*rap_image, l_recadre*rap_image, h_recadre*rap_image)
If l_recadre_demander<>-1 And h_recadre_demander<>-1
retaille_image_dans_cadre( #id_image_retour_temp,l_recadre_demander,h_recadre_demander)
EndIf
CopyImage( #id_image_retour_temp, #im_retouche_image)
retaille_image_dans_cadre_centrer_fenetre_fixe(#im_retouche_image,im_gadget_retouche_image,x_im_gadget,y_im_gadget,l_image_aff,h_image_aff)
retaille_image=1
DisableGadget(btn_contrast_moins_retouche_image,0)
DisableGadget(btn_contrast_plus_retouche_image,0)
DisableGadget(btn_lumiere_moins_retouche_image,0)
DisableGadget(btn_lumiere_plus_retouche_image,0)
DisableGadget(btn_fin_retouche_image,0)
DisableGadget(btn_retour_retouche_image,0)
DisableGadget(btn_retour_retouche_image,0)
DisableGadget(btn_tourne_horaire_retouche_image,0)
DisableGadget(btn_tourne_anti_horaire_retouche_image,0)
DisableGadget(btn_retaille_retouche_image,1)
;}
Case btn_fin_retouche_image ;{
If retaille_image=0
resu=MessageRequester("Oups","L'image n'a pas été retaillée, elle ne sera pas importer sans retaillage !"+Chr(10)+"Voulez vous toujours quitter ?",#PB_MessageRequester_YesNo )
If resu=6
Quit_programme_image =1
EndIf
Else
Quit_programme_image =1
EndIf
;}
EndSelect
;}
Case #PB_Event_Menu ;{********************Choix d'un menu
Select EventMenu()
EndSelect
;}
Case #PB_Event_CloseWindow
If retaille_image=0
resu=MessageRequester("Oups","L'image n'a pas été retaillée, elle ne sera pas importer sans retaillage !"+Chr(10)+"Voulez vous toujours quitter ?",#PB_MessageRequester_YesNo )
If resu=6
Quit_programme_image =1
EndIf
Else
Quit_programme_image =1
EndIf
EndSelect
;}
EndSelect
Until Quit_programme_image = 1
CloseWindow(Fenetre_retouche_image)
CopyImage( #id_image_retour_temp, id_image_retour)
ProcedureReturn retaille_image
EndProcedure
OpenWindow(0,10,10,400,400,"test")
CreateGadgetList(WindowID(0))
ImageGadget(1,0,0,10,10,0)
UseJPEGImageDecoder()
file$=OpenFileRequester("Nom de l'image","c:\","",0)
LoadImage(1,file$) ; changer le nom de l'image
fenetre_retaille_image(0,1,1,300,300)
SetGadgetState(1,ImageID(1))
Repeat
Until WaitWindowEvent()=#WM_CLOSE