Thursday, February 4, 2010
Computer Graphics:translate with degree
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include<math.h>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
int i,j;
int ht=Image1->Height;
int wt=Image1->Width;
int theta=StrToInt(Edit1->Text);
int radius=StrToInt(Edit2->Text);
for(i=0;i<wt;i++)
{
for(j=0;j<ht;j++)
{
Image2->Canvas->Pixels[i*cos(theta)-j*sin(theta)][i*sin(theta)+j*cos(theta)]=Image1->Canvas->Pixels[i][j];
}
}
}
//---------------------------------------------------------------------------
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment