|
void S_PicXZ(Graphics::TBitmap *Source,Graphics::TBitmap *NewPic,int angle)//
+ l6 L; B4 ^" j0 [. _{ 7 K7 W- M( S2 P
if(angle>180)angle=360-angle;
% O/ Q& [" |3 `5 ~' J) M% J' iif(angle<-180)angle=360+angle; 4 }5 @) D* n5 c; w
float radians=(2*3.1416*angle)/360; & s: r, {( k$ N0 T
float cosine=(float)cos(radians);
' U& V* F7 e2 }1 \5 C1 ]/ ifloat sine=(float)sin(radians); " b: ]1 W! @2 { h$ Z
float Point1x=(-Source->Height*sine);
3 b1 J( _) o& }7 l% o4 s3 k9 ~float Point1y=(Source->Height*cosine);
$ w8 E( G+ y- {0 D4 |% {; tfloat Point2x=(Source->Width*cosine-Source->Height*sine);
! B) A1 o6 d" \" k( Afloat Point2y=(Source->Height*cosine+Source->Width*sine);
V/ T P! Y( g- u3 Q6 m6 Q, z1 o dfloat Point3x=(Source->Width*cosine);
1 X8 A0 T7 f/ p/ a- z2 v$ dfloat Point3y=(Source->Width*sine);
! C, n' h1 o) S. a2 V9 i9 I( Nfloat minx=min((float)0,min(Point1x,min(Point2x,Point3x))); 8 ~# f4 L; o; Y1 v: S$ D2 H5 T
float miny=min((float)0,min(Point1y,min(Point2y,Point3y)));
+ F4 l3 r4 y9 r, P5 D5 Ffloat maxx=max(Point1x,max(Point2x,Point3x));
) F9 F& ]+ n# h5 _2 Ifloat maxy=max(Point1y,max(Point2y,Point3y));
6 T, K' b: }! R. lint DestBitmapWidth,DestBitmapHeight; 4 ?" L) h/ W! X1 v5 s0 C$ p
if(angle>90&&angle<180) 1 J7 i: C- F: Z! t8 Q. ]& t) y/ _ F
DestBitmapWidth=(int)ceil(-minx);
5 g2 {$ `. W. A7 c& ]else 5 V/ O/ C+ b# ?' K, t" H2 J
DestBitmapWidth=(int)ceil(maxx-minx); ! c; y8 t6 D' f
if(angle>-180&&angle<-90) 3 c; x1 d: ?* r" p; s3 Z
DestBitmapHeight=(int)ceil(-miny); 3 W5 s5 @% r% ]) a4 d( M
else
( U. Y6 n' P2 R6 aDestBitmapHeight=(int)ceil(maxy-miny);
+ R7 D8 d. |: G: ONewPic->Height=DestBitmapHeight; - T" @ @0 J& L
NewPic->Width=DestBitmapWidth;
/ N8 W3 ~; i- i0 R8 D8 f* r% ]1 z! `for(int x=0;x<DestBitmapWidth;x++) 2 ?6 s1 o! [+ Q+ O% D+ U9 |' t% F
{
3 }$ A1 |7 q9 G2 d. Mfor(int y=0;y<DestBitmapHeight;y++){
3 q7 X/ _. V4 _2 t1 h7 b3 cint SrcBitmapx=(int)((x+minx)*cosine+(y+miny)*sine); 7 D9 w& L& |9 `( _
int SrcBitmapy=(int)((y+miny)*cosine-(x+minx)*sine); ! e$ _& e& h' C: T7 W
if(SrcBitmapx>=0&&SrcBitmapx<Source->Width&&SrcBitmapy>=0&& . s, y, G$ h; V
SrcBitmapy<Source->Height)
; R7 Q6 E+ f1 y( s2 B2 b) F* X{
- F" P# b( H& A! \NewPic->Canvas-> ixels[x][y]=
, v7 l/ a3 d9 L6 c4 FSource->Canvas-> ixels[SrcBitmapx][SrcBitmapy];
9 s z2 Y& {- T& Y8 p}
; h: H+ \' A/ M0 m$ r}
1 t8 U2 j) {% g0 |6 e} 3 W5 a' b( C- O. ^7 t
} |