Recent Posts

Selamat datang di Coding Delphi Land Weblog kumpulan source code pemogram delphi

(Bukan maksud untuk menggurui tetapi marilah kita berbagi ilmu tuk perkembangan kemajuan teknologi kita

Selasa, 17 November 2009

MakeShadesofGrayImage from RGB Composite Image

PROCEDURE TForm1.MakeShadesOfGrayImage;
VAR
Gray : INTEGER;
i : INTEGER;
j : INTEGER;
rowRGB : pRGBTripleArray;
rowGray: pRGBTripleArray;
BEGIN
Screen.Cursor := crHourGlass;
TRY
FOR j := BitmapRGB.Height-1 DOWNTO 0 DO
BEGIN
rowRGB := BitmapRGB.Scanline[j];
rowGray := BitmapGray.Scanline[j];
FOR i := BitmapRGB.Width-1 DOWNTO 0 DO
BEGIN
// Intensity = (R + G + B) DIV 3
WITH rowRGB[i] DO
Gray := (rgbtRed + rgbtGreen + rgbtBlue) DIV 3;

WITH rowGray[i] DO
BEGIN
rgbtRed := Gray;
rgbtGreen := Gray;
rgbtBlue := Gray
END

END
END;
FINALLY
Screen.Cursor := crDefault
END
END;

0 komentar:

Posting Komentar