|
void S_PicXZ(Graphics::TBitmap *Source,Graphics::TBitmap *NewPic,int angle)//
* ]9 z+ A0 g0 B* P. y4 j& c{
2 j6 g$ q" ?. L; Nif(angle>180)angle=360-angle;
( Q/ z0 _ H, T2 N+ \; gif(angle<-180)angle=360+angle; / ~& k) H" f" X! ?" s1 `
float radians=(2*3.1416*angle)/360; _$ P# E8 I, P7 n% _' O6 j/ ~: \
float cosine=(float)cos(radians); 6 n9 f, M% P# ^. x
float sine=(float)sin(radians);
` V" ` j3 `7 c _& Cfloat Point1x=(-Source->Height*sine); 1 i- P d, Z' K$ T, F* G R" ~
float Point1y=(Source->Height*cosine);
$ ~# u; f% @! s1 Y$ ?4 B+ Ufloat Point2x=(Source->Width*cosine-Source->Height*sine);
) n4 J; b5 o5 Ofloat Point2y=(Source->Height*cosine+Source->Width*sine);
+ F( l6 M! t2 W# n1 v6 Sfloat Point3x=(Source->Width*cosine); 3 y; v `. D% z
float Point3y=(Source->Width*sine); - P; j, y6 P r8 h9 Y; e# H
float minx=min((float)0,min(Point1x,min(Point2x,Point3x)));
$ Q% V2 r1 [1 U" P# r2 f. j, c! Qfloat miny=min((float)0,min(Point1y,min(Point2y,Point3y)));
$ C' d. n8 _- ]$ B1 c" {! I" s$ r! ifloat maxx=max(Point1x,max(Point2x,Point3x));
1 H* I* @% @* ^, z* c4 B- Xfloat maxy=max(Point1y,max(Point2y,Point3y));
/ i$ x9 ]6 z7 }4 Eint DestBitmapWidth,DestBitmapHeight;
! ^8 L3 t' s4 }, Z: k. V) j: Bif(angle>90&&angle<180) 3 ]9 c( F$ J; u$ n, ~3 S
DestBitmapWidth=(int)ceil(-minx);
( ^( ^! Q: ^7 D0 m& u; Gelse
) T5 V4 h, i" \; B, MDestBitmapWidth=(int)ceil(maxx-minx); J; N( n+ @* X! H7 D3 k- ]" ?
if(angle>-180&&angle<-90)
7 E; \# F+ W8 J0 ~+ d( p0 RDestBitmapHeight=(int)ceil(-miny);
3 t4 i; Q" a1 A8 telse ) {0 Z: V' J+ ]
DestBitmapHeight=(int)ceil(maxy-miny); 9 T9 T) v3 {/ H* N5 B/ Q7 s
NewPic->Height=DestBitmapHeight; 3 s8 t# L* c! E+ E, Q4 t
NewPic->Width=DestBitmapWidth;
% u! ?& B8 ?- p7 w# f8 o1 wfor(int x=0;x<DestBitmapWidth;x++) % d+ N6 {" m: }& m6 G
{ $ q- u& h: d9 o- N
for(int y=0;y<DestBitmapHeight;y++){ # l! K; B7 V" |3 g0 G5 _+ t% ?
int SrcBitmapx=(int)((x+minx)*cosine+(y+miny)*sine); ( A1 Z$ ^4 l& q
int SrcBitmapy=(int)((y+miny)*cosine-(x+minx)*sine);
8 L3 {) K' \) k! s7 N" L+ s# ~2 Bif(SrcBitmapx>=0&&SrcBitmapx<Source->Width&&SrcBitmapy>=0&& ; ]0 j; q* I. D; z2 S {
SrcBitmapy<Source->Height) 3 t3 T; \9 E8 K, x* r3 S
{ : |+ Q! p' J; }! l0 K3 v1 v+ l
NewPic->Canvas-> ixels[x][y]=
1 q' T. _1 i1 {Source->Canvas-> ixels[SrcBitmapx][SrcBitmapy]; \: T' c( t% V1 B3 V
} 2 _; g9 K0 F$ _0 s4 Q+ }
}
9 d1 k7 e4 a- Q$ q}
1 L, \' J0 u% w; z4 }$ P: f} |