Les Snippets

Connexion

Image en niveaux de gris

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 26/03/2006 14:02:43 et initié par MorpionMx [Liste]
Date de mise à jour : 14/05/2007 10:12:47
Vue : 23301
Catégorie(s) : Graphique
Langages dispo pour ce code :
- C# 1.x, C# 2.x
- VB 2005, VB.NET 1.x
- C# 1.x, C# 2.x
- VB 2005, VB.NET 1.x
- VB6
- VB6
- Java
- Assembleur x86
- Delphi 5
- Java
- C++, C++ .NET 1.x, C++ .NET 2.x
- Delphi 5
- Delphi 5
- Voir tous les langages pour ce code snippet



Langage : Delphi 5
Date ajout : 25/07/2008
Posté par Caribensila [Liste]

procedure ColToAverageGrey( const BMP : TBitmap );
           var Grey : Byte;
                 i       : Integer;
                 Pix   : pRGBQuad;
begin
  BMP.PixelFormat := pf32bit;
  Pix := BMP.ScanLine[ BMP.Height-1 ]; // Un seul appel à Scanline.
  for i:=1 to BMP.Width*BMP.Height do begin
    Grey := ( Pix^.rgbBlue + Pix^.rgbGreen + Pix^.rgbRed ) div 3;
    Pix^.rgbBlue   := Grey;
    Pix^.rgbGreen := Grey;
    Pix^.rgbRed    := Grey;
    Inc( Pix );
  end;
end;


procedure ColToSightGrey( const BMP : TBitmap );
           var Grey : Byte;
                 i       : Integer;
                 Pix   : pRGBQuad;
begin
  BMP.PixelFormat := pf32bit;
  Pix := BMP.ScanLine[ BMP.Height-1 ]; // Un seul appel à Scanline.
  for i:=1 to BMP.Width*BMP.Height do begin
    Grey := round( Pix^.rgbBlue*0.0721 + Pix^.rgbGreen*0.7154 + Pix^.rgbRed*0.2125 );
    Pix^.rgbBlue   := Grey;
    Pix^.rgbGreen := Grey;
    Pix^.rgbRed    := Grey;
    Inc( Pix );
  end;
end;


{UTILISATION :}
procedure TForm1.Button1Click( Sender: TObject );
           var BMPtemp1, BMPtemp2 : TBitmap;
begin
  BMPtemp1 := TBitmap.Create;
  BMPtemp2 := TBitmap.Create;
  try
    BMPtemp1.Assign( Image1.picture.bitmap );
    ColToAverageGrey( BMPtemp1 );
    Image2.Picture.Bitmap.Assign( BMPtemp1 );
    BMPtemp2.Assign( Image1.picture.bitmap );
    ColToSightGrey( BMPtemp2 );
    Image3.Picture.Bitmap.Assign( BMPtemp2 );
  finally BMPtemp2.Free;BMPtemp1.Free; end;
end;



Snippets en rapport avec : Image, Picture, Niveau, Gris, Grayscale



Codes sources en rapport avec : Image, Picture, Niveau, Gris, Grayscale

{JAVA / J2EE} FAIRE DEFILER UNE IMAGE
...

{Visual Basic, VB6, VB.NET, VB 2005} CONVERTIR UNE IMAGE EN NIVEAU DE GRIS
On peut convertir une image couleur en niveau de gris via une formule empirique liée aux composantes...

{PHP} CRÉE UNE IMAGE DE PILE DE MINIATURES EN UTILISANT LA BIBLIOTHÈQUE GD
Tout est dans le titre. Regarder la capture pour mieux comprendre. N'hésitez pas à me contacter ...

{Visual Basic, VB6, VB.NET, VB 2005} LOUPE PICTURE BOX
AUTEUR: ProgElecT SOURCE: http://www.developpez.net/forums/d208213/autres-langages/general-visual...

{Visual Basic, VB6, VB.NET, VB 2005} REDIMENSIONNER IMAGE + COMPRESSION EN JPG ( AVEC OPTION )
Bonjour, Ce controle utilisateur reprend pour plus de simplicité la methode de redimensionnement ...

{PHP} REDIMENSIONNEMENT D'UNE IMAGES, GIF, PNG, JPEG, JPG
J'éspère que ce code vous sera utile, je n'ai pas encore eu de problème avec ce code, je l'ai amélio...

{Visual Basic, VB6, VB.NET, VB 2005} ROTATION IMAGE AVEC GDI+ (EXEMPLES ET QUESTIONS)
Quelques humbles exemples à partir du source de Renfield que j'espère n'avoir pas trop massacré, pou...

{Delphi} CHARGER DES IMAGES A PARTIR D'UNE DLL
Charger des images a partir d'une DLL...

{C / C++ / C++.NET} ECRAN DE VEILLE (LOAD IMAGE REPERTOIRE)
Bonjour, Je recherchais un écran de veille paramétrable assez facilement, ne le trouvant pas j'ai...

{Javascript / DHTML} DIAPORAMA PHP / JS
Bonjour, voila ne trouvant pas de diaporama à mon goût, j'ai décidé d'en faire un moi même ;) C'est...