Example Delphi
Delphi Examples Collection
Today, Delphi is one of the popular desktop programming tool. There are thousand even million programmer in this world using delphi as their favorit tool. This site try to collect the examples, tips and tricks of Delphi programming. We collect, test them and redistribute the collection of delphi programming for you.
Convert Bitmap Image to Grayscale
Author: admin | Category: Graphic
//This is how we can convert bitmap to grayscale mode function ConvertBitmapToGrayscale(const Bitmap: TBitmap): TBitmap; var i, j: Integer; Grayshade, Red, Green, Blue: Byte; PixelColor: Longint; begin with Bitmap do for i := 0 to Width - 1 do for j := 0 to Height - 1 do begin PixelColor := ColorToRGB(Canvas.Pixels[i, j]); Red := PixelColor; Green := PixelColor shr 8; Blue := PixelColor shr 16; Grayshade := Round(0.3 * Red + 0.6 * Green + 0.1 * Blue); Canvas.Pixels[i, j] := RGB(Grayshade, Grayshade, Grayshade); end; Result := Bitmap; end;
Is there any way we can use this function or a similar one with a JPEG file?
Yes we can.
First convert JPEG file to Bitmap, then use any bitmap operation to the convert result bitmap.
Try this example
great reply thanks!!