Page 1 sur 1

IrisPicture

Publié : mer. 08/avr./2009 9:27
par KrisJNT
Bonjour à tous !

Un petit prog pour visualiser ses photos JPG que j'ai fait hier soir (versio bêta voire alpha):

Pour la versio complète, vous pouvez le télécharger ici (l'installeur permet d'associer les JPG avec automatiquement et d'avoir l'icône en plus, sinon, il faut rajouter l'argument d'une photo JPG à la compilation, quand vous copiez le code source dans l'IDE) : http://jntradio.free.fr/setup_IFirispictureWin32.exe

Code : Tout sélectionner

Declare.s GetPhoto(command.s)
Declare LoadIt(path.s, hasToClose)

ExamineDesktops()
Global xSize = DesktopWidth(0)
Global ySize = DesktopHeight(0)

UseJPEGImageDecoder()

OpenWindow(1, 0, 0, 0, 0, "IrisPicture", #PB_Window_BorderLess|#PB_Window_ScreenCentered)
TextGadget(5, 0, Int((ySize - 15) / 2), xSize, 15, "Chargement...", #PB_Text_Center)
SetGadgetColor(5, #PB_Gadget_BackColor, 0)
SetGadgetColor(5, #PB_Gadget_FrontColor, $FFFFFF)
SetWindowColor(1, 0)
Style = GetWindowLong_(WindowID(1), #GWL_EXSTYLE)
SetWindowLong_(WindowID(1), #GWL_EXSTYLE, Style|#WS_EX_LAYERED|#WS_EX_TOOLWINDOW)
SetLayeredWindowAttributes_(WindowID(1), 0, 200, #LWA_ALPHA)
ResizeWindow(1, 0, 0, xSize, ySize)

command.s = PeekS(GetCommandLine_(), -1, #PB_Unicode)
path.s = GetPhoto(command)

ExamineDirectory(0, GetPathPart(path), "*.jpg")
Dim listOfJPG.s(1)
nbFile = 1

While NextDirectoryEntry(0)
	If DirectoryEntryType(0) = #PB_DirectoryEntry_File
		nbFile = nbFile + 1
		ReDim listOfJPG(nbFile)
		listOfJPG(nbFile) = DirectoryEntryName(0)
		If Left(GetFilePart(path), 6) = Left(DirectoryEntryName(0), 6) And FileSize(path) = DirectoryEntrySize(0) And GetFileAttributes(path) = DirectoryEntryAttributes(0) And GetFileDate(path, #PB_Date_Created) = DirectoryEntryDate(0, #PB_Date_Created) And GetFileDate(path, #PB_Date_Modified) = DirectoryEntryDate(0, #PB_Date_Modified) And GetFileDate(path, #PB_Date_Accessed) = DirectoryEntryDate(0, #PB_Date_Accessed)
			posBase = nbFile
		EndIf
	EndIf
Wend

LoadIt(path, 0)

Repeat
	Delay(1)
	If GetForegroundWindow_() = WindowID(1) Or GetForegroundWindow_() = WindowID(0)
		If GetAsyncKeyState_(1) Or GetAsyncKeyState_(#VK_ESCAPE) Or GetAsyncKeyState_(#VK_RETURN)
			Break
		EndIf
		If GetAsyncKeyState_(#VK_LEFT)
			posBase = posBase - 1
			If posBase = -1
				posBase = nbFile
			EndIf
			While LCase(Right(listOfJPG(posBase), 4)) <> ".jpg"
				posBase = posBase - 1
				If posBase = -1
					posBase = nbFile
				EndIf
			Wend
			LoadIt(GetPathPart(path) + listOfJPG(posBase), 1)
		EndIf
		If GetAsyncKeyState_(#VK_RIGHT)
			posBase = posBase + 1
			If posBase = nbFile + 1
				posBase = 1
			EndIf
			While LCase(Right(listOfJPG(posBase), 4)) <> ".jpg"
				posBase = posBase + 1
				If posBase = nbFile + 1
					posBase = 1
				EndIf
			Wend
			LoadIt(GetPathPart(path) + listOfJPG(posBase), 1)
		EndIf
	EndIf
Until WindowEvent() = #PB_Event_CloseWindow

End

Procedure.s GetPhoto(command.s)
	command = Trim(command)
	pos = 1
	While Left(Right(command, pos), 1) <> ":"
		pos = pos + 1
	Wend
	pos = pos + 1
	If Right(command, 1) = Chr(34)
		command = Left(command, Len(command) - 1)
	EndIf
	ProcedureReturn Right(command, pos)
EndProcedure

Procedure LoadIt(path.s, hasToClose)
	If hasToClose : CloseWindow(0) : EndIf
	SetGadgetText(5, "Chargement de " + GetFilePart(path) + " ...")
	LoadImage(1, path, #PB_Image_DisplayFormat)
	
	If ImageWidth(1) > xSize - 50
		ResizeImage(1, xSize - 50, ImageHeight(1) * (xSize - 50) / ImageWidth(1))
	EndIf
	If ImageHeight(1) > ySize - 50
		ResizeImage(1, ImageWidth(1) * (ySize - 50) / ImageHeight(1), ySize - 50)
	EndIf
	
	OpenWindow(0, 0, 0, ImageWidth(1), ImageHeight(1), "IrisPicture", #PB_Window_BorderLess|#PB_Window_ScreenCentered)
	StickyWindow(0, 1)
	StartDrawing(WindowOutput(0))
		DrawImage(ImageID(1), 0, 0)
	StopDrawing()
	SetGadgetText(5, "")
EndProcedure
Et voila le travail !

Si vous remarquez le moindre bug (fort probable ^^), dites-le moi !

Publié : mer. 08/avr./2009 9:45
par Jagang
J'aime bien mais lors de l'installation ça n'a pas associer les .jpg et même quand je fait toujours ouvrir avec ce programme ça ne marche pas, enfin si au moment où je le fait mais dès que je reclique sur un .jpg ça m'ouvre le truc windows

Cordialement
Jagang

PS : Windows XP Pro SP1

Publié : mer. 08/avr./2009 9:48
par KrisJNT
je viens de m'en rendre compte en effet : j'ai oublié de virer une entrée dans le registre...

Pour ceux qui s'y connaissent : dans la boite de dialogue Exécuter e windos, faites regedt32, puis allez dans HKEY_CLASSES_ROOT\jpegfile\shell\Open\command\, et supprimez la commande qui ne s'appelle pas "(Par défaut)", mais l'autre.

Voila !

Publié : mer. 08/avr./2009 9:50
par KrisJNT
autre précision :

Les commandes :
- Echap, ou Entrée, ou Clique gauche : fermer le programme
- Gauche, droite : visualiser les photos du même dossier

Compatible à partir de Windows 2000

Publié : mer. 08/avr./2009 10:00
par Jagang
Dans le registre j'ai :
- (par defaut)
- EditFlag
- FriendlyTypeName
- ImageOptionFlags

Le quel il faut supprimer ?

Publié : mer. 08/avr./2009 16:12
par KrisJNT
euh... je serais tenté de dire tous sauf le "(par défaut)", mais fait une copie de registre avant de faire ce que je te propose, parce que si ça fait tout planter... :)