Code archives/Graphics/MirrorImage

This code has been declared by its author to be Public Domain code.

Download source code

MirrorImage by Justus2007
This function returns an image, which is vertically mirrored and given a transparency gradient to create the impression of a mirror.
How visible the mirror is can be adjusted by changing maxAlpha in the range from 0.0 up to 255.0

Example:
http://www.blitzforum.de/upload/file.php?id=1265
Function mirrorImage:TImage(img:TImage)
   Local a:Int
   Local r:Int
   Local g:Int
   Local b:Int
   Local i:Int
   Local j:Int
   Local argb:Int
   Local pixmap:TPixmap = LockImage(img)
   pixmap = ConvertPixmap(pixmap,PF_RGBA8888)
   pixmap = YFlipPixmap(pixmap)
   For i = 0 To PixmapWidth(pixmap)-1
      For j = 0 To PixmapHeight(pixmap)-1
         argb = ReadPixel(pixmap,i,j)
         a:Int = Int(76.0*(1.0-((Float(j)/Float(ImageHeight(img))))))
         If (argb Shr 24) = 0 Then a = 0
         r:Int = (argb Shr 16) & $ff
           g:Int = (argb Shr 8)  & $ff
           b:Int = argb & $ff
         argb = a*$1000000 + r*$10000 + g*$100 + b
         WritePixel pixmap,i,j,argb
      Next
   Next
   Return LoadImage(pixmap)
EndFunction

Comments

xlsior2007
Nice effect


Code Archives Forum