Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, Math, StdCtrls, Buttons, ExtCtrls, ExtDlgs;
- type
- TForm1 = class(TForm)
- Panel1: TPanel;
- gb1: TImage;
- Label1: TLabel;
- gb2: TImage;
- Label2: TLabel;
- BitBtn1: TBitBtn;
- BitBtn2: TBitBtn;
- Label3: TLabel;
- Label4: TLabel;
- Edit1: TEdit;
- Edit2: TEdit;
- opd: TOpenPictureDialog;
- procedure BitBtn1Click(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- procedure FormShow(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.BitBtn1Click(Sender: TObject);
- begin
- if (opd.Execute) then
- gb1.Picture.LoadFromFile(opd.FileName);
- gb2.Picture.LoadFromFile(opd.FileName);
- end;
- procedure TForm1.BitBtn2Click(Sender: TObject);
- var
- br,kl, min, max : Integer;
- temp, xmin, xmax, x, c, p: Real;
- dbaris1, dbaris2 : PByteArray;
- begin
- min :=0; max :=0;
- c:=StrToFloat(Edit1.Text);
- p:=StrToFloat(Edit2.Text);
- for br := 0 to gb1.Height-1 do
- begin
- for kl := 0 to gb1.Width-1 do
- begin
- dbaris1:= gb1.Picture.Bitmap.ScanLine[br];
- dbaris2:= gb2.Picture.Bitmap.ScanLine[br];
- if (Form1.gb1.Picture.Bitmap.PixelFormat= pf8bit) then
- begin
- if (dbaris1[kl] < min ) then min:=dbaris1[kl];
- if (dbaris1[kl] > max ) then max:=dbaris1[kl];
- end;
- end;
- end;
- xmin:= c * Power(min,p);
- xmax:= Power(max,p);
- for br := 0 to gb1.Height-1 do
- begin
- for kl := 0 to gb1.Width-1 do
- begin
- dbaris1 := gb1.Picture.Bitmap.ScanLine[br];
- dbaris2 := gb2.Picture.Bitmap.ScanLine[br];
- if (Form1.gb1.Picture.Bitmap.PixelFormat = pf8bit) then
- begin
- x:= c * Power(dbaris1[kl],p);
- temp:=Round((x-xmin)*(255/xmax));
- if (temp > 255) then dbaris2[kl]:=255;
- if (temp < 0 ) then dbaris2[kl]:=0;
- dbaris2[kl]:=Round(temp);
- end;
- end;
- end;
- gb2.Repaint;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment