Working with ScanLine / Home



...

Type
      TRGB=Record
            B, G, R: Byte;
            End;
      ARGB=Array [0..0] Of TRGB;
      PARGB=^ARGB;

Var Form1: TForm1; MyBmp: TBitmap; i: Byte=0;

...

Procedure TForm1.FormCreate(Sender: TObject);
Begin
MyBmp:=TBitmap.Create;
MyBmp.PixelFormat:=pf24bit;
MyBmp.Width:=Form1.Width;
MyBmp.Height:=Form1.Height;
Timer1.Interval:=50;
End;

Procedure Draw;
Var LinePointer: PARGB; a, b: Real; x, y: Integer;
Begin
For y:=0 To (MyBmp.Height-1) Do
      Begin
      LinePointer:=MyBmp.ScanLine[y];
      For x:=0 To (MyBmp.Width-1) Do
            Begin
            // Генерирование изображения попиксельно... Например такое:
            a:=x*x+i;
            b:=y*y+i;
            LinePointer[x].R:=Trunc(Abs(b));
            LinePointer[x].G:=Trunc(Abs(a+b));
            LinePointer[x].B:=Trunc(Abs(a));
            // Можете поэкспериментировать ;)
            End;
      End;
BitBlt(Form1.Canvas.Handle, 0, 0, Form1.ClientWidth, Form1.ClientHeight, MyBmp.Canvas.Handle, 0, 0, SRCCOPY);
End;

Procedure TForm1.FormDestroy(Sender: TObject);
Begin
MyBmp.Free;
End;

Procedure TForm1.Timer1Timer(Sender: TObject);
Begin
Draw;
Inc(i);
End;

...


Вариант 1 - Скомпилированный файл
Вариант 2 - С небольшой оптимизацией
Вариант 3 - С небольшой оптимизацией + Сложная формула + Пиксилизация



Hosted by uCoz