Recent Posts

Selamat datang di Coding Delphi Land Weblog kumpulan source code pemogram delphi

(Bukan maksud untuk menggurui tetapi marilah kita berbagi ilmu tuk perkembangan kemajuan teknologi kita

Selasa, 17 November 2009

Rotate Pixel

unit ScreenPixels;

interface

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

type
TFormRotateBitmap = class(TForm)
ImageFrom: TImage;
ImageTo: TImage;
SpeedButton0: TSpeedButton;
SpeedButton90: TSpeedButton;
SpeedButton180: TSpeedButton;
SpeedButton270: TSpeedButton;

procedure SpeedButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FormRotateBitmap: TFormRotateBitmap;

implementation
{$R *.DFM}

procedure TFormRotateBitmap.SpeedButtonClick(Sender: TObject);
VAR
i: INTEGER;
j: INTEGER;
begin

WITH ImageFrom.Canvas.ClipRect DO
BEGIN
FOR i := Left TO Right DO
BEGIN

FOR j := Top TO Bottom DO
BEGIN
CASE (Sender AS TSpeedButton).Tag OF
0: ImageTo.Canvas.Pixels[i,j] :=
ImageFrom.Canvas.Pixels[i,j];

90: ImageTo.Canvas.Pixels[j,Right-i-1] :=
ImageFrom.Canvas.Pixels[i,j];

180: ImageTo.Canvas.Pixels[Right-i-1,Bottom-j-1] :=
ImageFrom.Canvas.Pixels[i,j];

270: ImageTo.Canvas.Pixels[Bottom-j-1,i] :=
ImageFrom.Canvas.Pixels[i,j]
END
END
END
END
end;

end.

0 komentar:

Posting Komentar