CREATION ICONE VALIDE A PARTIR DE SECTIONDATA

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
Fortix
Messages : 559
Inscription : mar. 30/mai/2006 17:03

Message par Fortix »

Si t'as mieu à proposer @Case surtout n'hésite pas!!,poste :wink:
mais pour le moment celui là fonctionne bien

encore merci :D
Avatar de l’utilisateur
Fortix
Messages : 559
Inscription : mar. 30/mai/2006 17:03

Message par Fortix »

Celà dis j'ais remarqué que l'îcone qu'on crée avec sa structure n'a pas d'ID, il en aura une seulement après l'avoir rechargé avec LoadImage(image0),

alors la question est la suivante, est il possible d'attribuer un ID à une îcone ainsi crée pendant l'execution même? (de façon à ne pas créer d'élement image externe pour les recharger aussitôt)

Merchite :lol:
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

Regarde là-dedans :
http://www.purebasic.fr/french/viewtopic.php?t=7191
Il y a 2 fonctions :

CreateAlphaImage() et
CatchAlphaImage()

Case pourra te confirmer si ça fait l'affaire...
Avatar de l’utilisateur
case
Messages : 1546
Inscription : lun. 10/sept./2007 11:13

Message par case »

en fait c'est tout bete :p il suffis d'utiliser catch image a l'adresse du buffer ou on cree l'icone .





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 

Avatar de l’utilisateur
Fortix
Messages : 559
Inscription : mar. 30/mai/2006 17:03

Message par Fortix »

C'est vraiement super les gars, vous avez réponse à touts décidement,

comme on dit, la réponse est là où on c'y attent le moin!!!

je pensais qu'il fallait intervenir dans la structure de l'îcone même pour donner en quelques sortes une identitée mais en fait sa n'a rien à voir :lol:

merci 1000 fois :D :D :D
Répondre