Показать сообщение отдельно
  #2  
Старый 02.12.2006, 20:41
ART ART вне форума
Продвинутый
 
Регистрация: 13.02.2006
Адрес: Магнитогорск
Сообщения: 669
Репутация: 14745
По умолчанию

//Должно работать

unit Unit1;

interface

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

type PixelData=record
Point:TPoint; //Координаты точки (целочислительные Point.x и Point.y )
Color:TColor; //Цвет точки
end;

type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
procedure GetMass(x1,y1,x2,y2:real;Canvas:TCanvas);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
Mass: array of PixelData; //Наш Массив
implementation

{$R *.dfm}


procedure TForm1.GetMass(x1,y1,x2,y2:real;Canvas:TCanvas);
var
k,m:real;
x,y:real;
i:integer;
begin
x:=x1;
SetLength(Mass,Abs(Round(x2-x1)));
for i:=1 to Abs(Round(x2-x1))-1 do begin
x:=x+1;
k:=(y1-y2)/(x1-x2);
m:=(x1*(y1-y2)+y1*(x2-x1))/(x1-x2);
y:=Round(k*x+m); //Уравнение прямой
//Заносим данные в массив
Mass[i].Point.X:=Round(x);
Mass[i].Point.y:=Round(y);
Mass[i].Color:=canvas.Pixels[Round(x),Round(y)];
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
GetMass(1,1,50,50,image1.Bitmap.Canvas);
end;
end.
Ответить с цитированием