créer image pixel par pixel

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
venom
Messages : 3138
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

créer image pixel par pixel

Message par venom »

Bonjour,

voilà a une époque je souhaité faire de la stéganographie sur image.
bon j'ai toujours pas réussi :D .

en revanche même si je suis sur qu'il y a beaucoup plus simple, j'ai fait un code qui permet de récupérer pixel par pixel une image, et de la ré envoyé sur un Drawing() grâce a la fonction Plot().

voilà comme je dit plus haut sa existe plus simple mais la ont peut s'amuser en changent les valeurs par exemple : foncer ou éclaircir l'image.

Bref voici le code au cas ou sa peut servir a quel qu'un.

Code : Tout sélectionner

Structure img
 x.l
 y.l
 color.l
EndStructure

file$ = OpenFileRequester("fichier image", "", "image bitmap|*.bmp"  , 0);<---- ont choisit une image bitmap
If LoadImage(1, file$);<--- ont charge l'image du dessus
 If StartDrawing(ImageOutput(1))
  width = ImageWidth(1);<--- ont prend la largeur de l'image
  height = ImageHeight(1);<--- ont prend la hauteur de l'image
  size = width * height;<--- ont multiplie la largeur par la hauteur pour savoir le nombre de pixels au total
  Dim array.img(size)

;<------------------------- ont récupère la  couleur de chaque pixel -----------------------
  i=0
  For y = 0 To height-1
   For x = 0 To width-1
    color = Point(x, y)
    array(i)\x = x
    array(i)\y = y
    array(i)\color = color
    i+1
   Next
  Next
;<------------------------------------------------------------------------------------------
  StopDrawing()

 EndIf 
EndIf 

If OpenWindow(0, 0, 0, ImageWidth(1), ImageHeight(1), "");<------------------------- ont ouvre une fenêtre a la taille de l'image
 If CreateImage(0, ImageWidth(1), ImageHeight(1));<------------------------- ont charge l'environnement image
  If StartDrawing(ImageOutput(0))

For i=0 To size-1
 i=0
  For y = 0 To height-1
   For x = 0 To width-1
    i+1
      Plot(array(i)\x = x, array(i)\y = y, RGB(Red(array(i)\color), Green(array(i)\color), Blue(array(i)\color)));<----- ici ont redessine pixel par pixel sur le Drawing() 
   Next
  Next
Next 
     
      StopDrawing()
    EndIf
  EndIf

 ImageGadget(0, 0, 0, 0, 0, ImageID(0))
  
  Repeat
    EventID = WaitWindowEvent() 
  Until EventID = #PB_Event_CloseWindow
EndIf
;<------------------------- et ont quitte
bon le débu du code ne viens pas de moi mais je ne sais plus de qui désolé pour lui :oops:

voilà





@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Avatar de l’utilisateur
venom
Messages : 3138
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Message par venom »

j'ai re modifier mon code et je lui est ajouté 3 trackbargadget() pour changer la valeur de red(), green(), blue()
voilà :

Code : Tout sélectionner

Structure img
 x.l
 y.l
 color.l
EndStructure

file$ = OpenFileRequester("fichier image", "", "image bitmap|*.bmp"  , 0);<---- ont choisit une image bitmap
If LoadImage(1, file$);<--- ont charge l'image du dessus
 If StartDrawing(ImageOutput(1))
  width = ImageWidth(1);<--- ont prend la largeur de l'image
  height = ImageHeight(1);<--- ont prend la hauteur de l'image
  size = width * height;<--- ont multiplie la largeur par la hauteur pour savoir le nombre de pixels au total
  Dim array.img(size)

;<------------------------- ont récupère la  couleur de chaque pixel -----------------------
  i=0
  For y = 0 To height-1
   For x = 0 To width-1
    color = Point(x, y)
    array(i)\x = x
    array(i)\y = y
    array(i)\color = color
    i+1
   Next
  Next
;<------------------------------------------------------------------------------------------
  StopDrawing()

 EndIf 
EndIf 

If OpenWindow(0, 0, 0, ImageWidth(1), ImageHeight(1)+30, "");<------------------------- ont ouvre une fenêtre a la taille de l'image
 If CreateImage(0, ImageWidth(1), ImageHeight(1));<------------------------- ont charge l'environnement image
  If StartDrawing(ImageOutput(0))

For i=0 To size-1
 i=0
  For y = 0 To height-1
   For x = 0 To width-1
    i+1
      Plot(array(i)\x = x, array(i)\y = y, RGB(Red(array(i)\color), Green(array(i)\color), Blue(array(i)\color)));<----- ici ont redessine pixel par pixel sur le Drawing() 
   Next
  Next
Next 
     
      StopDrawing()
    EndIf
   TrackBarGadget(8, 0,  ImageHeight(1)+5, 100, 20, 0, 100)
   TrackBarGadget(9, 120,  ImageHeight(1)+5, 100, 20, 0, 100)
   TrackBarGadget(10, 240,  ImageHeight(1)+5, 100, 20, 0, 100)
   ButtonGadget(11, 360, ImageHeight(1)+5, 200, 20, "recalculer les pixels")
  EndIf

 ImageGadget(0, 0, 0, 0, 0, ImageID(0))
  
  Repeat
   EventID = WaitWindowEvent()
    If EventID = #PB_Event_Gadget 
      Select EventGadget()
      
       Case 11
        If StartDrawing(ImageOutput(0))

         For i=0 To size-1
          i=0
           For y = 0 To height-1
            For x = 0 To width-1
             i+1
              Plot(array(i)\x = x, array(i)\y = y, RGB(Red(array(i)\color)+GetGadgetState(8), Green(array(i)\color)+GetGadgetState(9), Blue(array(i)\color)+GetGadgetState(10)));<----- ici ont redessine pixel par pixel sur le Drawing() 
            Next
           Next
         Next 
     
         StopDrawing()
        EndIf
      ImageGadget(0, 0, 0, 0, 0, ImageID(0))
      EndSelect
    EndIf
  Until EventID = #PB_Event_CloseWindow
EndIf
;<------------------------- et ont quitte





@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Répondre