[SOLVED] Image couleur ver nb

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
microdevweb
Messages : 1802
Inscription : mer. 29/juin/2011 14:11
Localisation : Belgique

[SOLVED] Image couleur ver nb

Message par microdevweb »

Bonjour,

quelqu’un connait'il une méthode, pour afficher une image couleur en nb, ou convertir une image couleur en nb.

Merci

J'ai trouvé voici la solution

Code : Tout sélectionner

Procedure ImageGrayout(image)
  Protected w, h, x, y, r, g, b, gray, color
 
  w = ImageWidth(image)
  h = ImageHeight(image)
  StartDrawing(ImageOutput(image))
  For x = 0 To w - 1
    For y = 0 To h - 1
      color = Point(x, y)
      r    = Red(color)
      g    = Green(color)
      b    = Blue(color)
      gray = 0.2126*r + 0.7152*g + 0.0722*b
      Plot(x, y, RGB(gray, gray, gray))
    Next
  Next
  StopDrawing()
EndProcedure
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Avatar de l’utilisateur
SPH
Messages : 4947
Inscription : mer. 09/nov./2005 9:53

Re: [SOLVED] Image couleur ver nb

Message par SPH »

Pourquoi pas ceci ? :

Code : Tout sélectionner

Procedure ImageGrayout(image)
  Protected w, h, x, y, r, g, b, gray, color

  w = ImageWidth(image)
  h = ImageHeight(image)
  StartDrawing(ImageOutput(image))
  For x = 0 To w - 1
    For y = 0 To h - 1
      color = Point(x, y)
      r    = Red(color)
      g    = Green(color)
      b    = Blue(color)
      gray = (r+g+b)/3
      Plot(x, y, RGB(gray, gray, gray))
    Next
  Next
  StopDrawing()
EndProcedure

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Répondre