PureViewer
Re: PureViewer
Merci pour le partage.
J'ai regardé les sources, mais je dois dire que cela dépasse mes compétences.
Fonctionne correctement a part un plantage de temps en temps, notamment si je dépose un dossier qui contient quelques photos.
Autrement, au quotidien, j'utilise Honeyview http://www.bandisoft.com/honeyview/fr/
J'ai regardé les sources, mais je dois dire que cela dépasse mes compétences.
Fonctionne correctement a part un plantage de temps en temps, notamment si je dépose un dossier qui contient quelques photos.
Autrement, au quotidien, j'utilise Honeyview http://www.bandisoft.com/honeyview/fr/
■ Win10 64-bit (Intel Celeron CPU N2920 @ 1.86GHz, 4,0GB RAM, Intel HD Graphics) & PB 6.00 LTS
■ Vivre et laisser vivre.
■ PureBasic pour le fun
■ Gérard sur le forum Anglais
■ Mes sites: http://pbcage.free.fr - http://yh.toolbox.free.fr
■ Vivre et laisser vivre.
■ PureBasic pour le fun
■ Gérard sur le forum Anglais
■ Mes sites: http://pbcage.free.fr - http://yh.toolbox.free.fr
Re: PureViewer
Tiens j'avais raté ce fil.
Super Dobro et merci pour le partage.
Beau travail.
Super Dobro et merci pour le partage.
Beau travail.
Re: PureViewer
Rien que pour t'embêter je remarque que si je redimensionne la fenêtre l'image deviens flou.
Voilà juste un petit retour style bêta testeur
Voilà juste un petit retour style bêta testeur
Re: PureViewer
Je viens de tester et je te plein
Trop cheulou comme comportement. J'ai regardé ton code mais j'avoue j'ai pas le courage de chercher le pourquoi du comment, y'a trop de chose.
Trop cheulou comme comportement. J'ai regardé ton code mais j'avoue j'ai pas le courage de chercher le pourquoi du comment, y'a trop de chose.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Re: PureViewer
Essaye de soumettre ton archive quand même (mets un lien direct), j'ai tenté d'expliquer la chose.
I've got a strange bug with Rotate function.
If you're using pureviewer to open a picture, you can see there is no problem to rotate it with "R" key.
There is 4 steps 1.2.3.4 (turn 90% each)
Now try to compile the code And try to open a picture with the windows "Open With" function.
When the picture is loaded in pureviewer, try now to rotate with "R" Key
That's working EXCEPT a step is missing ! 1.3.4 instead of 1.2.3.4
To i think it may have a bug during compilation.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Re: PureViewer
Je n'ai pas encore regarder ton code, mais bravo pour le travail effectué .
http://blendman.blogspot.com/
Forum PB fr : http://www.purebasic.fr/french - Forum PB Eng : http://www.purebasic.fr/english
Forum PB fr : http://www.purebasic.fr/french - Forum PB Eng : http://www.purebasic.fr/english
- Kwai chang caine
- Messages : 6962
- Inscription : sam. 23/sept./2006 18:32
- Localisation : Isere
Re: PureViewer
Moi aussi ça m'est arrivé what milliards de foisFred m'a demander de réduire le code au minimum possible , ce que j'ai fait
et la la connerie m'a sautée a la tronche !!
Sûr de moi, j'allais engueuler Fred (faut bien que quinquin prenne, et comme je suis tout seul dans mon bureau... ) et comme il est patient et gentil, c'est plus facile pour gueuler dessus
Et c'est toujours de sa faute en premier, après tout il avait qu'à pas inventer un programme aussi génial et près de la perfection...
Bref je commence une rédaction de 3 pages avec des exemples reproduisant le bouzin, et paf (pas le chien), je la remet dans ma culotte, je m'aperçois d'une grosse daube au milieu de mon code, mais....
Je l'aurais un jour....je l'aurais !!!
Re: PureViewer
Ton lien de telech n'affiche rien.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Re: PureViewer
bon comme le source avait disparu avec le compte de Spock
revoici la dernière Version de Pure_viewer
un viewer d'images de pleins de formats d'images et meme lecteur de video
l'icone pour le prg
Format pris en compte :
rappel :
[Return] = mode Fenetré/fullScreen
Pavé numérique :
[+] et [-] = zoom sur image (marche maintenant en Fullscreen et fenetré)
[8] et [2] = déplacement vertical dans l'image
[4] et [6] = déplacement horizontal dans l'image
[V] = flip vertical de l'image (marche maintenant en FullScreen et fenetré)
[H] = flip horizontal de l'image (marche maintenant en FullScreen et fenetré)
[L] = Rotation Left (marche maintenant en FullScreen et fenetré)
[R] = Rotation Right (marche maintenant en FullScreen et fenetré)
touches flechées du clavier <- et -> pour voir l'image suivante ou precedente dans le dossier
Le code :
Partie 1/2
revoici la dernière Version de Pure_viewer
un viewer d'images de pleins de formats d'images et meme lecteur de video
l'icone pour le prg
Format pris en compte :
Atari : (Pi1,pi2,pi3,pc1,pc2,pc3,Neo )
Pcx
DDS
TinyIFF (Tiff)
Gif (et Gif Animés)
Ico
jpg/Jpeg
png
bmp
tga
iff
Movie :
avi
mpg
divx
wmv
mp4
rappel :
[Return] = mode Fenetré/fullScreen
Pavé numérique :
[+] et [-] = zoom sur image (marche maintenant en Fullscreen et fenetré)
[8] et [2] = déplacement vertical dans l'image
[4] et [6] = déplacement horizontal dans l'image
[V] = flip vertical de l'image (marche maintenant en FullScreen et fenetré)
[H] = flip horizontal de l'image (marche maintenant en FullScreen et fenetré)
[L] = Rotation Left (marche maintenant en FullScreen et fenetré)
[R] = Rotation Right (marche maintenant en FullScreen et fenetré)
touches flechées du clavier <- et -> pour voir l'image suivante ou precedente dans le dossier
Le code :
Partie 1/2
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
Dernière modification par Zorro le dim. 04/sept./2016 15:18, modifié 2 fois.
Site: http://michel.dobro.free.fr/
Devise :"dis moi ce dont tu as besoin, je t'expliquerai comment t'en passer"
Re: PureViewer
Partie 2/2
Code : Tout sélectionner
For x = 0 To *bh\w - 1
If camg & #camgHAM
p = pixels(x)
Select p >> hbits
Case 0: c = cmap(p & mask)
Case 1: c = RGB(Red(c), Green(c), ( p & mask ) << mbits)
Case 2: c = RGB(( p & mask ) << mbits, Green(c), Blue(c))
Case 3: c = RGB(Red(c), ( p & mask ) << mbits, Blue(c))
EndSelect
Else
c = cmap(pixels(x))
EndIf
Plot(x, y, c)
pixels(x) = 0
Next
c = 0
Next
EndProcedure
Procedure Catch_ILBM_24(*bh.IFF_BMHD, *bp.UBYTES, rowBytes.l)
Protected x, y, w, h, p, plane, p0, p1, p2
Protected Dim m(*bh\w), Dim r(*bh\w), Dim g(*bh\w), Dim b(*bh\w)
w = *bh\w - 1 : h = *bh\h - 1 : p = *bh\nPlanes - 1
For x = 0 To w : m(x) = 128 >> ( x % 8 ) : Next
For y = 0 To h
For plane = 0 To p
p0 = 1 << plane
p1 = 1 << ( plane - 8 )
p2 = 1 << ( plane - 16 )
If plane < 8
For x = 0 To w
If *bp\b[x >> 3] & m(x) : r(x) | p0 : EndIf
Next
ElseIf plane > 15
For x = 0 To w
If *bp\b[x >> 3] & m(x) : b(x) | p2 : EndIf
Next
Else
For x = 0 To w
If *bp\b[x >> 3] & m(x) : g(x) | p1 : EndIf
Next
EndIf
*bp + rowBytes
Next
For x = 0 To w
Plot(x, y, RGB(r(x), g(x), b(x)))
r(x) = 0 : g(x) = 0 : b(x) = 0
Next
Next
EndProcedure
;------------------------------------------------------------------------------------------------
Procedure Catch(ImageID.l, *m.IFF_Header, MemSize.q, KeepAspect.l = #True, ResizeMode.l = #PB_Image_Raw)
Protected i.l, image.i, rowBytes.w, camg.l, cmapSize.l, *imageOutput, *bp, *eof, *bodyUnpacked
Protected *ck.IFF_Chunk, *bh.IFF_BMHD, *cmap.IFF_CMAP, Dim cmap.l(256)
If *m And *m\id = #ID_FORM And ( *m\name = #ID_ILBM Or *m\name = #ID_PBM )
*m\size = UINT32(*m\size)
If *m\size > 0 And *m\size < MemSize
*eof = *m + MemSize
*ck = *m\chunk
While *ck
*ck\size = UINT32(*ck\size)
If *ck\size & 1
*ck\size + 1
EndIf
Select *ck\id
Case #ID_BMHD
*bh = *ck\bytes
*bh\w = UINT16(*bh\w)
*bh\h = UINT16(*bh\h)
rowBytes = ( ( ( *bh\w + 15 ) >> 4 ) << 1 )
Case #ID_CAMG
camg = UINT32(PeekL(*ck\bytes))
;Debug "camg = %" + RSet(Bin(camg, #PB_Long), 32, "0")
Case #ID_CMAP
*cmap = *ck\bytes
cmapSize = *ck\size
For i = 0 To ( cmapSize / 3 ) - 1
cmap(i) = RGB(*cmap\c[i]\r, *cmap\c[i]\g, *cmap\c[i]\b)
Next
Case #ID_BODY
*bp = *ck\bytes
If *bh\compression = #cmpByteRun1
*bodyUnpacked = UnPackBits(*bh, *ck\bytes, *ck\size, rowBytes)
*bp = *bodyUnpacked
EndIf
If *bp And *bh
image = CreateImage(ImageID, *bh\w, *bh\h, 24, RGB(0, 0, 0))
If image
If ImageID = #PB_Any
*imageOutput = ImageOutput(image)
Else
*imageOutput = ImageOutput(ImageID)
EndIf
If StartDrawing(*imageOutput)
Select *m\name
Case #ID_ILBM
If *bh\nPlanes = 24
Catch_ILBM_24(*bh, *bp, rowBytes)
Else
Catch_ILBM_8(*bh, *bp, rowBytes, camg, cmapSize, cmap())
EndIf
Case #ID_PBM
If *bh\nPlanes = 24
Catch_PBM_24(*bh, *bp)
Else
Catch_PBM_8(*bh, *bp, cmap())
EndIf
EndSelect
StopDrawing()
EndIf
EndIf
If KeepAspect = #False
If *bh\xAspect = 0 Or *bh\yAspect = 0
*bh\xAspect = 10 : *bh\yAspect = 11
EndIf
Protected xRes.d = 1.0 + ( *bh\xAspect / *bh\yAspect )
Protected yRes.d = 1.0 + ( *bh\yAspect / *bh\xAspect )
If ImageID = #PB_Any
ResizeImage(image, *bh\w * xRes, *bh\h * yRes, ResizeMode)
Else
ResizeImage(ImageID, *bh\w * xRes, *bh\h * yRes, ResizeMode)
EndIf
EndIf
EndIf
If *bodyUnpacked
FreeMemory(*bodyUnpacked)
EndIf
Break
EndSelect
If *ck < *eof
*ck + 8 + *ck\size
Else
*ck = 0
EndIf
Wend
EndIf
EndIf
ProcedureReturn image
EndProcedure
Procedure Load(ImageID.l, FileName$, KeepAspect.l = #True, ResizeMode.l = #PB_Image_Raw)
Protected image.i, file.i, fileSize.q, *fileData
file = ReadFile(#PB_Any, FileName$)
If file
fileSize = Lof(file)
If fileSize > 0
*fileData = AllocateMemory(fileSize, #PB_Memory_NoClear)
If *fileData
If ReadData(file, *fileData, fileSize) > 0
image = Catch(ImageID, *fileData, fileSize, KeepAspect, ResizeMode)
EndIf
FreeMemory(*fileData)
EndIf
EndIf
CloseFile(file)
EndIf
ProcedureReturn image
EndProcedure
EndModule
;-------------------------------------------------------------------------------------------------------------------------------
;-Format Ico
Procedure LoadImage_Ico(Filename.s)
LoadImage(#image, Filename.s)
Img = LoadImage (#PB_Any, Filename.s)
CreateImage (#image, ImageWidth(Img), ImageHeight(Img), 32,#PB_Image_Transparent)
;
StartDrawing (ImageOutput(#image))
DrawingMode (#PB_2DDrawing_AllChannels )
DrawImage (ImageID(Img), 0, 0)
StopDrawing ()
FreeImage(Img)
EndProcedure
;-Format Pcx
Procedure.i LoadImage_PCX(filename.s)
;PCX FILE LOADER (Réalisation par KoakDesign) |
; +------------------------------------------------------+
; | COPYRIGHT(C)2007-2008, ALL RIGHT RESERVED KOAKDESIGN
;http://pbfrance.com/php/form_source_viewer.php?num=3
Structure pcx_fileheader
manufactor.b
version.b
encoding.b
bitsperpixel.b
xmin.w
ymin.w
xmax.w
ymax.w
hdpi.w
vdpi.w
colormap.b[48]
reserved.b
bitplan.b
bytesperline.w
palette_info.w
filler.b[58]
EndStructure
Structure pcx_filecolor
r.a
g.a
b.a
EndStructure
; ROUTINE DE CHARGEMENT DES FORMATS PCX.
Protected i.l
Protected j.l
Protected k.l
Protected file.l
Protected bdata.a
Protected llenx.l
Protected lleny.l
Protected ltemp.l
Protected image.l
Protected lcount.l
Protected lfllen.l
Protected lOffset.l
Protected Dim Raw.a(0)
Protected Dim color.pcx_filecolor(255)
Protected header.pcx_fileheader
file = ReadFile(#PB_Any, filename)
If file
lfllen = Lof(file)
ReadData(file, header, SizeOf(header))
k = lfllen - SizeOf(header) - 768
If k <= 0 Or k => lfllen
CloseFile(file)
ProcedureReturn #False
EndIf
ReDim Raw(k)
ReadData(file, Raw(), k)
FileSeek(file, lfllen - 768)
ReadData(file, color(), 768)
CloseFile(file)
If ((header\manufactor = 10) Or (header\version = 5) Or (header\encoding = 1) Or (header\bitplan = 1) Or (header\bitsperpixel = 8))
i = 0
llenx = header\bytesperline
lleny = header\ymax - header\ymin + 1
ltemp = lleny
;
; REDIMENTIONNEMENT DE LA FENÊTRE.
;
;;ResizeWindow(0, #PB_Ignore, #PB_Ignore, llenx, lleny)
;
; REDIMENTIONNEMENT DE LA FENÊTRE.
;
CreateImage(#image, llenx, lleny)
If #image
If StartDrawing(ImageOutput(#image))
While ltemp
lOffset = 0
ltemp - 1
j = (lleny - ltemp) * llenx
While (lOffset < llenx)
bdata = Raw(i)
i + 1
If (bdata & 192) = 192
lcount = bdata & 63
lOffset + lcount
bdata = Raw(i)
i + 1
While lcount
lcount - 1
Plot(j % llenx, (j / llenx) - 1, RGB(color(bdata)\r, color(bdata)\g, color(bdata)\b))
j + 1
Wend
Else
Plot(j % llenx, (j / llenx) - 1, RGB(color(bdata)\r, color(bdata)\g, color(bdata)\b))
lOffset + 1
j + 1
EndIf
Wend
Wend
StopDrawing()
ProcedureReturn #image
EndIf
EndIf
EndIf
EndIf
;
EndProcedure
;-format DDS
;****************************************************
;********* Miloo DDS Image Decoder ********
;********* Miloo King 2014.12.01 ********
;********* QQ:714095563 - CHI - ********
;****************************************************
Procedure MIP_CheckImageFormat(*MemData, *pImageInfo.__MIP_ImageInfo)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
With *pDDSHeader
If \ImageFlags <> #MIP_ImageFlags_DDS
ProcedureReturn #False
EndIf
Select \PixelFlags
Case $00002
If \RGBBitCount=$08
Result=#MIP_ImageFormat_DDS_A8
Result$ = #MIP_ImageFormat_DDS_A8$
EndIf
Case $20000
If \RGBBitCount=$08
Result=#MIP_ImageFormat_DDS_L8
Result$ = #MIP_ImageFormat_DDS_L8$
EndIf
Case $20001
If \RGBBitCount=$10
Result=#MIP_ImageFormat_DDS_A8L8
Result$ = #MIP_ImageFormat_DDS_A8L8$
EndIf
Case $00004 ;DTX??
Select \FourCC
Case $31545844
Result = #MIP_ImageFormat_DDS_DTX1
Result$ = #MIP_ImageFormat_DDS_DTX1$
; DTX1 ??A???A??
Pos = *pDDSHeader\InfoSize+4
For Y = 0 To *pDDSHeader\ImageH/4-1
For X = 0 To *pDDSHeader\ImageW/4-1
Color = PeekL(*MemData+Pos) : Pos+8
If Color = $010000
Result = #MIP_ImageFormat_DDS_DTX1A
Result$ = #MIP_ImageFormat_DDS_DTX1A$
Break 2
EndIf
Next
Next
Case $33545844
Result = #MIP_ImageFormat_DDS_DTX3
Result$ = #MIP_ImageFormat_DDS_DTX3$
Case $35545844
Result = #MIP_ImageFormat_DDS_DTX5
Result$ = #MIP_ImageFormat_DDS_DTX5$
EndSelect
Case $00041 :
Select \RGBBitCount
Case $20
Result=#MIP_ImageFormat_DDS_A8R8G8B8
Result$ = #MIP_ImageFormat_DDS_A8R8G8B8$
Case $18
Result=#MIP_ImageFormat_DDS_R8G8B8
Result$ = #MIP_ImageFormat_DDS_R8G8B8$
Case $10
If \GBitMask=$F0
Result=#MIP_ImageFormat_DDS_A4R4G4B4
Result$ = #MIP_ImageFormat_DDS_A4R4G4B4$
Else
Result=#MIP_ImageFormat_DDS_A1R5G5B5
Result$ = #MIP_ImageFormat_DDS_A1R5G5B5$
EndIf
EndSelect
Case $00040 :
Select \RGBBitCount
Case $20
Result=#MIP_ImageFormat_DDS_X8R8G8B8
Result$ = #MIP_ImageFormat_DDS_X8R8G8B8$
Case $18
Result=#MIP_ImageFormat_DDS_R8G8B8
Result$ = #MIP_ImageFormat_DDS_R8G8B8$
Case $10
If \GBitMask=$3E0
Result=#MIP_ImageFormat_DDS_X1R5G5B5
Result$ = #MIP_ImageFormat_DDS_X1R5G5B5$
Else
Result=#MIP_ImageFormat_DDS_R5G6B5
Result$ = #MIP_ImageFormat_DDS_R5G6B5$
EndIf
EndSelect
EndSelect
EndWith
*pImageInfo\ImageFlags = Result
*pImageInfo\ImageFlags$ = Result$
*pImageInfo\ImageW = *pDDSHeader\ImageW
*pImageInfo\ImageH = *pDDSHeader\ImageH
ProcedureReturn Result
EndProcedure
Procedure MIP_DDStoBMP32_A8R8G8B8(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32 = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW * 4
For R = *pDDSHeader\ImageH-1 To 0 Step -1
*pDDS32 = *MemData + $80 + RowBytes * R
CopyMemory_(*pBMP32, *pDDS32, RowBytes) : *pBMP32+RowBytes
Next
EndProcedure
Procedure MIP_DDStoBMP32_X8R8G8B8(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32 = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW * 4
For R = *pDDSHeader\ImageH-1 To 0 Step -1
*pDDS32 = *MemData+$80 + RowBytes * R
CopyMemory_(*pBMP32, *pDDS32, RowBytes) : *pBMP32+RowBytes
Next
DrawingMode(#PB_2DDrawing_AlphaChannel)
Box(0, 0, *pDDSHeader\ImageW, *pDDSHeader\ImageH, $FF000000)
EndProcedure
Procedure MIP_DDStoBMP32_R8G8B8(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32 = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW * 3
For R = *pDDSHeader\ImageH-1 To 0 Step -1
*pDDS24 = *MemData+$80 + RowBytes * R
For C = 1 To *pDDSHeader\ImageW
CopyMemory_(*pBMP32, *pDDS24, 3) : *pBMP32+4 : *pDDS24+3
Next
Next
EndProcedure
Procedure MIP_DDStoBMP32_A4R4G4B4(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32.__MPD_Pixel_BGRA = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW * 2
For R = *pDDSHeader\ImageH-1 To 0 Step -1
*pDDS16.Word = *MemData + $80 + RowBytes * R
For C = 1 To *pDDSHeader\ImageW
*pBMP32\B = (*pDDS16\w>>00 & $0F) | (*pDDS16\w<<04 & $F0)
*pBMP32\G = (*pDDS16\w>>04 & $0F) | (*pDDS16\w<<00 & $F0)
*pBMP32\R = (*pDDS16\w>>08 & $0F) | (*pDDS16\w>>04 & $F0)
*pBMP32\A = (*pDDS16\w>>12 & $0F) | (*pDDS16\w>>08 & $F0)
*pBMP32+4 : *pDDS16+2
Next
Next
EndProcedure
Procedure MIP_DDStoBMP32_A1R5G5B5(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32.__MPD_Pixel_BGRA = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW * 2
For R = *pDDSHeader\ImageH-1 To 0 Step -1
*pDDS16.word = *MemData+$80 + RowBytes * R
For C = 1 To *pDDSHeader\ImageW
*pBMP32\B = (*pDDS16\w>>02 & $07) | (*pDDS16\w<<03 & $F8)
*pBMP32\G = (*pDDS16\w>>07 & $07) | (*pDDS16\w>>02 & $F8)
*pBMP32\R = (*pDDS16\w>>12 & $07) | (*pDDS16\w>>07 & $F8)
*pBMP32\A = (*pDDS16\w>>15 & $01) * $FF
*pBMP32+4 : *pDDS16+2
Next
Next
EndProcedure
Procedure MIP_DDStoBMP32_X1R5G5B5(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32.__MPD_Pixel_BGRA = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW * 2
For R = *pDDSHeader\ImageH-1 To 0 Step -1
*pDDS16.word = *MemData+$80 + RowBytes * R
For C = 1 To *pDDSHeader\ImageW
Color = PeekW(*pDDS16)
*pBMP32\B = (*pDDS16\w>>02 & $07) | (*pDDS16\w<<03 & $F8)
*pBMP32\G = (*pDDS16\w>>07 & $07) | (*pDDS16\w>>02 & $F8)
*pBMP32\R = (*pDDS16\w>>12 & $07) | (*pDDS16\w>>07 & $F8)
*pBMP32+4 : *pDDS16+2
Next
Next
EndProcedure
Procedure MIP_DDStoBMP32_R5G6B5(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32.__MPD_Pixel_BGRA = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW * 2
For R = *pDDSHeader\ImageH-1 To 0 Step -1
*pDDS16.word = *MemData+$80 + RowBytes * R
For C = 1 To *pDDSHeader\ImageW
*pBMP32\B = (*pDDS16\w>>02 & $07) | (*pDDS16\w<<03 & $F8)
*pBMP32\G = (*pDDS16\w>>09 & $03) | (*pDDS16\w>>03 & $FC)
*pBMP32\R = (*pDDS16\w>>13 & $07) | (*pDDS16\w>>08 & $F8)
*pBMP32+4 : *pDDS16+2
Next
Next
EndProcedure
Procedure MIP_DDStoBMP32_A8L8(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32.__MPD_Pixel_BGRA = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW * 2
For R = *pDDSHeader\ImageH-1 To 0 Step -1
*pDDS16.byte = *MemData+$80 + RowBytes * R
For C = 1 To *pDDSHeader\ImageW
*pBMP32\B = *pDDS16\b
*pBMP32\G = *pDDS16\b
*pBMP32\R = *pDDS16\b : *pDDS16+1
*pBMP32\A = *pDDS16\b : *pDDS16+1 : *pBMP32+4
Next
Next
EndProcedure
Procedure MIP_DDStoBMP32_A8(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32.__MPD_Pixel_BGRA = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0, 0, *pDDSHeader\ImageW, *pDDSHeader\ImageH, $FFFFFFFF)
For R = *pDDSHeader\ImageH-1 To 0 Step -1
*pDDS08.byte = *MemData+$80 + RowBytes * R
For C = 1 To *pDDSHeader\ImageW
*pBMP32\A = *pDDS08\b : *pDDS08+1 : *pBMP32+4
Next
Next
EndProcedure
Procedure MIP_DDStoBMP32_L8(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32.__MPD_Pixel_BGRA = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0, 0, *pDDSHeader\ImageW, *pDDSHeader\ImageH, $FFFFFFFF)
For R = *pDDSHeader\ImageH-1 To 0 Step -1
*pDDS08.byte = *MemData+$80 + RowBytes * R
For C = 1 To *pDDSHeader\ImageW
*pBMP32\A = *pDDS08\b :
*pBMP32\A = *pDDS08\b :
*pBMP32\A = *pDDS08\b :
*pBMP32\A = *pDDS08\b : *pDDS08+1 : *pBMP32+4
Next
Next
EndProcedure
Procedure MIP_DTXGetXRGB(*MemData, *pColor)
; ?????
Color0 = PeekW(*MemData+0) & $FFFF
Color1 = PeekW(*MemData+2) & $FFFF
BitVal = PeekL(*MemData+4)
; ??????
*pPixel0.__MPD_Pixel_BGRA = *pColor+00
*pPixel0\B = (Color0>>00 & $1F)*$FF/$1F
*pPixel0\G = (Color0>>05 & $3F)*$FF/$3F
*pPixel0\R = (Color0>>11 & $1F)*$FF/$1F
*pPixel1.__MPD_Pixel_BGRA = *pColor+04
*pPixel1\B = (Color1>>00 & $1F)*$FF/$1F
*pPixel1\G = (Color1>>05 & $3F)*$FF/$3F
*pPixel1\R = (Color1>>11 & $1F)*$FF/$1F
*pPixel2.__MPD_Pixel_BGRA = *pColor+08
*pPixel2\B = (*pPixel0\B*2/3 + *pPixel1\B/3) & $FF
*pPixel2\G = (*pPixel0\G*2/3 + *pPixel1\G/3) & $FF
*pPixel2\R = (*pPixel0\R*2/3 + *pPixel1\R/3) & $FF
*pPixel3.__MPD_Pixel_BGRA = *pColor+12
*pPixel3\B = (*pPixel1\B*2/3 + *pPixel0\B/3) & $FF
*pPixel3\G = (*pPixel1\G*2/3 + *pPixel0\G/3) & $FF
*pPixel3\R = (*pPixel1\R*2/3 + *pPixel0\R/3) & $FF
ProcedureReturn BitVal
EndProcedure
Procedure MIP_DTXGetARGB(*MemData, *pColor)
; ?????
Color0 = PeekW(*MemData+0) & $FFFF
Color1 = PeekW(*MemData+2) & $FFFF
BitVal = PeekL(*MemData+4)
; ??????
*pPixel0.__MPD_Pixel_BGRA = *pColor+00
*pPixel0\B = (Color0>>00 & $1F)*$FF/$1F
*pPixel0\G = (Color0>>05 & $3F)*$FF/$3F
*pPixel0\R = (Color0>>11 & $1F)*$FF/$1F
*pPixel0\A = $FF
*pPixel1.__MPD_Pixel_BGRA = *pColor+04
*pPixel1\B = (Color1>>00 & $1F)*$FF/$1F
*pPixel1\G = (Color1>>05 & $3F)*$FF/$3F
*pPixel1\R = (Color1>>11 & $1F)*$FF/$1F
*pPixel1\A = $FF
If Color0 > Color1
*pPixel2.__MPD_Pixel_BGRA = *pColor+08
*pPixel2\B = (*pPixel0\B*2/3 + *pPixel1\B/3) & $FF
*pPixel2\G = (*pPixel0\G*2/3 + *pPixel1\G/3) & $FF
*pPixel2\R = (*pPixel0\R*2/3 + *pPixel1\R/3) & $FF
*pPixel2\A = $FF
*pPixel3.__MPD_Pixel_BGRA = *pColor+12
*pPixel3\B = (*pPixel1\B*2/3 + *pPixel0\B/3) & $FF
*pPixel3\G = (*pPixel1\G*2/3 + *pPixel0\G/3) & $FF
*pPixel3\R = (*pPixel1\R*2/3 + *pPixel0\R/3) & $FF
*pPixel3\A = $FF
Else
*pPixel2.__MPD_Pixel_BGRA = *pColor+08
*pPixel2\B = ((*pPixel0\B + *pPixel1\B)/2) & $FF
*pPixel2\G = ((*pPixel0\G + *pPixel1\G)/2) & $FF
*pPixel2\R = ((*pPixel0\R + *pPixel1\R)/2) & $FF
*pPixel2\A = $FF
*pPixel3.__MPD_Pixel_BGRA = *pColor+12
*pPixel3\B = 0
*pPixel3\G = 0
*pPixel3\R = 0
*pPixel3\A = 0
EndIf
ProcedureReturn BitVal
EndProcedure
Procedure MIP_DTXGetAlpha(*MemData, *pPixels.__MPD_Pixel_BGRA)
; ?????
Alpha1 = PeekB(*MemData+Pos) & $FF : Pos+1
Alpha2 = PeekB(*MemData+Pos) & $FF : Pos+1
BitVal = PeekQ(*MemData+Pos) & $FFFFFFFFFFFF : Pos+6
*pAlpha.ascii = @Alpha.q
If Alpha1 > Alpha2
*pAlpha\a = Alpha1 : *pAlpha+1
*pAlpha\a = Alpha2 : *pAlpha+1
*pAlpha\a = (6*Alpha1+1*Alpha2+3)/7 & $FF : *pAlpha+1
*pAlpha\a = (5*Alpha1+2*Alpha2+3)/7 & $FF : *pAlpha+1
*pAlpha\a = (4*Alpha1+3*Alpha2+3)/7 & $FF : *pAlpha+1
*pAlpha\a = (3*Alpha1+4*Alpha2+3)/7 & $FF : *pAlpha+1
*pAlpha\a = (2*Alpha1+5*Alpha2+3)/7 & $FF : *pAlpha+1
*pAlpha\a = (1*Alpha1+6*Alpha2+3)/7 & $FF : *pAlpha+1
Else
*pAlpha\a = Alpha1 : *pAlpha+1
*pAlpha\a = Alpha2 : *pAlpha+1
*pAlpha\a = (4*Alpha1+1*Alpha2+2)/5 & $FF : *pAlpha+1
*pAlpha\a = (3*Alpha1+2*Alpha2+2)/5 & $FF : *pAlpha+1
*pAlpha\a = (2*Alpha1+3*Alpha2+2)/5 & $FF : *pAlpha+1
*pAlpha\a = (1*Alpha1+4*Alpha2+2)/5 & $FF : *pAlpha+1
*pAlpha\a = $00 : *pAlpha+1
*pAlpha\a = $FF : *pAlpha+1
EndIf
For k = 0 To 15
*pAlpha = @Alpha + (BitVal >> (k*3)) & %111
*pPixels\A = *pAlpha\a : *pPixels+4
Next
EndProcedure
Procedure MIP_DDStoBMP32_DTX1(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32 = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW * 4
*pColor = AllocateMemory(4*4)
Pos = $80
For Y = *pDDSHeader\ImageH/4-1 To 0 Step -1
For X = 0 To *pDDSHeader\ImageW/4-1
BitVal = MIP_DTXGetXRGB(*MemData+Pos, *pColor) : Pos+8 : K = 0
For Row = 3 To 0 Step -1
For Col = 0 To 3
Index = (BitVal >> K) & %11 : K+2
*pDTXPixel.__MPD_Pixel_BGRA = *pColor + Index * 4
*pBMPPixel.__MPD_Pixel_BGRA = *pBMP32+(Y*4+Row) * RowBytes + (X*4+Col)*4
*pBMPPixel\R = *pDTXPixel\R
*pBMPPixel\G = *pDTXPixel\G
*pBMPPixel\B = *pDTXPixel\B
Next
Next
Next
Next
FreeMemory(*pColor)
EndProcedure
Procedure MIP_DDStoBMP32_DTX1A(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32 = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW * 4
*pColor = AllocateMemory(4*4)
Pos = $80
For Y = *pDDSHeader\ImageH/4-1 To 0 Step -1
For X = 0 To *pDDSHeader\ImageW/4-1
BitVal = MIP_DTXGetARGB(*MemData+Pos, *pColor) : Pos+8 : K = 0
For Row = 3 To 0 Step -1
For Col = 0 To 3
Index=(BitVal >> K) & %11 : K+2
*pDTXPixel.__MPD_Pixel_BGRA = *pColor + Index * 4
*pBMPPixel.__MPD_Pixel_BGRA = *pBMP32+(Y*4+Row) * RowBytes + (X*4+Col)*4
*pBMPPixel\R = *pDTXPixel\R
*pBMPPixel\G = *pDTXPixel\G
*pBMPPixel\B = *pDTXPixel\B
*pBMPPixel\A = *pDTXPixel\A
Next
Next
Next
Next
FreeMemory(*pColor)
EndProcedure
Procedure MIP_DDStoBMP32_DTX3(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32 = DrawingBuffer()
RowBytes = *pDDSHeader\ImageW * 4
*pColor = AllocateMemory(4*4)
Pos = $80
For Y = *pDDSHeader\ImageH/4-1 To 0 Step -1
For X = 0 To *pDDSHeader\ImageW/4-1
Alpha = PeekQ(*MemData+Pos) : Pos+8
BitVal = MIP_DTXGetXRGB(*MemData+Pos, *pColor) : Pos+8 : K = 0
For Row = 3 To 0 Step -1
For Col = 0 To 3
Index=(BitVal >> K) & %11
*pDTXPixel.__MPD_Pixel_BGRA = *pColor + Index * 4
*pBMPPixel.__MPD_Pixel_BGRA = *pBMP32+(Y*4+Row) * RowBytes + (X*4+Col)*4
A = Alpha >> (K*2) & %1111
*pBMPPixel\R = *pDTXPixel\R
*pBMPPixel\G = *pDTXPixel\G
*pBMPPixel\B = *pDTXPixel\B
*pBMPPixel\A = A | A << 4
K+2
Next
Next
Next
Next
FreeMemory(*pColor)
EndProcedure
Procedure MIP_DDStoBMP32_DTX5(*MemData)
*pDDSHeader.__MIP_DDS_HeaderInfo = *MemData
*pBMP32 = DrawingBuffer()
*pColor = AllocateMemory(4*4*4)
RowBytes = *pDDSHeader\ImageW * 4
Pos = $80
For Y = *pDDSHeader\ImageH/4-1 To 0 Step -1
For X = 0 To *pDDSHeader\ImageW/4-1
MIP_DTXGetAlpha(*MemData+Pos, *pColor) : Pos+8
BitVal = MIP_DTXGetXRGB(*MemData+Pos, *pColor) : Pos+8 : K = 0
For Row = 3 To 0 Step -1
For Col = 0 To 3
Index=(BitVal >> K) & %11
*pDTXPixel.__MPD_Pixel_BGRA = *pColor + Index * 4
*pBMPPixel.__MPD_Pixel_BGRA = *pBMP32+(Y*4+Row) * RowBytes + (X*4+Col)*4
A = Alpha >> (K*2) & %1111
*pBMPPixel\R = *pDTXPixel\R
*pBMPPixel\G = *pDTXPixel\G
*pBMPPixel\B = *pDTXPixel\B
*pBMPPixel\A = *pDTXPixel\A
K+2
Next
Next
Next
Next
FreeMemory(*pColor)
EndProcedure
Procedure MIP_CatchDDSImage(ImageID, *MemData, *pImageFlags.__MIP_ImageInfo)
;-MIP_CatchDDSImage
If *pImageFlags\ImageFlags
If ImageID = #PB_Any
ImageID = CreateImage(#PB_Any, *pImageFlags\ImageW, *pImageFlags\ImageH, 32)
Result = ImageID
Else
hImage = CreateImage(ImageID, *pImageFlags\ImageW, *pImageFlags\ImageH, 32)
Result = hImage
EndIf
If StartDrawing(ImageOutput(ImageID))
Select *pImageFlags\ImageFlags
Case #MIP_ImageFormat_DDS_DTX1 : MIP_DDStoBMP32_DTX1 (*MemData)
Case #MIP_ImageFormat_DDS_DTX1A : MIP_DDStoBMP32_DTX1A (*MemData)
Case #MIP_ImageFormat_DDS_DTX3 : MIP_DDStoBMP32_DTX3 (*MemData)
Case #MIP_ImageFormat_DDS_DTX5 : MIP_DDStoBMP32_DTX5 (*MemData)
Case #MIP_ImageFormat_DDS_DTX5NM
Case #MIP_ImageFormat_DDS_A8 : MIP_DDStoBMP32_A8 (*MemData)
Case #MIP_ImageFormat_DDS_L8 : MIP_DDStoBMP32_L8 (*MemData)
Case #MIP_ImageFormat_DDS_A8L8 : MIP_DDStoBMP32_A8L8 (*MemData)
Case #MIP_ImageFormat_DDS_R5G6B5 : MIP_DDStoBMP32_R5G6B5 (*MemData)
Case #MIP_ImageFormat_DDS_R8G8B8 : MIP_DDStoBMP32_R8G8B8 (*MemData)
Case #MIP_ImageFormat_DDS_X1R5G5B5 : MIP_DDStoBMP32_X1R5G5B5(*MemData)
Case #MIP_ImageFormat_DDS_A1R5G5B5 : MIP_DDStoBMP32_A1R5G5B5(*MemData)
Case #MIP_ImageFormat_DDS_A4R4G4B4 : MIP_DDStoBMP32_A4R4G4B4(*MemData)
Case #MIP_ImageFormat_DDS_X8R8G8B8 : MIP_DDStoBMP32_X8R8G8B8(*MemData)
Case #MIP_ImageFormat_DDS_A8R8G8B8 : MIP_DDStoBMP32_A8R8G8B8(*MemData)
EndSelect
StopDrawing()
EndIf
EndIf
ProcedureReturn Result
EndProcedure
Procedure MIP_LoadFileData(FileName$)
;-MIP_LoadFileData
FileID = ReadFile(#PB_Any, FileName$)
If FileID
DataSize = Lof(FileID)
*MemImage = AllocateMemory(DataSize)
ReadData(FileID, *MemImage, DataSize)
CloseFile(FileID)
EndIf
ProcedureReturn *MemImage
EndProcedure
Procedure MIP_LoadDDSImage(ImageID, FileName$)
;-MIP_LoadDDSImage
*MemImage = MIP_LoadFileData(FileName$)
If *MemImage
If MIP_CheckImageFormat(*MemImage, @ImageFlags.__MIP_ImageInfo)
Result = MIP_CatchDDSImage(ImageID, *MemImage, @ImageFlags)
EndIf
FreeMemory(*MemImage)
EndIf
ProcedureReturn Result
EndProcedure
;------------------------------------------------------------------
;-format Pi1,Pi2,Pi3,pc1,pc2,pc3,Neo
Procedure PI1(file$,x=0,y=0)
protected flag,bl,vl,rl,img_w,img_h,ZZ,ligne,off,S,i,b,nx,ny,mul,a,c
If FileSize(file$)>0
*mem=AllocateMemory(2) ; aloue 2 octets en memoire comme tampon lors de la lecture du fichier en 'BIG ENDIAN'
*sourcebuffer=AllocateMemory(FileSize(file$)) ; cree le tampon memoire pour charger les données
READ_BYTE=0 ; position dans le buffer source
Dim plane(4) ; stocker les bitplans
Dim RVB(15) ; palette de couleur
rd=OpenFile(#PB_Any,file$) ; ouverture fichier
If rd ; Succes !!
ReadData(rd,*sourcebuffer,FileSize(file$))
CloseFile(rd)
EndIf
PokeB(*mem+1,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1; lecture de l'octet de poids faible
PokeB(*mem,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1 ; lecture de l'octet de poids fort
If (LCase(GetExtensionPart(file$)))="neo" ; neochrome
ALWAY0=PeekW(*mem) &$FFFF ; format d'image(Pi1,Pi2,pi3)
PokeB(*mem+1,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1; lecture de l'octet de poids faible
PokeB(*mem,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1 ; lecture de l'octet de poids fort
flag=PeekW(*mem) &$FFFF ; debug flag
Else ; degas
; flag : 0=320*200*16 couleurs
; : 1=640*200*4 couleurs
; : 2=640*400*2 couleurs
flag=PeekB(*mem) &$ff ; format d'image(Pi1,Pi2,pi3)
packed= PeekB(*mem+1) &$ff ; packed (pc1,pc2,pc3)
EndIf ;
Select flag ; QUEL FORMAT D'IMAGE
Case 0 ; PI1 16 colors, 320x200 pixels
BIT_PLANES=4 ; 4 PB =16 couleurs
x_bound=320 ; resolution horizontale
y_bound=200 ; resolution Verticale
square=1
offset=6 ;bytes offset
nbytes=160 ;bytes par lignes
Case 1 ; PI2 4 colors, 640x200 pixels
BIT_PLANES=2 ; 2 PB =4 couleurs
x_bound=640 ; resolution horizontale
y_bound=200 ; resolution Verticale
square=1 ; pixels non carres multiplie par 2 pour conserver le raport original
offset=2
nbytes=160
Case 2 ; PI3 2 colors, 640x400 pixels
BIT_PLANES=1 ; 1 PB =16 couleurs
x_bound=640 ; resolution horizontale
y_bound=400 ; resolution Verticale
square=1
offset=0
nbytes=80
EndSelect
; +--------------------------+
; | lecture de la palette |
; +--------------------------+
For b=0 To 15 ; on repete 16 fois la boucle suivante
PokeB(*mem+1,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1;-+
PokeB(*mem,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1 ; | lecture d'un mot sur le disque en BIG ENDIAN j'aurais pu faire une procedure mais j'ai préféré une seule procedure
val.w=PeekW(*mem) &$FFFF ;-+
bl=(val & %1111 )*36 ; BLEU
vl=((val >> 4) & %1111 )*36; VERT
rl=((val >>8) & %1111)*36 ; ROUGE
RVB(b)=RGB(rl,vl,bl) ; stoque la valeur RVB de la couleur actuelle
Next
RVB(1)=RGB(0,0,0)
;----------------------neochrome
If (LCase(GetExtensionPart(file$)))="neo" ; neochrome
For a =1 To 12
filename$=filename$+Chr(PeekB(*sourcebuffer+READ_BYTE)&$FF):READ_BYTE +1;semble ne pas etre implementé
Next
PokeB(*mem+1,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1;-+
PokeB(*mem,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1 ; |
limits=PeekW(*mem) &$FFFF
PokeB(*mem+1,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1;-+
PokeB(*mem,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1 ; |
speed=PeekW(*mem) &$FFFF
PokeB(*mem+1,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1;-+
PokeB(*mem,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1 ; |
steps=PeekW(*MEM) &$ffff
PokeB(*mem+1,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1;-+
PokeB(*mem,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1 ; |
xoffset=PeekW(*MEM) &$ffff
PokeB(*mem+1,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1;-+
PokeB(*mem,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1 ; |
yoffset=PeekW(*mem) &$FFFF
PokeB(*mem+1,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1;-+
PokeB(*mem,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1 ; |
img_w=PeekW(*mem) &$FFFF
PokeB(*mem+1,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1;-+
PokeB(*mem,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1 ; |
img_h=PeekW(*mem) &$FFFF
; les 33 mots suivants sont reserves, on saute 66 bytes
READ_BYTE +66
EndIf
If packed<>0 ; packed degas elite file rle decoder
*unpackbuffer=AllocateMemory(32000)
off=READ_BYTE
off2=0
ligne=0
Repeat
ZZ=0
plane=0
Repeat
Repeat
x=PeekB(*sourcebuffer+off) & $FF
off +1
If x<128
I=0
Repeat
PokeB(*unpackbuffer+off2+ZZ,PeekB(*sourcebuffer+off)&$FF)
off+1
ZZ +1
If ZZ % 2 = 0
ZZ + offset
EndIf
I +1
Until I>x
Else
If x>128
x=256-x
S=PeekB(*sourcebuffer+off)&$FF
off +1
I=0
Repeat
PokeB(*unpackbuffer+off2+ZZ,s)
ZZ + 1
If ZZ % 2 = 0
ZZ + offset
EndIf
I+1
Until I>x
EndIf
EndIf
Until ZZ>=nbytes
ZZ=ZZ-nbytes+2
plane +1
Until plane=BIT_PLANES
;
off2=off2+nbytes
ligne+1
Until ligne=y_bound
EndIf
x=0
; +--------------------------+
; | lecture de l'image |
; +--------------------------+
CreateImage(#image+1,640,400)
StartDrawing(ImageOutput(#image+1))
Repeat
For a=1 To BIT_PLANES ; on repete pour chaque bitplane
If packed=0 ; image non compactée
PokeB(*mem+1,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1 ;-+
PokeB(*mem,PeekB(*sourcebuffer+READ_BYTE)):READ_BYTE +1 ; | lecture d'un mot en big endian
plane(a)=(PeekW(*MEM) & $ffff) ;-+ que l'on stock dans le tableau des bitplanes
Else ; image compactée on lis le buffer
PokeB(*mem+1,PeekB(*unpackbuffer+b_read)&$ff):b_read+1
PokeB(*mem,PeekB(*unpackbuffer+b_read)&$ff):b_read+1
plane(a)=(PeekW(*MEM) & $ffff)
EndIf
Next
If square=0 ;pixel carres ou pas
mul=2 ;multiplicateur vertical
Else
mul=1
EndIf ;
For b=1 To 16 ;
rot=15-(b-1) ; nombre de bit de decalage le premier pixel est a gauche du mot,
mask=1 << rot ; on decale donc le masque de 15 pas pour le premier pixel puis 14 13 ---> 0 pour le dernier pixel
;
; la ligne suivante lis le bit correspondant de chaque bitplan a l'aide du masque
; et additione chaque bit en les decalant de facon a avoir un nombre sur 4 bit pour le registre de couleur
c= ((plane(1) & mask) >> rot)+((plane(2) & mask) >> rot)<<1 +((plane(3) & mask) >> rot)<<2 +((plane(4) & mask) >> rot)<<3
;
Plot(nx,ny*mul,RVB(c)) ; affichage du point sur la surface utilisée pour le dessin aux coordonées choisies
If square=0
Plot(nx,ny*mul+1,RVB(c)) ; affichage du point sur la surface utilisée pour le dessin aux coordonées choisies
EndIf
nx+1 ; point suivant
If nx=x_bound ; arrivée a 320 pixels
nx=0 ; retour en debut de ligne
ny+1 ; retour a la ligne
EndIf
Next ; fin du mot
Until ny=y_bound ; si la ligne de fin est atteinte on sort de la boucle
StopDrawing()
EndIf
FreeMemory(*mem) ;libere la memoire
FreeMemory(*sourcebuffer)
If packed<>0
FreeMemory(*unpackbuffer)
EndIf
GrabImage(#image+1,#image,0,0,x_bound,y_bound)
FreeImage(#image+1)
EndProcedure
; Procedures recupéré de :LSI
; http://www.purebasic.fr/french/viewtopic.php?f=1&t=14022
; *************** la procedure de rotation ************************************
ProcedureDLL.i PivoterImage(ImageID.i, Angle.i) ; Rotation d'une image d'un angle multiple de 90°
Protected bmi.BITMAPINFO, hdc.i, NewImageID.i, Mem.i, Mem2, MemTemp.i, n.i, nn.i, bm.BITMAP, Temp1.i, Temp2.i
NewImageID = 0
If Angle <= 0
Angle = 360 + Angle
EndIf
; On récupère la taille de l'image
GetObject_(ImageID, SizeOf(BITMAP), @bm.BITMAP)
If Angle = 90 Or Angle = 180 Or Angle = 270
; on prépare les infos pour récupérer l'image sous forme d'adresse mémoire
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = bm\bmWidth
bmi\bmiHeader\biHeight = bm\bmHeight
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 32
If bm\bmBitsPixel = 24
bmi\bmiHeader\biCompression = #BI_RGB
EndIf
; On alloue 2 espace mémoire pour recevoir l'image d'origine et l'image pivotée
Mem = AllocateMemory(bm\bmWidth * bm\bmHeight * 4)
If Mem
Mem2 = AllocateMemory(bm\bmWidth * bm\bmHeight * 4)
If Mem2
; On récupère l'image dans un espace mémoire
hdc = CreateCompatibleDC_(GetDC_(ImageID))
If hdc
GetDIBits_(hdc, ImageID, 0, bm\bmHeight, Mem, @bmi, #DIB_RGB_COLORS) ; on envoie la liste dans l'image
DeleteDC_(hdc)
EndIf
MemTemp = Mem
; On fait la rotation de l'image de 90, 180 ou 270°
Select Angle
Case 90 ; rotation de 90°
Temp1 = bm\bmWidth - 1
; Pour chaque point de l'image
For n = 0 To bm\bmHeight - 1
For nn = Temp1 To 0 Step -1
PokeL(Mem2 + (n + nn * bm\bmHeight) * 4, PeekL(MemTemp)) ; On fait une rotation de 90°
MemTemp + 4
; Le * 4 vient du fait qu'on manipule des long
Next
Next
; On inverse la largeur et la hauteur de l'image
Temp1 = bm\bmHeight : bm\bmHeight = bm\bmWidth : bm\bmWidth = Temp1
bmi\bmiHeader\biWidth = bm\bmWidth
bmi\bmiHeader\biHeight = bm\bmHeight
; On crée la nouvelle image vierge
NewImageID = CreateImage(#PB_Any, bm\bmWidth, bm\bmHeight, bm\bmBitsPixel)
Case 180
Temp1 = Mem2 + bm\bmWidth * bm\bmHeight * 4 - 4
For nn = 0 To bm\bmWidth - 1
For n = 0 To bm\bmHeight - 1
PokeL(Temp1 - Temp2, PeekL(Mem + Temp2))
Temp2 + 4
Next
Next
NewImageID = CreateImage(#PB_Any, bm\bmWidth, bm\bmHeight, bm\bmBitsPixel)
Case 270
Temp1 = bm\bmHeight - 1
For n = Temp1 To 0 Step -1
For nn = 0 To bm\bmWidth - 1
PokeL(Mem2 + (n + nn * bm\bmHeight) * 4, PeekL(MemTemp))
MemTemp + 4
Next
Next
Temp1 = bm\bmHeight : bm\bmHeight = bm\bmWidth : bm\bmWidth = Temp1
bmi\bmiHeader\biWidth = bm\bmWidth
bmi\bmiHeader\biHeight = bm\bmHeight
NewImageID = CreateImage(#PB_Any, bm\bmWidth, bm\bmHeight, bm\bmBitsPixel)
EndSelect
; On copie l'espace mémoire qui contient l'image pivotée dans la nouvelle image créée
hdc = CreateCompatibleDC_(GetDC_(ImageID(NewImageID)))
If hdc
SetDIBits_(hdc, ImageID(NewImageID), 0, bm\bmHeight, Mem2, @bmi, #DIB_RGB_COLORS) ; on envoie la liste dans l'image
DeleteDC_(hdc)
EndIf
; On libère la mémoire
FreeMemory(Mem2)
EndIf
FreeMemory(Mem)
EndIf
EndIf
ProcedureReturn NewImageID
EndProcedure
;- Symetrie
ProcedureDLL.i SymetrieV(ImageID.i) ; Symétrie Verticale de l'image
Protected bmi.BITMAPINFO, hdc.i, NewImageID.i, Mem.i, Mem2.i, MemTemp.i, n.i, nn.i, bm.BITMAP
NewImageID = 0
GetObject_(ImageID, SizeOf(BITMAP), @bm.BITMAP)
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = bm\bmWidth
bmi\bmiHeader\biHeight = bm\bmHeight
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 32
If bm\bmBitsPixel = 24
bmi\bmiHeader\biCompression = #BI_RGB
EndIf
Mem = AllocateMemory(bm\bmWidth * bm\bmHeight * 4)
If Mem
Mem2 = AllocateMemory(bm\bmWidth * bm\bmHeight * 4)
If Mem2
hdc = CreateCompatibleDC_(GetDC_(ImageID))
If hdc
GetDIBits_(hdc, ImageID, 0, bm\bmHeight, Mem, @bmi, #DIB_RGB_COLORS) ; on envoie la liste dans l'image
DeleteDC_(hdc)
EndIf
MemTemp = Mem
; On fait la symétrie
For n = 0 To bm\bmHeight - 1
For nn = 0 To bm\bmWidth - 1
PokeL(Mem2 + (nn + (bm\bmHeight - 1 - n) * bm\bmWidth) * 4, PeekL(MemTemp))
MemTemp + 4
Next
Next
; on crée la nouvelle image
NewImageID = CreateImage(#PB_Any, bm\bmWidth, bm\bmHeight, bm\bmBitsPixel)
hdc = CreateCompatibleDC_(GetDC_(ImageID(NewImageID)))
If hdc
SetDIBits_(hdc, ImageID(NewImageID), 0, bm\bmHeight, Mem2, @bmi, #DIB_RGB_COLORS) ; on envoie la liste dans l'image
DeleteDC_(hdc)
EndIf
FreeMemory(Mem2)
EndIf
FreeMemory(Mem)
EndIf
ProcedureReturn NewImageID
EndProcedure
ProcedureDLL.i SymetrieH(ImageID.i) ; Symétrie horizontale de l'image
Protected bmi.BITMAPINFO, hdc.i, NewImageID.i, Mem.i, Mem2.i, MemTemp.i, n.i, nn.i, bm.BITMAP
NewImageID = 0
GetObject_(ImageID, SizeOf(BITMAP), @bm.BITMAP)
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = bm\bmWidth
bmi\bmiHeader\biHeight = bm\bmHeight
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 32
If bm\bmBitsPixel = 24
bmi\bmiHeader\biCompression = #BI_RGB
EndIf
Mem = AllocateMemory(bm\bmWidth * bm\bmHeight * 4)
If Mem
Mem2 = AllocateMemory(bm\bmWidth * bm\bmHeight * 4)
If Mem2
hdc = CreateCompatibleDC_(GetDC_(ImageID))
If hdc
GetDIBits_(hdc, ImageID, 0, bm\bmHeight, Mem, @bmi, #DIB_RGB_COLORS) ; on envoie la liste dans l'image
DeleteDC_(hdc)
EndIf
MemTemp = Mem
; On fait la symétrie
For n = 0 To bm\bmHeight - 1
For nn = 0 To bm\bmWidth - 1
PokeL(Mem2 + (bm\bmWidth - 1 - nn + n * bm\bmWidth) * 4, PeekL(MemTemp))
MemTemp + 4
Next
Next
; on crée la nouvelle image
NewImageID = CreateImage(#PB_Any, bm\bmWidth, bm\bmHeight, bm\bmBitsPixel)
hdc = CreateCompatibleDC_(GetDC_(ImageID(NewImageID)))
If hdc
SetDIBits_(hdc, ImageID(NewImageID), 0, bm\bmHeight, Mem2, @bmi, #DIB_RGB_COLORS) ; on envoie la liste dans l'image
DeleteDC_(hdc)
EndIf
FreeMemory(Mem2)
EndIf
FreeMemory(Mem)
EndIf
ProcedureReturn NewImageID
EndProcedure
Site: http://michel.dobro.free.fr/
Devise :"dis moi ce dont tu as besoin, je t'expliquerai comment t'en passer"