touches flechées du clavier <- et -> pour voir l'image suivante ou precedente dans le dossier
Code : Tout sélectionner
;***********************************************
;Titre :Pure_view
;Auteur : Dobro
;Date :19/09/2015
; retouché le 03/09/2016
;Heure :16:07:00
;Version Purebasic : PureBasic 5.50 (Windows - x86 )
;Version de l'editeur :EPB V2.62
; Libairies necessaire : Aucune
;***********************************************
; Sample pictures Atari (Pi1,pi2,pi3,pc1,pc2,pc3,Neo here) :
;http://michel.dobro.free.fr/Purebasic/format PC1_pc2_pi1_pi2_pc3.zip
; Sample Pictures Amiga IFF here :
;https://www.filepicker.io/api/file/9TWib84jTZCM82hwZeET
; Sample Pictures PCX here :
; http://michel.dobro.free.fr/Purebasic/format pcx.zip
; and here
; http://samples.libav.org/image-samples/pcx/
;***********************************************
UseJPEGImageDecoder()
UsePNGImageDecoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()
UseJPEG2000ImageDecoder()
; **********************************************
InitMovie()
Enumeration
#Win
#file
EndEnumeration
;}
;{ Gadgets
;Global image=1
Enumeration
#image_load
#image_efface
#image_rotate_left
#image_rotate_right
#Button_load
#Button_gauche
#Button_droit
#Image_gadget
#Scroll_Area
#Text_logo
#image
#image_rot_ref
#key_gauche
#key_droit
#key_return
#key_esc
#key_r
#key_l
#key_plus
#key_moins
#key_g_z
#key_d_z
#key_h_z
#key_b_z
#key_H
#key_V
#Text_rez
EndEnumeration
Structure picture
x.i
y.i
largeur.i
hauteur.i
mem_rez_x.i
mem_rez_y.i
rapport.f
EndStructure
Global picture .picture
;
Structure fenetre
x.i
y.i
largeur.i
Hauteur.i
Couleur.i
EndStructure
Global fenetre.fenetre
;
Structure gadget_image
x.i
y.i
largeur.i
Hauteur.i
dif_Largeur.i
dif_hauteur.i
EndStructure
Global gadget_image.gadget_image
if FileSize(GetHomeDirectory()+"Pure_viewer.inf")>0
OpenFile(#file,GetHomeDirectory()+"Pure_viewer.inf")
fenetre\x.i=Val(ReadString(#file,#PB_Ascii ) )
fenetre\y.i= Val(ReadString(#file,#PB_Ascii ) )
fenetre\largeur.i=Val( ReadString(#file,#PB_Ascii ) )
fenetre\hauteur.i= Val(ReadString(#file,#PB_Ascii ) )
CloseFile(#file)
Else
fenetre\x.i=449
fenetre\y.i=44
fenetre\largeur.i=320
fenetre\hauteur.i=200
Endif
;------------------------------------------------------------------------------------------------------
;****************************************************
;********* Miloo DDS Image Decoder ********
;********* Miloo King 2014.12.01 ********
;********* QQ:714095563 - CHI - ********
;****************************************************
;{- [Constants pour DDS]
#MIP_ImageFlags_DDS = $20534444
#MIP_ImageFormat_DDS_DTX1 = $04156506
#MIP_ImageFormat_DDS_DTX1A = $04A56506
#MIP_ImageFormat_DDS_DTX3 = $04388806
#MIP_ImageFormat_DDS_DTX5 = $04588806
#MIP_ImageFormat_DDS_DTX5NM = $04F88806
#MIP_ImageFormat_DDS_A8 = $02000806
#MIP_ImageFormat_DDS_L8 = $01000806
#MIP_ImageFormat_DDS_A8L8 = $01008806
#MIP_ImageFormat_DDS_R5G6B5 = $00056506
#MIP_ImageFormat_DDS_R8G8B8 = $00088806
#MIP_ImageFormat_DDS_X1R5G5B5 = $00155506
#MIP_ImageFormat_DDS_A1R5G5B5 = $01155506
#MIP_ImageFormat_DDS_A4R4G4B4 = $01444406
#MIP_ImageFormat_DDS_X8R8G8B8 = $00888806
#MIP_ImageFormat_DDS_A8R8G8B8 = $01888806
#MIP_ImageFormat_DDS_A8$ = "DDS:A8"
#MIP_ImageFormat_DDS_L8$ = "DDS:L8"
#MIP_ImageFormat_DDS_A8L8$ = "DDS:A8L8"
#MIP_ImageFormat_DDS_DTX1$ = "DDS:DTX1"
#MIP_ImageFormat_DDS_DTX1A$ = "DDS:DTX1A"
#MIP_ImageFormat_DDS_DTX3$ = "DDS:DTX3"
#MIP_ImageFormat_DDS_DTX5$ = "DDS:DTX5"
#MIP_ImageFormat_DDS_A8R8G8B8$ = "DDS:A8R8G8B8"
#MIP_ImageFormat_DDS_R8G8B8$ = "DDS:R8G8B8"
#MIP_ImageFormat_DDS_A4R4G4B4$ = "DDS:A4R4G4B4"
#MIP_ImageFormat_DDS_A1R5G5B5$ = "DDS:A1R5G5B5"
#MIP_ImageFormat_DDS_X8R8G8B8$ = "DDS:X8R8G8B8"
#MIP_ImageFormat_DDS_R8G8B8$ = "DDS:R8G8B8"
#MIP_ImageFormat_DDS_X1R5G5B5$ = "DDS:X1R5G5B5"
#MIP_ImageFormat_DDS_R5G6B5$ = "DDS:R5G6B5"
;-
;- [Structure]
Structure __MPD_Pixel_BGRA
B.a
G.a
R.a
A.a
EndStructure
Structure __MIP_DDS_HeaderInfo
ImageFlags.l ;DDS??
InfoSize.l ;????,??$7C,???ImgFlags???
Format.l ;DDS???
ImageH.l ;???????
ImageW.l ;???????
PixelSize.l ;????,???????
Depth.l ;?????(?????)
MapCount.l ;MipMap???
Reserved1.l[11] ;?????
StructSize.l ;Pixel?????
PixelFlags.l ;Pixel??,#DDPF_xxxx
FourCC.l ;???????,?DTX1,DTX2
RGBBitCount.l ;RGB?????
RBitMask.l ;?????,??A8R8G8B8?, ?$00ff0000.
GBitMask.l ;?????,??A8R8G8B8?, ?$0000ff00.
BBitMask.l ;?????,??A8R8G8B8?, ?$000000ff.
ABitMask.l ;?????,??A8R8G8B8?, ?$ff000000.
Caps1.l ;???????.
Caps2.l ;?????????
Caps3.l ;??
Caps4.l ;??
Reserved2.l ;??
EndStructure
Structure __MIP_ImageInfo
ImageFlags.l
ImageFlags$
ImageID.l
hImage.l
ImageW.l
ImageH.l
EndStructure
Declare mip_checkimageformat(*memdata, *pimageinfo.__mip_imageinfo)
Declare mip_ddstobmp32_a8r8g8b8(*memdata)
Declare mip_ddstobmp32_x8r8g8b8(*memdata)
Declare mip_ddstobmp32_r8g8b8(*memdata)
Declare mip_ddstobmp32_a4r4g4b4(*memdata)
Declare mip_ddstobmp32_a1r5g5b5(*memdata)
Declare mip_ddstobmp32_x1r5g5b5(*memdata)
Declare mip_ddstobmp32_r5g6b5(*memdata)
Declare mip_ddstobmp32_a8l8(*memdata)
Declare mip_ddstobmp32_a8(*memdata)
Declare mip_ddstobmp32_l8(*memdata)
Declare mip_dtxgetxrgb(*memdata, *pcolor)
Declare mip_dtxgetargb(*memdata, *pcolor)
Declare mip_dtxgetalpha(*memdata, *ppixels.__mpd_pixel_bgra)
Declare mip_ddstobmp32_dtx1(*memdata)
Declare mip_ddstobmp32_dtx1a(*memdata)
Declare mip_ddstobmp32_dtx3(*memdata)
Declare mip_ddstobmp32_dtx5(*memdata)
Declare mip_catchddsimage(imageid, *memdata, *pimageflags.__mip_imageinfo)
Declare mip_loadfiledata (filename$)
Declare mip_loadddsimage(imageid, filename$)
GLobal xt.f,yt.f,xd.f,yd.f
;} ------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Name: Module TinyIFF.pbi
; Description: A tiny module for loading IFF-ILBM and IFF-PBM images.
; Author: flype, flype44(at)gmail(dot)com
; Revision: 1.4 (2015-09-16)
;------------------------------------------------------------------------------
;-declaration Module IFF
DeclareModule TinyIFF
; @TinyIFF::Load()
; Charge une image à partir de l'emplacement disque spécifié.
; #ImageID : Le numéro d'identification de l'image à charger.
; FileName$ : Le chemin et le nom du fichier à charger.
; KeepAspect : Garde l'aspect original de l'image (Tient compte de xAspect/yAspect).
; ResizeMode : Mode de redimensionnement de l'image (avec ou sans interpolation).
Declare Load(ImageID.l, FileName$, KeepAspect.l = #True, ResizeMode.l = #PB_Image_Raw)
; @TinyIFF::Catch()
; Charge une image à partir de l'emplacement mémoire spécifié.
; #ImageID : Le numéro d'identification de l'image à charger.
; *Memory : Adresse de l'emplacement mémoire.
; MemSize.q : Taille de l'emplacement mémoire (en octets).
; KeepAspect : Garde l'aspect original de l'image (Tient compte de xAspect/yAspect).
; ResizeMode : Mode de redimensionnement de l'image (avec ou sans interpolation).
Declare Catch(ImageID.l, *Memory, MemSize.q, KeepAspect.l = #True, ResizeMode.l = #PB_Image_Raw)
; @Parameter KeepAspect
; #True : Garde l'aspect original de l'image (défaut).
; #False : Redimensionne l'image en tenant compte de xAspect/yAspect.
; @Parameter ResizeMode
; #PB_Image_Raw : Redimensionne l'image avec interpolation (défaut).
; #PB_Image_Smooth : Redimensionne l'image sans interpolation.
EndDeclareModule
;------------------------------------------------------------------------------
;{-Gif
; ------------------------------------------
Global Gif
global pos_movie
Global ext.s=""
global pos_movie
; ---------------------------------------
;}
;-Ico
;--------------------------------------------------
Declare LoadImage_Ico(filename.s)
;---------------------------------------------------
;----------------------------------------
;-Pcx
Declare LoadImage_PCX(filename.s)
;------------------------------------------
; +----------------------------+
; | Degas Elite PI1,2,3 LOADER |
; | Pc1,2,3 |
; | Neochrome .NEO |
; | |
; | ATARI ST FORMAT FILE |
; +----------------------------+
; | © Case @ purebasic forums |
; | Domaine public |
; +----------------------------+
declare PI1(file$,x=0,y=0)
;------------------------------------------
;- Declaration Procedures
Declare openwindow_win(a,b,c,d)
Declare zoom(sens)
Declare centre_image()
Declare PivoterImage(ImageID.i, Angle.i)
Declare.i SymetrieH(ImageID.i)
Declare.i SymetrieV(ImageID.i)
Declare scan(path$)
Declare load_image()
Declare aff_taille()
;-variables_init
Global NewList list_Image.s()
Global flag_rez=0 ; determine le plein ecran ou fenetre
Global Flag_rotate=0 ; si c'est une rotation , on n'efface pas l'image
Desk= ExamineDesktops()
Global b_larg=DesktopWidth(0)
Global b_Haut=DesktopHeight(0)
Global nombre
Global Style
;Global x_i=20 , y_i=55 ,larg_i=995,haut_i=690
gadget_image\x.i=20
gadget_image\y.i=55
gadget_image\largeur.i=fenetre\largeur.i-42
gadget_image\hauteur.i=fenetre\hauteur.i-78
gadget_image\dif_largeur.i=(fenetre\largeur.i-gadget_image\largeur.i)
gadget_image\dif_hauteur.i=(fenetre\hauteur.i-gadget_image\hauteur.i)
Global pos_larg_logo=fenetre\largeur.i-50
Global pos_haut_logo=fenetre\hauteur.i- 20
Global index_actuel
Global touche_h,touche_v
Global degres.i
Global Flag_redimension=0
Global file_to_open$=""
;}
Define.l Event
;- Creation image Attente chargement
if gadget_image\largeur.i<320 :gadget_image\largeur.i=320:Endif
If gadget_image\hauteur.i<320:gadget_image\hauteur.i=200:Endif
CreateImage(#image_load,gadget_image\largeur.i,gadget_image\hauteur.i,32,$0)
StartDrawing(ImageOutput(#image_load))
DrawText (50,gadget_image\hauteur.i/3,"Wait.. Loading ....",$00FF00)
StopDrawing()
;- Creation image effacement
CreateImage(#image_efface,gadget_image\largeur.i,gadget_image\hauteur.i,32,$0)
StartDrawing(ImageOutput(#image_efface))
DrawText (50,gadget_image\hauteur.i/3,"",$00FF00)
StopDrawing()
;- Creation image rotate left
CreateImage(#image_rotate_left,gadget_image\largeur.i,gadget_image\hauteur.i,32,$0)
StartDrawing(ImageOutput(#image_rotate_left))
DrawText (50,gadget_image\hauteur.i/3,"Wait.. Left Rotate ....",$00FF00)
StopDrawing()
;-Creation image rotate right
CreateImage(#image_rotate_right,gadget_image\largeur.i,gadget_image\hauteur.i,32,$0)
StartDrawing(ImageOutput(#image_rotate_right))
DrawText (50,gadget_image\hauteur.i/3,"Wait.. Right Rotate ....",$00FF00)
StopDrawing()
if fenetre\largeur.i>=b_larg :fenetre\largeur.i=b_larg-50:fenetre\x.i=10:fenetre\y.i=10:Endif
If fenetre\hauteur.i>=b_haut:fenetre\hauteur.i=b_haut-50:fenetre\x.i=10:fenetre\y.i=10:Endif
;}
OpenWindow_Win(fenetre\x.i,fenetre\y.i,fenetre\largeur.i,fenetre\hauteur.i)
;- ouvrir avec ..
If CountProgramParameters()>0
file_to_open$=ProgramParameter()
file_image$=file_to_open$
path$=file_to_open$
if path$<>""
Scan(path$)
aff_taille()
Centre_image()
Endif
EndIf
;{- Event loop
Repeat
Event = WaitWindowEvent(12)
Select Event
; ///////////////////
Case #PB_Event_GadgetDrop ;
Select EventGadget()
Case #Image_gadget
select EventDropAction()
Case #PB_Drag_Link
;- ** drag/Drop
;; debug EventDropFiles() ; ok le chemin complet de l'image Dropé
if Isimage(#image_rot_ref)
FreeImage(#image_rot_ref)
Endif
path$=EventDropFiles()
file_image$=path$
Scan(file_image$)
if ListSize(list_Image.s())>0
aff_taille()
Centre_image()
if Lcase( GetExtensionPart(list_Image.s()) ) <>"gif" and ext.s<>"avi" and ext.s<>"mpg" and ext.s<>"divx" and ext.s<>"wmv" and IsImage(#image)
copyimage(#image,#image_rot_ref) ; on fait une copie de l'image pour avoir une reference pour la rotation
Endif
Else
MessageRequester("info", "selectionner au moins une image",#PB_MessageRequester_Ok )
Endif
EndSelect
EndSelect
;-Clavier
Case #PB_Event_Menu
Select EventMenu()
Case #key_g_z
;-**touche_4
touche_h=touche_h+10
zoom(2)
Case #key_d_z
;-**touche_6
touche_h=touche_h-10
zoom(2)
Case #key_h_z
;-**touche 8
touche_v=touche_v+10
zoom(2)
Case #key_b_z
;-**touche 2
touche_v=touche_v-10
zoom(2)
Case #key_plus
;-**touche +
if Flag_rez=1
zoom(1)
Else ; fenetre
zoom(1)
Endif
Case #key_moins
;-**touche -
if Flag_rez=1
zoom(0)
Else ; fenetre
zoom(0)
Endif
;-key rot
Case #key_r
;-**touche R
if Isimage(#image_rot_ref)
copyimage(#image_rot_ref,#image)
SetGadgetState(#Image_gadget,ImageId(#image_rotate_right)) ; ne pas toucher
Flag_rotate=1
degres.i=degres.i +90
if degres.i>=360 :degres.i=0
copyimage(#image_rot_ref,#image)
Else
im=PivoterImage(imageId(#image), degres.i)
copyimage(im,#image)
Endif
picture\hauteur.i=ImageHeight(#image)
picture\largeur.i=ImageWidth(#image)
aff_taille()
Centre_image()
Endif
Case #key_l
;-**touche L
if isimage(#image_rot_ref)
copyimage(#image_rot_ref,#image)
SetGadgetState(#Image_gadget,ImageId(#image_rotate_left)) ; ne pas toucher
Flag_rotate=1
degres.i =degres.i -90
if degres.i<=0:degres.i=360
copyimage(#image_rot_ref,#image)
Else
im=PivoterImage(imageId(#image), degres.i)
copyimage(im,#image)
Endif
picture\hauteur.i=ImageHeight(#image)
picture\largeur.i=ImageWidth(#image)
aff_taille()
Centre_image()
Endif
Case #key_H
;-**touche H
if isimage(#image_rot_ref)
copyimage(#image_rot_ref,#image)
Endif
im=SymetrieH(imageId(#image))
copyimage(im,#image)
if isimage(#image_rot_ref)
copyimage(im,#image_rot_ref)
Endif
picture\hauteur.i=ImageHeight(#image_rot_ref)
picture\largeur.i=ImageWidth(#image_rot_ref)
aff_taille()
Centre_image()
Case #key_V
;-**touche V
if isimage(#image_rot_ref)
copyimage(#image_rot_ref,#image)
Endif
im=SymetrieV(imageId(#image))
copyimage(im,#image)
if isimage(#image_rot_ref)
copyimage(im,#image_rot_ref)
Endif
picture\hauteur.i=ImageHeight(#image_rot_ref)
picture\largeur.i=ImageWidth(#image_rot_ref)
aff_taille()
Centre_image()
Case #key_gauche
;-**touche <-
Flag_redimension=0
pos_movie=0
If PreviousElement(list_Image.s()) <>0
Load_image()
aff_taille()
Centre_image()
Else
If LastElement(list_Image.s()) ; on va a la fin
Load_image()
aff_taille()
Centre_image()
Endif
EndIf
delay(100)
Case #key_droit
;-**touche ->
Flag_redimension=0
pos_movie=0
If NextElement(list_Image.s()) <>0
Load_image()
aff_taille()
Centre_image()
Else
If FirstElement(list_Image.s()) ; on va au debut
Load_image()
aff_taille()
Centre_image()
Endif
EndIf
delay(100)
Case #key_return
;-**touche Return
Flag_redimension=0
If nombre>0
if flag_rez=0
flag_rez=1
else
flag_rez=0
Endif
if flag_rez=1
;debug "on" ; FullScreen
SetWindowLongPtr_(WindowID(#Win), #GWL_STYLE, Style & ~#WS_OVERLAPPEDWINDOW) ; laisser en premier
HideGadget(#Button_load,#True) ; cache gadget
HideGadget(#Button_gauche ,#True) ; cache gadget
HideGadget(#Button_Droit ,#True) ; cache gadget
HideGadget(#Text_logo ,#True) ; cache gadget
HideGadget(#text_rez ,#True) ; cache gadget
ResizeWindow(#win,0,0,b_larg,b_haut)
if IsImage(#image)
SetGadgetState(#Image_gadget,ImageId(#image))
ResizeImage(#image,picture\mem_rez_x,picture\mem_rez_y,#PB_Image_Raw ) ; remet la bonne taille d'origine
Endif
PostEvent(#PB_Event_SizeWindow)
Else ; Fenetré
SetWindowLongPtr_(WindowID(#Win), #GWL_STYLE, Style & ~#WS_MAXIMIZE) ; laisser en premier
HideGadget(#Button_load,#False) ; montre gadget
HideGadget(#Button_gauche ,#False) ; montre gadget
HideGadget(#Button_Droit ,#false) ; montre gadget
HideGadget(#Text_logo ,#false) ; montre gadget
HideGadget(#text_rez ,#false) ; montre gadget
ResizeWindow(#win,fenetre\x.i,fenetre\y.i,fenetre\largeur.i,fenetre\hauteur.i)
PostEvent(#PB_Event_SizeWindow)
Endif
Load_image()
aff_taille()
Centre_image()
Endif
Case #key_esc
;-**touche ESC
PostEvent(#PB_Event_CloseWindow)
Endselect
Case #PB_Event_Gadget
;-gadget_boutons
Select EventGadget()
Case #Button_load
;- ** bouton_load
Flag_redimension=0
file_image$=OpenFileRequester("Ouvrir une image","c:\","*.bmp;*.jpg;*.png;*.tiff;*.tga;*.iff;*.gif;*.avi;*.mpg;*.mp4;*.divx;*.pcx;*.dds;*.pi1;*.pi2;*.pi3;*.pc1;*.pc2;*.pc3;*.neo;*.ico",0)
if file_image$<>""
path$=file_image$
Scan(path$)
Load_image()
aff_taille()
Centre_image()
Endif
Case #Button_gauche
;- ** bouton_Gauche
Flag_redimension=0
If PreviousElement(list_Image.s()) <>0
Load_image()
aff_taille()
Centre_image()
Else
If LastElement(list_Image.s()) ; on va a la fin
Load_image()
aff_taille()
Centre_image()
Endif
EndIf
delay(100)
Case #Button_droit
;- ** bouton_Droit
Flag_redimension=0
If NextElement(list_Image.s()) <>0
Load_image()
aff_taille()
Centre_image()
Else
If FirstElement(list_Image.s()) ; on va au debut
Load_image()
aff_taille()
Centre_image()
Endif
EndIf
delay(100)
Case #Image_gadget
Case #Text_logo
EndSelect
; ////////////////////////
Case #PB_Event_CloseWindow
fenetre\x.i=WindowX(#win)
fenetre\y.i=WindowY(#win)
fenetre\largeur.i=WindowWidth(#win)
fenetre\hauteur.i=WindowHeight(#win)
OpenFile(#file,GetHomeDirectory()+"Pure_viewer.inf")
WriteStringN(#file,Str(fenetre\x.i),#PB_Ascii )
WriteStringN(#file,Str(fenetre\y.i),#PB_Ascii )
WriteStringN(#file,Str(fenetre\largeur.i),#PB_Ascii )
WriteStringN(#file,Str(fenetre\hauteur.i),#PB_Ascii )
CloseFile(#file)
CloseWindow(#Win)
Break
Case #PB_Event_SizeWindow
;-change taille fenetre
if flag_rez=0
ResizeGadget(#Image_gadget,#pb_ignore,#pb_ignore,WindowWidth(#win)-gadget_image\dif_largeur,WindowHeight(#win)-gadget_image\dif_hauteur)
;; ResizeGadget(#scroll_area,#pb_ignore,#pb_ignore,WindowWidth(#win)-gadget_image\dif_largeur,WindowHeight(#win)-gadget_image\dif_hauteur)
gadget_image\largeur.i=GadgetWidth(#Image_gadget)
gadget_image\hauteur.i=GadgetHeight(#Image_gadget)
if ListSize(list_Image.s()) ; and Flag_redimension=0
Load_image() ; recharge l'image en cas de zoom par resize fenetre pour eviter l'effet de flou du zoom
Endif
aff_taille()
Centre_image()
pos_larg_logo=WindowWidth(#win)-50
pos_haut_logo=WindowHeight(#win)-20
ResizeGadget(#Text_logo,pos_larg_logo,pos_haut_logo,#pb_ignore,#pb_ignore)
fenetre\x.i=WindowX(#win)
fenetre\y.i=WindowY(#win)
fenetre\largeur.i=WindowWidth(#win)
fenetre\hauteur.i=WindowHeight(#win)
OpenFile(#file,GetHomeDirectory()+"Pure_viewer.inf")
WriteStringN(#file,Str(fenetre\x.i),#PB_Ascii )
WriteStringN(#file,Str(fenetre\y.i),#PB_Ascii )
WriteStringN(#file,Str(fenetre\largeur.i),#PB_Ascii )
WriteStringN(#file,Str(fenetre\hauteur.i),#PB_Ascii )
CloseFile(#file)
if isMovie(1)<>0
pos_movie=MovieStatus(1)
Endif
; if IsMovie(1)
; ResizeMovie(1,0,0,WindowWidth(#win),WindowHeight(#win))
; Endif
Endif
EndSelect
Forever
;
;}
;- les Procedures
Procedure OpenWindow_Win(a,b,c,d)
;-Openwindows
If OpenWindow(#Win,fenetre\x.i,fenetre\y.i,fenetre\largeur.i,fenetre\hauteur.i, "Pure_View", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_SizeGadget )
SetWindowColor(#win, $0)
ButtonGadget(#Button_load, 20, 25, 100, 25, "Load")
ButtonGadget(#Button_gauche, 395-100, 15, 80, 35, "<-")
ButtonGadget(#Button_droit, 495-100, 15, 80, 35, "->")
TextGadget(#Text_rez, 140, 35, 150, 20, "pas d'images")
SetGadgetColor(#Text_rez,#PB_Gadget_BackColor,$0):SetGadgetColor(#Text_rez,#PB_Gadget_FrontColor,rgb(0,255,0))
TextGadget(#Text_logo,WindowWidth(#win)-50, WindowHeight(#win)-20, 60, 20, "By dobro"):SetGadgetColor(#Text_logo,#PB_Gadget_BackColor,$0):SetGadgetColor(#Text_logo,#PB_Gadget_FrontColor,rgb(0,255,0))
ResizeGadget(#Text_logo,pos_larg_logo,pos_haut_logo,#pb_ignore,#pb_ignore)
;; ScrollAreaGadget(#Scroll_Area, 20, 55, 950, 350, 980, 680,#PB_ScrollArea_Center )
ImageGadget(#Image_gadget, 20, 55, 995, 690, 0 )
;; CloseGadgetList()
AddKeyboardShortcut(#win, #PB_Shortcut_Left ,#key_gauche)
AddKeyboardShortcut(#win, #PB_Shortcut_Right , #key_droit )
AddKeyboardShortcut(#win, #PB_Shortcut_Return , #key_return )
AddKeyboardShortcut(#win, #PB_Shortcut_Escape , #key_esc)
AddKeyboardShortcut(#win, #PB_Shortcut_R , #key_r )
AddKeyboardShortcut(#win, #PB_Shortcut_L , #key_l )
AddKeyboardShortcut(#win, #PB_Shortcut_Add , #key_plus )
AddKeyboardShortcut(#win, #PB_Shortcut_Subtract , #key_moins )
AddKeyboardShortcut(#win, #PB_Shortcut_Pad4 , #key_g_z)
AddKeyboardShortcut(#win, #PB_Shortcut_Pad6 , #key_d_z)
AddKeyboardShortcut(#win, #PB_Shortcut_Pad8 , #key_h_z)
AddKeyboardShortcut(#win, #PB_Shortcut_Pad2 , #key_b_z)
AddKeyboardShortcut(#win,#PB_Shortcut_V,#key_V)
AddKeyboardShortcut(#win,#PB_Shortcut_H,#key_H)
Style = GetWindowLongPtr_(WindowID(#Win), #GWL_STYLE)
EnableGadgetDrop(#Image_gadget, #PB_Drop_Files , #PB_Drag_Link)
EnablegadgetDrop(#Button_load, #PB_Drop_Image , #PB_Drag_Link)
WindowBounds(#win, 481, 141, b_larg, b_haut)
EndIf
EndProcedure
Procedure zoom(sens)
;-Zoom
if Isimage(#image)
; if flag_rez=1
xt.f=imageWidth(#image)
yt.f=imageHeight(#image)
; Endif
if flag_rez=1 ; Full
xd.f=(b_larg-xt)/2
yd.f=(b_haut-yt)/2
Else ; fenetre
xd.f=(WindowWidth(#win)-xt)/2
yd.f=(Windowheight(#win)-yt)/2
Endif
select sens
Case 1 ; grossi
ResizeGadget(#Image_gadget,xd.f,yd.f,#pb_ignore, #pb_ignore); deplacement
if flag_rez=0 ; fenetré
xt.f=xt.f+50
yt.f=yt.f+50
Else
xt.f=xt.f+50
yt.f=yt.f+50
Endif
Case 0; diminue
ResizeGadget(#Image_gadget,xd.f,yd.f,#pb_ignore, #pb_ignore); deplacement
if Flag_rez=0 ; fenetré
xt.f=xt.f-50
yt.f=yt.f-50
Else ;Full
xt.f=xt.f-50
yt.f=yt.f-50
Endif
Case 2 ; touche de deplacement
;if flag_rez=1
xd=xd+touche_h
yd=yd+touche_v
ResizeGadget(#Image_gadget,xd.f,yd.f,#pb_ignore, #pb_ignore); deplacement
; Else ; fenetre
;Endif
EndSelect
; tests
if flag_rez=0; fenetré
;test_dob
if xd<=0:xd=0:endif
if yd<=y_i+0:yd=y_i+0:endif
if xt<=0:xt=1:endif
if yt<=0:yt=1:endif
Else; Full
if xd<=0:xd=0:endif
if yd<=y_i+0:yd=y_i+0:endif
if xt<=0:xt=1:endif
if yt<=0:yt=1:endif
Endif
; affichage
Load_image()
ResizeImage(#image,xt,yt,#PB_Image_Raw ) ; zoom
SetGadgetState(#Image_gadget,ImageId(#image)) ; ne pas toucher
Endif
EndProcedure
Procedure Centre_image()
; ***** centre l'image ********************************
if IsMovie(1)
larg_mov=MovieWidth(1)
haut_mov=MovieHeight(1)
larg_gif=MovieWidth(1)
haut_gif=MovieHeight(1)
pos_gif_x_ec=((b_larg-larg_gif)/2)
pos_gif_y_ec=((b_haut-haut_gif)/2)
pos_gif_x_fen=((WindowWidth(#win)-larg_gif)/2)-larg_gif
pos_gif_y_fen=((WindowHeight(#win)-haut_gif)/2)-haut_gif
ResizeGadget(#Image_gadget,0,0,b_larg,b_haut)
ResizeMovie(1,pos_gif_x_ec,pos_gif_y_ec,larg_mov,haut_mov)
Endif
;-centre_image
if IsImage(#image)
x_fenetre=WindowWidth(#win) ; taille de notre fenetre
y_fenetre=WindowHeight(#win)
if flag_rez=0 ; ecran fenetre
;calldebugger
if picture\mem_rez_x>=picture\mem_rez_y ; image horizontale
picture\rapport.f= picture\mem_rez_x/picture\mem_rez_y ; x/y=rapport de proportion (1024/768=1.33333) ;
picture\hauteur.i=gadget_image\hauteur.i
picture\largeur.i=gadget_image\hauteur.i * picture\rapport.f
Resizeimage(#Image,picture\largeur.i,picture\hauteur.i,#PB_Image_Raw )
Endif
if picture\mem_rez_x<=picture\mem_rez_y ; image vertical
picture\rapport.f= picture\mem_rez_x/picture\mem_rez_y ; x/y=rapport de proportion (1024/768=1.33333) ;
picture\hauteur.i=gadget_image\hauteur.i
picture\largeur.i=gadget_image\hauteur.i * picture\rapport.f
Resizeimage(#Image,picture\largeur.i,picture\hauteur.i,#PB_Image_Raw )
Endif
restew=(WindowWidth(#win)-picture\largeur.i)/2
resteh=gadget_image\y
ResizeGadget(#Image_gadget,restew,resteh,picture\largeur.i,picture\hauteur.i) ; recentre l'image
; ****ajout
if Flag_redimension=0
if picture\largeur.i>WindowWidth(#win)
;;;;;ResizeWindow(#win,#pb_ignore,#pb_ignore, picture\largeur.i,#pb_ignore)
ElseIf picture\largeur.i<WindowWidth(#win)
;;;;;ResizeWindow(#win,#pb_ignore,#pb_ignore, picture\largeur.i,#pb_ignore)
Endif
Flag_redimension=1
Endif
; ******
Else ; Full
if picture\mem_rez_x>=picture\mem_rez_y ; image horizontale
picture\rapport.f= picture\mem_rez_y/picture\mem_rez_x ; x/y=rapport de proportion (1024/768=1.33333) ;
picture\largeur.i=b_larg
picture\hauteur.i=b_larg * (picture\rapport.f) ; le 1.2 n'est la que pour legerement adapter l'image au proportion de mon ecran
Resizeimage(#Image,picture\largeur.i,picture\hauteur.i,#PB_Image_Raw )
Endif
if picture\mem_rez_x<=picture\mem_rez_y ; image vertical
picture\rapport.f= picture\mem_rez_x/picture\mem_rez_y ; x/y=rapport de proportion (1024/768=1.33333) ;
picture\hauteur.i=b_haut
picture\largeur.i=b_haut * (picture\rapport.f)
Resizeimage(#Image,picture\largeur.i,picture\hauteur.i,#PB_Image_Raw )
Endif
resteh=(b_haut-ImageHeight(#image))/2
restew=(b_larg-imageWidth(#image))/2
restew=(b_larg-imageWidth(#image))/2
ResizeGadget(#Image_gadget,restew,resteh,picture\largeur.i,picture\hauteur.i) ; recentre l'imageesizeGadget(#Image_gadget,restew,resteh,picture\largeur.i,picture\hauteur.i) ; recentre l'image
Endif
SetGadgetState(#Image_gadget,ImageId(#image)) ; ne pas toucher
Endif
; C'est un Film ou un Gif
if ListSize(list_Image.s()) > 0
ext.s=GetExtensionPart(list_Image.s() )
if ext.s="gif" or ext.s="avi" or
ext.s="mpg" or ext.s="mp4" or ext.s="divx" or
ext.s="wmv"
SetWindowTitle(#win,"Pure_View "+GetFilePart(list_Image.s()))
CreateImage(#image,GadgetWidth(#Image_gadget),GadgetHeight(#Image_gadget))
StartDrawing(ImageOutput(#image))
box(0,0,imageWidth(#image),imageHeight(#image),$0) ; effaceur
StopDrawing()
SetGadgetState(#Image_gadget,ImageId(#image))
if IsImage(#image)
FreeImage(#image)
Endif
if IsMovie(1)
FreeMovie(1)
Endif
;HideGadget(#Image_gadget,1)
if ismovie(1)=0
LoadMovie(1, list_Image.s() )
Endif
larg_mov=MovieWidth(1)
haut_mov=MovieHeight(1)
larg_gif=MovieWidth(1)
haut_gif=MovieHeight(1)
pos_gif_x_ec=((b_larg-larg_gif)/2)
pos_gif_y_ec=((b_haut-haut_gif)/2)
pos_gif_x_fen=((WindowWidth(#win)-larg_gif)/2)-larg_gif
pos_gif_y_fen=((WindowHeight(#win)-haut_gif)/2)-haut_gif
if flag_rez=1; Full Screen
if ext.s<>"gif"
ResizeGadget(#Image_gadget,0,0,b_larg,b_haut)
ResizeMovie(1,0,0,b_larg,b_haut)
Else ; =Gif
ResizeGadget(#Image_gadget,0,0,b_larg,b_haut)
ResizeMovie(1,pos_gif_x_ec,pos_gif_y_ec,larg_mov,haut_mov)
Endif
Else ; Window
if ext.s<>"gif"
ResizeGadget(#Image_gadget,gadget_image\x,Gadget_image\y,WindowWidth(#win),WindowHeight(#win))
ResizeMovie(1,0,0,WindowWidth(#win)-30,WindowHeight(#win)-80)
Else ; =Gif
ResizeGadget(#Image_gadget,20, 55,WindowWidth(#win),WindowHeight(#win)) ; 20;55 pour ne pas effacer les boutons
ResizeMovie(1,pos_gif_x_fen,pos_gif_y_fen,larg_mov,haut_mov)
Endif
Endif
MovieSeek(1,pos_movie)
PlayMovie(1,gadgetID(#Image_gadget))
ProcedureReturn 1
Else
if IsMovie(1)
FreeMovie(1)
Endif
Endif :ext.s=""
if IsMovie(1)
if flag_rez=1 ; full screen
ResizeMovie(1,0,0,b_larg,b_haut)
Else ; window
if GetExtensionPart(list_Image.s() )<>"gif"
ResizeMovie(1,0,0,WindowWidth(#win)-gadget_image\dif_largeur.i,WindowHeight(#win)-gadget_image\dif_hauteur.i)
Endif
Endif
Endif
Endif
; *************************************************
Endprocedure
;- Rotation Procedure
;*****************************************************
Procedure Scan(path$)
;-scan
if Isimage(#image)
Freeimage(#image)
Endif
file_image$=lcase(path$)
ClearList(list_Image.s())
Directory$ =GetPathPart(path$) ; Liste tous les fichiers et les dossiers du répertoire
path$=GetPathPart(Directory$) ; vire le nom de fichier et garde le path
If ExamineDirectory(0, Directory$, "*.*")
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
Type$ = " [Fichier] "
Taille$ = " (Taille : " + DirectoryEntrySize(0) + ")"
Else
Type$ = " [Dossier] "
Taille$ = "" ; Un Dossier n'a pas de taille
EndIf
nam$= LCase( DirectoryEntryName(0))
if nam$ <>"." and nam$ <>".."
ext.s=GetExtensionPart(nam$ )
If (ext.s="jpg" or ext.s="jpeg" or ext.s="png" or
ext.s="bmp" or ext.s="tga" or ext.s="tiff" or
ext.s="iff" or ext.s="gif" or ext.s="avi" or
ext.s="mpg" or ext.s="divx" or ext.s="wmv" or ext.s="mp4" or
ext.s="pcx" or ext.s="dds" or
ext.s="pi1" or ext.s="pi2" or ext.s="pi3" or
ext.s="pc1" or ext.s="pc2" or ext.s="pc3" or
ext.s="neo" or ext.s="ico")
AddElement(list_Image.s())
list_Image.s()=Lcase(path$+DirectoryEntryName(0))
Endif
Endif
Wend
ForEach list_Image.s()
if list_Image.s() =file_image$
index_actuel =ListIndex(list_Image.s())
SelectElement(list_Image.s(),index_actuel)
Break
Endif
Next
FinishDirectory(0)
EndIf
nombre=ListSize(list_Image.s())
Load_image()
;Endif
Endprocedure
Procedure Load_image()
; if ismovie(1)
; StopMovie(1)
; FreeMovie(1)
;
; Endif
Flag_rotate=0
;-Load image
if nombre>0
ext.s=Lcase( GetExtensionPart(list_Image.s()) )
if ext.s="gif" or ext.s="avi" or ext.s="mpg" or ext.s="divx" or ext.s="wmv"
ProcedureReturn ; si c'est un film, on sort d'ici , le chargement et l'affichage se font dans la procedure Centre_image()
Endif
SetGadgetState(#Image_gadget,ImageId(#image_load)) ; ne pas toucher
select ext.s
Case "ico"
LoadImage_Ico(list_Image.s())
copyimage(#image,#image_rot_ref):degres.i=0 ; on fait une copie de l'image pour avoir une reference pour la rotation
Case "iff"
;TinyIFF::Load(list_Image.s()) ; Flype
TinyIFF::Load(#image, list_Image.s(), #True, #PB_Image_Raw):degres.i=0
copyimage(#image,#image_rot_ref) ; on fait une copie de l'image pour avoir une reference pour la rotation
ProcedureReturn
Case "pcx"
LoadImage_PCX(list_Image.s()):degres.i=0
copyimage(#image,#image_rot_ref) ; on fait une copie de l'image pour avoir une reference pour la rotation
ProcedureReturn
Case "dds"
MIP_LoadDDSImage(#image,list_Image.s()):degres.i=0
copyimage(#image,#image_rot_ref) ; on fait une copie de l'image pour avoir une reference pour la rotation
ProcedureReturn
Case "bmp","tiff","tga","jpg","png"
If LoadImage( #image,list_Image.s()):degres.i=0 ; bmp ,tiff,png,tga,jpg
Else
Messagerequester("erreur", "probleme de chargement d'une image")
Endif
Case "pi1","pi2","pi3","pc1","pc2","pc3","neo"
select ext.s
Case "pi1","pc1","neo"
CreateImage(#image,320,200)
picture\mem_rez_x=320
picture\mem_rez_y=200
Case "pi2","pc2"
CreateImage(#image,640,200)
picture\mem_rez_x=320
picture\mem_rez_y=400
Case "pi3","pc3"
CreateImage(#image,640,400)
picture\mem_rez_x=640
picture\mem_rez_y=400
EndSelect
ext.s=""
;http://samples.libav.org/image-samples/atarist/degas/
PI1(list_Image.s(),0,0) :degres.i=0
;;;StopDrawing()
EndSelect
copyimage(#image,#image_rot_ref) ; on fait une copie de l'image pour avoir une reference pour la rotation
Endif
if Isimage(#image_rot_ref)
FreeImage(#image_rot_ref)
copyimage(#image,#image_rot_ref) ; copie l'image pour avoir une reference pour la rotation
Endif
SetGadgetState(#Image_gadget,ImageId(#image_efface)) ; ne pas toucher l'image 8 est une image d'effacement (une gomme )
Endprocedure
Procedure aff_taille()
;-aff_taille
if IsImage(#image)
resolution$="( "+ImageWidth(#image)+" X "+ImageHeight(#image)+" : "+ImageDepth(#image)+"->"+strf(FileSize( list_Image.s())/1000,2)+" Ko"+" )"
SetGadgetText(#Text_rez,resolution$)
picture\mem_rez_x=ImageWidth(#image)
picture\mem_rez_y=ImageHeight(#image)
SetWindowTitle(#win,"Pure_View "+GetFilePart(list_Image.s()))
Endif
Endprocedure
;-************** FORMATS Images *****************************************************
;- Module FLype IFF24 ----------------------------------------------------------------------------------------------------
Module TinyIFF
;------------------------------------------------------------------------------------------------
EnableExplicit
;------------------------------------------------------------------------------------------------
Macro UINT16(a)
((((a)<<8)&$FF00)|(((a)>>8)&$FF))
EndMacro
Macro UINT32(a)
((((a)&$FF)<<24)|(((a)&$FF00)<<8)|(((a)>>8)&$FF00)|(((a)>>24)&$FF))
EndMacro
Macro MAKEID(a, b, c, d)
((a)|((b)<<8)|((c)<<16)|((d)<<24))
EndMacro
;------------------------------------------------------------------------------------------------
Enumeration ChunkIDs
#ID_FORM = MAKEID('F','O','R','M') ; IFF file
#ID_ILBM = MAKEID('I','L','B','M') ; Interleaved Bitmap (Planar)
#ID_PBM = MAKEID('P','B','M',' ') ; Portable Bitmap (Chunky)
#ID_BMHD = MAKEID('B','M','H','D') ; Bitmap Header
#ID_CMAP = MAKEID('C','M','A','P') ; Color Map
#ID_CAMG = MAKEID('C','A','M','G') ; View Modes
#ID_BODY = MAKEID('B','O','D','Y') ; Bitmap Data
EndEnumeration
Enumeration ViewModes
#camgLace = $0004 ; Interlaced
#camgEHB = $0080 ; Extra Half Bright
#camgHAM = $0800 ; Hold And Modify
#camgHiRes = $8000 ; High Resolution
#camgSuperHiRes = $0020 ; Super High Resolution
EndEnumeration
Enumeration BitmapHeaderCmp
#cmpNone ; No compression
#cmpByteRun1 ; ByteRun1 encoding
EndEnumeration
;------------------------------------------------------------------------------------------------
Structure BYTES
b.b[0]
EndStructure
Structure UBYTES
b.a[0]
EndStructure
Structure IFF_RGB8
r.a
g.a
b.a
EndStructure
Structure IFF_BMHD
w.u ; UWORD
h.u ; UWORD
x.w ; WORD
y.w ; WORD
nPlanes.a ; UBYTE
masking.a ; UBYTE
compression.a ; UBYTE
pad.a ; UBYTE
tColor.u ; UWORD
xAspect.a ; UBYTE
yAspect.a ; UBYTE
pageWidth.w ; WORD
pageHeight.w ; WORD
EndStructure
Structure IFF_CMAP
c.IFF_RGB8[0]
EndStructure
Structure IFF_Chunk
id.l
size.l
bytes.UBYTES
EndStructure
Structure IFF_Header
id.l
size.l
name.l
chunk.UBYTES
EndStructure
;------------------------------------------------------------------------------------------------
Procedure UnPackBits(*bh.IFF_BMHD, *packedBits.BYTES, packedSize, rowBytes)
Protected i, j, k, v, unpackedSize, *unpackedBits.BYTES
unpackedSize = 1 + ( *bh\h * rowBytes * *bh\nPlanes )
If unpackedSize
*unpackedBits = AllocateMemory(unpackedSize)
If *unpackedBits
While i < packedSize
v = *packedBits\b[i]
If v >= 0
For j = 0 To v
*unpackedBits\b[k] = *packedBits\b[i + 1 + j]
k + 1
Next
i + j
ElseIf v <> -128
For j = 0 To -v
*unpackedBits\b[k] = *packedBits\b[i + 1]
k + 1
Next
i + 1
EndIf
i + 1
Wend
EndIf
EndIf
ProcedureReturn *unpackedBits
EndProcedure
;------------------------------------------------------------------------------------------------
Procedure Catch_PBM_8(*bh.IFF_BMHD, *bp.UBYTES, Array cmap.l(1))
Protected x, y, i
For y = 0 To *bh\h - 1
For x = 0 To *bh\w - 1
Plot(x, y, cmap(*bp\b[i]))
i + 1
Next
Next
EndProcedure
Procedure Catch_PBM_24(*bh.IFF_BMHD, *bp.UBYTES)
Protected x, y, i
For y = 0 To *bh\h - 1
For x = 0 To *bh\w - 1
Plot(x, y, RGB(*bp\b[i], *bp\b[i+1], *bp\b[i+2]))
i + 3
Next
Next
EndProcedure
;------------------------------------------------------------------------------------------------
Procedure Catch_ILBM_8(*bh.IFF_BMHD, *bp.UBYTES, rowBytes.w, camg.l, cmapSize.l, Array cmap.l(1))
Protected i, x, y, c, p, plane, mbits, mask, hbits, Dim pixels(*bh\w)
If camg & #camgHAM
hbits = 4
If *bh\nPlanes > 6 : hbits + 2 : EndIf
mbits = 8 - hbits
mask = ( 1 << hbits ) - 1
EndIf
If camg & #camgEHB
For i = 0 To ( cmapSize / 3 ) - 1
cmap(i+32) = RGB(Red(cmap(i)) >> 1, Green(cmap(i)) >> 1, Blue(cmap(i)) >> 1)
Next
EndIf
For y = 0 To *bh\h - 1
For plane = 0 To *bh\nPlanes - 1
For x = 0 To *bh\w - 1
If *bp\b[x >> 3] & ( 128 >> ( x % 8 ) )
pixels(x) | ( 1 << plane )
EndIf
Next
*bp + rowBytes
Next