Vertical mirror in a Bitmap  

Send By: Q3 Team
Web : http://www.q3.nu
Email: dlib@q3.nu
Date: 12/09/99

Tip accessed 440 times

 


  • Put a TButton (Button1) and a TImage (Image1) in your form
  • Load an image in Image1


     procedure TForm1.Button2Click(Sender: TObject);
    
     procedure EspejoVrt(BMPOrigen, BMPDestino:TBitmap);
     var
        f,c:integer;
        Ancho,Alto:integer;
        tmpBMP: TBitmap;
     begin
       {Bitmap temporal}
       tmpBMP:=TBitmap.create;
       with tmpBMP do
       begin
         Height:=BMPOrigen.height;
         Width :=BMPOrigen.width;
       end;
    
       {Inicializamos los límites de los bucles}
       {Initialize loop's limits}
       Ancho:=BMPOrigen.Width-1;
       Alto :=BMPOrigen.Height-1;
    
       {Copiamos los pixels}
       {Copy the pìxels}
       for f:=0 to Alto do
       begin
         for c:=0 to Ancho do
           tmpBMP.Canvas.Pixels[c,f]:=BMPOrigen.Canvas.Pixels[c,Alto-f];
       end;
    
       BMPDestino.Assign(tmpBMP);
       tmpBMP.Free;
     end;
    
     begin
       EspejoVrt(Image1.Picture.Bitmap,Image1.Picture.Bitmap);
     end;
    



    You can use the function with the same Bitmap like origin and like destination or to put the resulting image in another bitmap.