Write, bd2 )) then begin try for Y := 0 to ( Source. LoadFromFile ( FileName ) Result := TBitmap. P1, p2 : PAlphaColorArray Source : TBitmap begin Source := TBitmap. Unmap ( bd2 ) end end end function ConvertToGrayscale ( const FileName : String const aMethod : TAlgorithm = algnone ): TBitmap var P2 := Colortogray ( p1, aMethod ) end end finallyĪBitmap. GetScanline ( Y )) for X := 0 to ( aBitmap. Write, bd2 )) then begin try for Y := 0 to ( aBitmap. P1, p2 : PAlphaColorArray begin Result := TBitmap. ![]() Minvalue ()) / 2 Exit ( HSLToRGB ( H, S, L )) end else Exit ( HSLtoRGB ( 0, 0, L )) end end function ConvertToGrayscale ( const aBitmap : TBitmap const aMethod : TAlgorithm = algnone ): TBitmap var B ) Exit ( HSLToRGB ( H, S, L )) end Īlgaverage : begin var mean : integer := ( c. ![]() ![]() Type Talgorithm = ( algnone, algluminosity, algaverage, alglightness ) function ConvertToGrayscale ( const aBitmap : TBitmap const aMethod : TAlgorithm = algnone ) : TBitmap overload function ConvertToGrayscale ( const FileName : String const aMethod : TAlgorithm = algnone ) : TBitmap overload įunction Colortogray ( const aColor : Talphacolor const aAlgo : TAlgorithm = algnone ) : Talphacolor varĬ : TAlphacolorRec // begin RGBToHSL ( aColor, H, S, L ) HI, I wrote this unit to grayscale an image
0 Comments
Leave a Reply. |