|
void S_PicXZ(Graphics::TBitmap *Source,Graphics::TBitmap *NewPic,int angle)//
$ ^/ |, t L8 w/ i2 u* l7 t E1 U{ $ o$ G+ A6 x. z- ?. d6 v/ R/ C
if(angle>180)angle=360-angle; 7 I+ t. @# h! f; p7 P! p7 {
if(angle<-180)angle=360+angle;
) S4 b0 Z# }7 b/ c( w6 Y* Pfloat radians=(2*3.1416*angle)/360;
+ }3 l3 M/ B( Q4 G; [3 vfloat cosine=(float)cos(radians); 2 w! Y4 z0 W) J0 @& ?; a$ \2 u# k
float sine=(float)sin(radians); 4 Y# p# A g- u6 A1 M- J: \; e
float Point1x=(-Source->Height*sine);
" o) X! @& r$ A$ Y9 Tfloat Point1y=(Source->Height*cosine); 1 P/ o% R. v* R2 M
float Point2x=(Source->Width*cosine-Source->Height*sine);
+ o6 z. @2 {! Yfloat Point2y=(Source->Height*cosine+Source->Width*sine); - y: w, q- o/ z8 [7 r6 c4 @
float Point3x=(Source->Width*cosine);
1 I( X& \5 S7 ?+ Q" \! r3 h' yfloat Point3y=(Source->Width*sine); - R Q( w; w0 V
float minx=min((float)0,min(Point1x,min(Point2x,Point3x)));
- c0 `0 E7 N& l8 R. a* Hfloat miny=min((float)0,min(Point1y,min(Point2y,Point3y)));
1 w2 A* `* S7 z) V4 Dfloat maxx=max(Point1x,max(Point2x,Point3x)); 4 b2 j# y+ K( @' c K! }" h! l
float maxy=max(Point1y,max(Point2y,Point3y)); ; @- ]$ y: D+ I& O( u
int DestBitmapWidth,DestBitmapHeight;
0 Y! o" I8 T/ n7 |2 t: ^# n9 rif(angle>90&&angle<180) 0 o: ?7 S: c& y/ r5 b
DestBitmapWidth=(int)ceil(-minx); : S. k4 d- w! g+ V
else 3 y; ?0 ~1 ` I
DestBitmapWidth=(int)ceil(maxx-minx); $ N4 k- |; w# q, C1 D% i. i. S2 ]
if(angle>-180&&angle<-90) % H8 H' r+ h$ I& B: @% s
DestBitmapHeight=(int)ceil(-miny); ( c" Y% m1 I( r; e$ e9 ]+ f
else 2 v- t8 W6 y9 B+ O; R
DestBitmapHeight=(int)ceil(maxy-miny);
1 f2 M0 F" W) X4 R5 w& M) dNewPic->Height=DestBitmapHeight;
5 `9 p+ W& C! C; P' `4 v R) SNewPic->Width=DestBitmapWidth;
# h |. {/ i! ^/ ]5 _for(int x=0;x<DestBitmapWidth;x++)
$ o- f$ ~: T, M) `( \$ S* D& \{ . ?, ` h) Y j# f! e5 g; v
for(int y=0;y<DestBitmapHeight;y++){ 4 T' b" I2 Q; P; s; d7 f
int SrcBitmapx=(int)((x+minx)*cosine+(y+miny)*sine);
4 q) E! z6 c. o. h) x$ |+ v! pint SrcBitmapy=(int)((y+miny)*cosine-(x+minx)*sine); 7 L5 n$ P4 W$ s3 g, b, P
if(SrcBitmapx>=0&&SrcBitmapx<Source->Width&&SrcBitmapy>=0&& & [5 e+ S6 f0 u6 F
SrcBitmapy<Source->Height)
/ G+ j; K/ c2 S9 {{ * m& Y* N1 i- z' ?7 t
NewPic->Canvas-> ixels[x][y]= 1 h, `% v; s' B+ i
Source->Canvas-> ixels[SrcBitmapx][SrcBitmapy]; % Q" l" X. l0 a- H
}
! w+ k$ Y/ B' i( X5 C, K} ! m/ W, Z4 Z3 B, N
}
: W" n' E, V& S( J1 A) m; |/ q} |