Publié : mar. 25/sept./2007 18:18
Si t'as mieu à proposer @Case surtout n'hésite pas!!,poste
mais pour le moment celui là fonctionne bien
encore merci

mais pour le moment celui là fonctionne bien
encore merci

Forums PureBasic - Français
https://www.purebasic.fr/french/
Code : Tout sélectionner
Declare poke(mem,offset,value,typ)
Procedure saveicon(filename$,hauteur,largeur, ColorKey)
buffer=AllocateMemory(10000)
If buffer
;-------------------------------ICONDIR structure
offset=poke(buffer,offset,0,1) ;reserved must be 0 (WORD)0
offset=poke(buffer,offset,1,1) ;ressource type icon=1 (WORD)2
offset=poke(buffer,offset,1,1) ;how many images 1 (WORD)4
;-------------------------------ICONDIR ENTRY
offset=poke(buffer,offset,largeur,0) ;width in pixel of the picture (BYTE)6
offset=poke(buffer,offset,hauteur,0) ;height in pixel of the picture (BYTE)7
offset=poke(buffer,offset,0,0) ;#color in image 0 if >8bpp (BYTE)8
offset=poke(buffer,offset,0,0) ;reserved must be 0 (BYTE)9
offset=poke(buffer,offset,1,1) ;color planes (WORD)10
offset=poke(buffer,offset,32,1) ;bit per pixel (WORD)12
bytecount=((largeur*hauteur)*4);x,y*4 bytes
offset=poke(buffer,offset,bytecount+40+(largeur*hauteur)/8,2) ;how many bytes in this ressource (DWORD)14
offset=poke(buffer,offset,offset+4,2) ;where in the file is the bitmap data (DWORD)18
;--------------------------------DIB header
offset=poke(buffer,offset,40,2) ;lenght of the header (DWORD)22
offset=poke(buffer,offset,largeur,2) ;width in pixel of the picture (DWORD)26
offset=poke(buffer,offset,hauteur*2,2) ;width in pixel of the picture (DWORD)30
offset=poke(buffer,offset,1,1) ;color planes 1 in most case (WORD)34
offset=poke(buffer,offset,32,1) ;bit per pixel (WORD)36
offset=poke(buffer,offset,0,2) ;compression value (DWORD)38
offset=poke(buffer,offset,bytecount,2) ;pixeldata size (DWORD)42
offset=poke(buffer,offset,0,2) ;ppm (DWORD)46
offset=poke(buffer,offset,0,2) ;ppm (DWORD)50
offset=poke(buffer,offset,0,2) ;number of color 0=max (DWORD)54
offset=poke(buffer,offset,0,2) ;number of color indice importants 0=max(DWORD)58
For y=0 To Hauteur -1
For x=0 To Largeur -1
Read a.l
b=(a <<8)>>24
g=(a <<16)>>24
r=(a <<24)>>24
If RGB(r, g, b) = ColorKey: Alpha = 0: Else: Alpha = 255: EndIf
offset=poke(buffer,offset,B,0)
offset=poke(buffer,offset,G,0)
offset=poke(buffer,offset,R,0)
offset=poke(buffer,offset,Alpha,0)
Next x
Next Y
EndIf
For a=1 To bytecount/8
offset=poke(buffer,offset,0,0)
Next
ProcedureReturn buffer
EndProcedure
Procedure poke(mem,offset,value,typ)
Select typ
Case 0;byte
PokeB(mem+offset,value):offset=offset+1
Case 1;word
PokeW(mem+offset,value):offset=offset+2
Case 2;long
PokeL(mem+offset,value):offset=offset+4
EndSelect
ProcedureReturn offset
EndProcedure
If OpenWindow(0, 100, 200, 300, 200, "Pti test")
CreateGadgetList(WindowID(0))
icon= saveicon("c:\blah.ico",32,32, RGB(0, 0, 0) )
CatchImage (0,icon)
FreeMemory(icon)
If AddSysTrayIcon(0, WindowID(0),ImageID(0) )=0
Debug "Element non valide: îcone"
Else
Debug "Element autorisé: îcone"
EndIf
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
EndIf
End
DataSection
Data.l $000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000
Data.l $000000,$AA25FF,$AA25FF,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000
Data.l $000000,$AA25FF,$AA25FF,$000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000
Data.l $000000,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$FF4873,$AA25FF,$000000,$000000,$000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000
Data.l $000000,$000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$FF4873,$FF4873,$FF4873,$AA25FF,$000000,$000000,$000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000
Data.l $000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$FF4873,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$AA25FF,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000
Data.l $000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000,$AA25FF,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000
Data.l $AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000
Data.l $AA25FF,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000
Data.l $AA25FF,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$FF4873,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000
Data.l $AA25FF,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$FF4873,$FF4873,$FF4873,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000
Data.l $AA25FF,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$FF4873,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000
Data.l $AA25FF,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000
Data.l $AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000
Data.l $000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$FF4873,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000
Data.l $000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$FF4873,$FF4873,$FF4873,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000
Data.l $000000,$000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$FF4873,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$FF4873,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000
Data.l $000000,$000000,$000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$FF4873,$FF4873,$FF4873,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000
Data.l $000000,$000000,$000000,$000000,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$FF4873,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000
Data.l $000000,$AA25FF,$AA25FF,$AA25FF,$000000,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000
Data.l $000000,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$FF4873,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000
Data.l $000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$FF4873,$FF4873,$FF4873,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000
Data.l $000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$FF4873,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000
Data.l $000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000
Data.l $000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$FF4873,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000
Data.l $000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$FF4873,$FF4873,$FF4873,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000
Data.l $000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$FF4873,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000
Data.l $000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000
Data.l $000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$AA25FF,$AA25FF,$000000
Data.l $000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$000000
Data.l $000000,$000000,$000000,$000000,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$AA25FF,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000
Data.l $000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000
;_Hauteur: 32 px
;_Largeur: 32 px
EndDataSection