Je viens de passer l'apres midi a bidouiller mon code. J'ai enlevé le ProgressBarGadget et j'en ai fabriqué un 100% pb.
Et bien, ca plante quand je m'attaque a des dossiers bien fournis en image.
J'ai meme viré toute la partie html pour voir si ca ne venait pas de la. Non, ca bggue quand meme.
J'ai mis Evenement = WaitWindowEvent(1000) mais rien n'y fait.
Donc, il y a un bug mais je ne sais pas ou. Un truc interessant : quand je perd le focus et que je le remet, la barre de progression (que j'ai codé moi meme je le rappelle) bloque mais le calcul des mini images se fait quand meme !
Code : Tout sélectionner
UseJPEGImageEncoder()
UseJPEGImageDecoder()
UseGIFImageDecoder()
UsePNGImageDecoder()
OpenWindow(0, 0, 0, 749, 486+12, "ImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If LoadImage(0, "c:\SPH\PB\titre.bmp") ; changez le 2ème paramètre en indiquant le chemin/fichier contenant votre image
ImageGadget(0, 10, 10, 728, 53, ImageID(0)) ; imagegadget standard
EndIf
Global Repertoire$
calcul=0
ExplorerTreeGadget(1, 11, 73, 360, 300, Repertoire$, #PB_Explorer_NoFiles)
ExplorerListGadget(2, 377,73,360,300, "*.jpg;*.jpeg;*.bmp;*.gif;*.png", #PB_Explorer_NoFolders|#PB_Explorer_NoParentFolder)
FrameGadget(3, 11, 380, 727,65, "", #PB_Frame_Single)
;titre
TextGadget(4, 20, 388,90,20,"Titre de la page :")
StringGadget(5, 20, 410, 150, 20, "")
;vignettes
CheckBoxGadget(6, 200, 388, 70, 20, " Vignettes :")
SetGadgetState(6, #PB_Checkbox_Checked)
TrackBarGadget(8, 200, 410, 180, 25, 0, 12, #PB_TrackBar_Ticks)
SetGadgetState(8, 6)
TextGadget(7, 285, 391, 95, 17, Str(37+GetGadgetState(8)*16)+" pixels de large")
;colonnes
TextGadget(9, 410, 388,50,20,"Colonnes :")
SpinGadget (10, 410, 410, 45, 25, 1, 100)
SetGadgetState (10, 8) : SetGadgetText(10, "8") ; définit la valeur initiale
;papier peint
CheckBoxGadget(11, 490, 388, 80, 20, " Papier peint :")
SetGadgetState(11, #PB_Checkbox_Checked)
ButtonGadget(13, 500, 412, 70, 18, "Couleur")
;14 image fong.gif
If CreateImage(14, 32,32) And StartDrawing(ImageOutput(14))
For x = 0 To 31
For y = 0 To 31
Plot(X, Y, RGB(255,255,255))
Next y
Next x
StopDrawing()
ImageGadget(14, 580, 394, 32, 32, ImageID(14))
EndIf
;visualiser
CheckBoxGadget(15, 650, 388, 80, 20, " Visualiser")
SetGadgetState(15, #PB_Checkbox_Checked)
;generer le html
ButtonGadget(16, 10, 450+15, 729, 28, "Générer la page")
;progressbar
;ProgressBarGadget(17, 110, 453, 529, 8, 0, 100)
CreateImage(17, 329,8)
StartDrawing(ImageOutput(17))
;Debug Str(z)+" "+Str(nombre2*328/nombre)
For x = 0 To 328
For y = 0 To 7
Plot(x, Y, RGB(100+Random(50),40+Random(20),40+Random(20)))
Next y
Next x
StopDrawing()
ImageGadget(17, 210, 453, 329, 8, ImageID(17))
;ImageGadget(0, 10, 10, 728, 53, ImageID(0)) ; imagegadget standard
Procedure Afficher_fichiers()
SetGadgetText(2, "") ; Vider la liste des fichiers
Repertoire$ = GetGadgetText(1) ; Voir quel est le répertoire sélectionné
SetGadgetText(2, Repertoire$) ; Remplir la liste avec le répertoire
EndProcedure
; Si clic gauche sur l'arbre ou déplacement avec les flèches, alors afficher les fichiers dans la fenêtre liste fichiers
BindGadgetEvent(1, @Afficher_fichiers(), #PB_EventType_Change) ; #PB_EventType_LeftClick)
;Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Repeat
Evenement = WaitWindowEvent(1000)
If Evenement = #PB_Event_Gadget And calcul=0
CreateImage(17, 329,8)
StartDrawing(ImageOutput(17))
For x = 0 To 328
For y = 0 To 7
Plot(x, Y, RGB(100+Random(50),40+Random(20),40+Random(20)))
Next y
Next x
StopDrawing()
ImageGadget(17, 210, 453, 329, 8, ImageID(17))
If EventGadget() = 10 And calcul=0
SetGadgetText(10,Str(GetGadgetState(10)))
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If EventGadget() = 8 And calcul=0
SetGadgetText(7, Str(37+GetGadgetState(8)*16)+" pixels de large")
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If EventGadget() = 13 And calcul=0
couleur=ColorRequester()
r=Red(couleur)
v=Green(couleur)
b=Blue(couleur)
Restore fond
If StartDrawing(ImageOutput(14)); And couleur>=0
For u=0 To 31
For i=0 To 31
Read.b c.b
If c=1
If r=255
rr=r-Random(50)
Else
rr=r+Random(50)
EndIf
If v=255
vv=v-Random(50)
Else
vv=v+Random(50)
EndIf
If b=255
bb=b-Random(50)
Else
bb=b+Random(50)
EndIf
Plot(i,u,RGB(rr,vv,bb))
Else
If r>235
rr=r-10-Random(50)
Else
rr=r+10+Random(50)
EndIf
If v>235
vv=v-10-Random(50)
Else
vv=v+10+Random(50)
EndIf
If b>235
bb=b-10-Random(50)
Else
bb=b+10+Random(50)
EndIf
Plot(i,u,RGB(rr,vv,bb))
EndIf
Next
Next
StopDrawing()
ImageGadget(14, 580, 394, 32, 32, ImageID(14))
EndIf
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If EventGadget() = 16 And calcul=0
calcul=1
cmb=0
z=0
If ExamineDirectory(0, Repertoire$, "*.*")
If CreateFile(0, Repertoire$+"index.html")
Else
MessageRequester("Erreur","Fabrication HTML impossible") : End
EndIf
WriteStringN(0,"<!doctype html>")
WriteStringN(0,"<html lang="+Chr(34)+"fr"+Chr(34)+">")
WriteStringN(0,"<head>")
WriteStringN(0,"<title>"+GetGadgetText(5)+"</title>")
WriteStringN(0,"<meta http-equiv="+Chr(34)+"X-UA-Compatible"+Chr(34)+" content="+Chr(34)+"IE=edge"+Chr(34)+">")
WriteStringN(0,"<meta charset="+Chr(34)+"utf-8"+Chr(34)+" />")
WriteStringN(0,"</head>")
WriteStringN(0,"<body background="+Chr(34)+"fond.gif"+Chr(34)+">")
WriteStringN(0,"<center>")
nombre=0
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
file$= DirectoryEntryName(0)
; debug file$
a$=Right(file$,5)
Position = FindString(a$,".")
If position<>0
type$=Right(a$,5-position)
; debug type$
If (LCase(type$)="jpg" Or LCase(type$)="jpeg" Or LCase(type$)="bmp" Or LCase(type$)="gif" Or LCase(type$)="png") And LCase(file$)<>"fond.gif"
nombre+1
EndIf
EndIf
EndIf
Wend
FinishDirectory(0)
; debug nombre
; ProgressBarGadget(16, 110, 453, 529, 22, 0, nombre)
; ProgressBarGadget(16, 110, 453, 529, 22, 0, nombre, #PB_ProgressBar_Smooth)
nombre2=0
;;;;;;;;;;;;
ExamineDirectory(0, Repertoire$, "*.*")
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
file$= DirectoryEntryName(0)
; debug file$
;;;
TextGadget(0,250,20, 391, 40, file$);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
a$=Right(file$,5)
Position = FindString(a$,".")
If position<>0
type$=Right(a$,5-position)
; debug type$
gadgetX=37+GetGadgetState(8)*16
If (LCase(type$)="jpg" Or LCase(type$)="jpeg" Or LCase(type$)="bmp" Or LCase(type$)="gif" Or LCase(type$)="png") And LCase(file$)<>"fond.gif"
If GetGadgetState(6)<>0
If wwww=0
CreateDirectory(Repertoire$+"mini")
wwww=1
EndIf
LoadImage(0,Repertoire$+file$)
CopyImage(0,1)
;;;;;;;;;;;
imagex=ImageWidth(0)
imagey=ImageHeight(0)
If imagex>imagey
imx=gadgetX
imy=imagey*imx/imagex
Else
imy=gadgetX
imx=imagex*imy/imagey
EndIf
;;;;;;;;;;;
ResizeImage(1, imx,imy)
SaveImage(1,Repertoire$+"mini/"+file$,#PB_ImagePlugin_JPEG)
FreeImage(1)
EndIf
WriteStringN(0,"<td align=center valign=center>")
WriteStringN(0,"<a href="+Chr(34)+file$+Chr(34)+" target="+Chr(34)+"_blank"+Chr(34)+">")
WriteStringN(0,"<img src="+Chr(34)+"mini/"+file$+Chr(34)+" border=1></a>")
WriteStringN(0,"</td>")
nombre2+1
;SetGadgetState (17,nombre2*100/nombre)
StartDrawing(ImageOutput(17))
;Debug Str(z)+" "+Str(nombre2*328/nombre)
For x = z To nombre2*328/nombre
For y = 0 To 7
Plot(x, Y, RGB(20+Random(30),200+Random(55),20+Random(30)))
Next y
Next x
z=nombre2*328/nombre
StopDrawing()
;ImageGadget(0, 0, 0, 200, 200, ImageID(0))
ImageGadget(17, 210, 453, 329, 8, ImageID(17))
;ProgressBarGadget(17, 110, 453, 529, 8, 0, 100)
cmb+1
If cmb>=GetGadgetState(10)
cmb=0
WriteStringN(0,"<br />")
EndIf
EndIf
EndIf
EndIf
Wend
FinishDirectory(0)
WriteStringN(0,"<br />")
WriteStringN(0,"</body>")
WriteStringN(0,"</html>")
CloseFile(0)
EndIf
SaveImage(14, Repertoire$+"fond.gif")
If GetGadgetState(15)<>0
RunProgram( Repertoire$+"index.html")
EndIf
;ButtonGadget(16, 10, 450, 729, 28, "Générer la page")
calcul=0
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EndIf
Until Evenement = #PB_Event_CloseWindow
End
;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;
DataSection
fond:
Data .b 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Data .b 1,1,1,1,1,1,1,1,1,1,1,1,1,1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