Warna dasar di dunia digital ada tiga macam, yaitu Red, Green, dan Blue.
.Format RGB banyak digunakan dalam menyatakan pixel dalam sistem
digital. Hal ini sehubungan dengan kemudahan pernyataan warna dalam
bentuk komponen warnaprimer R, G dan B.
Dan berikut adalah syntacnya:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TeEngine, Series, ExtCtrls,
TeeProcs, Chart;
type
TForm1 = class(TForm)
Label1: TLabel;
Image1: TImage;
Chart1: TChart;
Series1: TLineSeries;
Series2: TLineSeries;
Series3: TLineSeries;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
OpenDialog1: TOpenDialog;
Button1: TButton;
ScrollBar1: TScrollBar;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ScrollBar1Change(Sender:
TObject);
procedure Image1MouseMove(Sender:
TObject; Shift: TShiftState; X,
Y: Integer);
procedure Image1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var
Action: TCloseAction);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
gambar2 :Tbitmap;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender:
TObject);
var
red,green,blue:byte;
a,b,lebar:Integer;
warna:TColor;
open:string;
begin
OpenDialog1.Execute;
open:=OpenDialog1.FileName;
Image1.Picture.LoadFromFile(open);
scrollbar1.Enabled := True;
gambar2.Assign(Image1.Picture);
ScrollBar1.Max:=Image1.Picture.Height;
end;
ATAU
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Label1: TLabel;
Image1: TImage;
Chart1: TChart;
Series1: TLineSeries;
Series2: TLineSeries;
Series3: TLineSeries;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
OpenDialog1: TOpenDialog;
Button1: TButton;
ScrollBar1: TScrollBar;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ScrollBar1Change(Sender: TObject);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Image1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
gambar2 :Tbitmap;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
red,green,blue:byte;
a,b,lebar:Integer;
warna:TColor;
open:string;
begin
OpenDialog1.Execute;
open:=OpenDialog1.FileName;
Image1.Picture.LoadFromFile(open);
scrollbar1.Enabled := True;
gambar2.Assign(Image1.Picture);
ScrollBar1.Max:=Image1.Picture.Height;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
gambar2:=TBitmap.Create;
// ScrollBar1.Max:=Image1.Picture.Height;
end;
procedure TForm1.ScrollBar1Change(Sender: TObject);
var
red,green,blue:byte;
a,b,lebar:Integer;
warna:TColor;
garis:TBitmap;
begin
Series1.Clear;
Series2.Clear;
Series3.Clear;
b:=ScrollBar1.Position;
lebar:=Image1.Picture.Bitmap.Width;
garis:=TBitmap.Create;
garis.Assign(gambar2);
garis.Canvas.MoveTo(0,b);
garis.Canvas.LineTo(lebar,b);
for a:=0 to lebar -1 do
begin
warna:=Image1.Picture.Bitmap.Canvas.Pixels[a,b];
red:=GetRValue(warna);
green:=GetGValue(warna);
blue:=GetBValue(warna);
Series1.AddXY(a,red);
Series2.AddXY(a,green);
Series3.AddXY(a,blue);
end;
Image1.Picture.Assign(garis);
garis.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
open:string;
begin
OpenDialog1.Execute;
open:=OpenDialog1.FileName;
Image1.Picture.LoadFromFile(open);
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
warna:TColor;
begin
warna:=Image1.Picture.Bitmap.Canvas.Pixels[X,Y];
Label2.Caption:= inttostr(GetRValue(warna));
Label3.Caption:= IntToStr(GetGValue(warna));
Label4.Caption:= IntToStr(GetBValue(warna));
end;
procedure TForm1.Image1Click(Sender: TObject);
begin
gambar2:=TBitmap.Create;
ScrollBar1.Max:=Image1.Picture.Height;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
gambar2.Free;
end;
end.
Dan berikut adalah syntacnya:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TeEngine, Series, ExtCtrls,
TeeProcs, Chart;
type
TForm1 = class(TForm)
Label1: TLabel;
Image1: TImage;
Chart1: TChart;
Series1: TLineSeries;
Series2: TLineSeries;
Series3: TLineSeries;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
OpenDialog1: TOpenDialog;
Button1: TButton;
ScrollBar1: TScrollBar;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ScrollBar1Change(Sender:
TObject);
procedure Image1MouseMove(Sender:
TObject; Shift: TShiftState; X,
Y: Integer);
procedure Image1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var
Action: TCloseAction);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
gambar2 :Tbitmap;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender:
TObject);
var
red,green,blue:byte;
a,b,lebar:Integer;
warna:TColor;
open:string;
begin
OpenDialog1.Execute;
open:=OpenDialog1.FileName;
Image1.Picture.LoadFromFile(open);
scrollbar1.Enabled := True;
gambar2.Assign(Image1.Picture);
ScrollBar1.Max:=Image1.Picture.Height;
end;
ATAU
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Label1: TLabel;
Image1: TImage;
Chart1: TChart;
Series1: TLineSeries;
Series2: TLineSeries;
Series3: TLineSeries;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
OpenDialog1: TOpenDialog;
Button1: TButton;
ScrollBar1: TScrollBar;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ScrollBar1Change(Sender: TObject);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Image1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
gambar2 :Tbitmap;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
red,green,blue:byte;
a,b,lebar:Integer;
warna:TColor;
open:string;
begin
OpenDialog1.Execute;
open:=OpenDialog1.FileName;
Image1.Picture.LoadFromFile(open);
scrollbar1.Enabled := True;
gambar2.Assign(Image1.Picture);
ScrollBar1.Max:=Image1.Picture.Height;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
gambar2:=TBitmap.Create;
// ScrollBar1.Max:=Image1.Picture.Height;
end;
procedure TForm1.ScrollBar1Change(Sender: TObject);
var
red,green,blue:byte;
a,b,lebar:Integer;
warna:TColor;
garis:TBitmap;
begin
Series1.Clear;
Series2.Clear;
Series3.Clear;
b:=ScrollBar1.Position;
lebar:=Image1.Picture.Bitmap.Width;
garis:=TBitmap.Create;
garis.Assign(gambar2);
garis.Canvas.MoveTo(0,b);
garis.Canvas.LineTo(lebar,b);
for a:=0 to lebar -1 do
begin
warna:=Image1.Picture.Bitmap.Canvas.Pixels[a,b];
red:=GetRValue(warna);
green:=GetGValue(warna);
blue:=GetBValue(warna);
Series1.AddXY(a,red);
Series2.AddXY(a,green);
Series3.AddXY(a,blue);
end;
Image1.Picture.Assign(garis);
garis.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
open:string;
begin
OpenDialog1.Execute;
open:=OpenDialog1.FileName;
Image1.Picture.LoadFromFile(open);
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
warna:TColor;
begin
warna:=Image1.Picture.Bitmap.Canvas.Pixels[X,Y];
Label2.Caption:= inttostr(GetRValue(warna));
Label3.Caption:= IntToStr(GetGValue(warna));
Label4.Caption:= IntToStr(GetBValue(warna));
end;
procedure TForm1.Image1Click(Sender: TObject);
begin
gambar2:=TBitmap.Create;
ScrollBar1.Max:=Image1.Picture.Height;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
gambar2.Free;
end;
end.
Tidak ada komentar:
Posting Komentar