[Delphi] Image czarno – biały

0

Jak zmienić obrazek w Image z kolorowego na czarno – biały.

--
Pozdrowienia dla całego FORUM !

Marco_99

0

nie wiem czy to Ci pomoże.ale zawsze bedziesz mial jakiś punkt zaczepienia..program przyciemnia lub rozjaśnia dowolny obrazek
(to jest cały kompletny listing)

------------CUT HERE-----------------
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, jpeg, ExtDlgs;

type
TForm1 = class(TForm)
Image1: TImage;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
OpenP: TOpenPictureDialog;
Button1: TButton;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function Darker(Col: TColor; Percent: Byte): TColor;
var
R, G, B: Byte;
begin
R := GetRValue(Col);
G := GetGValue(Col);
B := GetBValue(Col);
R := Round(RPercent/100);
G := Round(G
Percent/100);
B := Round(B*Percent/100);
Result := RGB(R, G, B);
end;

function Lighter(Col: TColor; Percent: Byte): TColor;
var
R, G, B: Byte;
begin
R := GetRValue(Col);
G := GetGValue(Col);
B := GetBValue(Col);
R := Round(RPercent/100) + Round(255 - Percent/100255);
G := Round(GPercent/100) + Round(255 - Percent/100255);
B := Round(BPercent/100) + Round(255 - Percent/100255);
Result := RGB(R, G, B);
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
var
Pic : TBitmap;
I, J : Integer;
begin
Pic := TBitmap.Create;
try
Pic.Assign(Image1.Picture.Graphic);
for I := 0 to Pic.Width do
for J := 0 to Pic.Height do
Pic.Canvas.Pixels[i, j] := Darker(Pic.Canvas.Pixels[i, j], 50);

Image1.Picture.Graphic := Pic;

finally
Pic.Free;
end;

end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
if openp.execute then //openp to openpicturedialog
image1.picture.loadfromfile(openp.FileName);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
Pic : TBitmap;
I, J : Integer;
begin
Pic := TBitmap.Create;
try
Pic.Assign(Image1.Picture.Graphic);
for I := 0 to Pic.Width do
for J := 0 to Pic.Height do
Pic.Canvas.Pixels[i, j] := Lighter(Pic.Canvas.Pixels[i, j], 50);

Image1.Picture.Graphic := Pic;

finally
Pic.Free;
end;

end;

end.
------------CUT HERE-----------------

jak coś niejasne to mail albo coś

--
[email protected]
POZDRAWIAM
DELPHI RULEZ
NIECH MOCz BĘDZIE Z WAMI
:-))

0

LOFIX - Bardzo dziękuje , na pewno coś z tego przerobię. ;-)

--
Pozdrowienia dla całego FORUM !

Marco_99

0

Przykład jest w gotowcach

[cisza]
lolek

1 użytkowników online, w tym zalogowanych: 0, gości: 1