|
void S_PicXZ(Graphics::TBitmap *Source,Graphics::TBitmap *NewPic,int angle)//
, s8 w( r2 ?' Q" m( W0 r! i{ ' d, h* u5 Z4 }0 ?0 j
if(angle>180)angle=360-angle; 8 D- [' U3 W7 G/ l/ Z# p) L
if(angle<-180)angle=360+angle;
$ p( _% S5 n9 i* G- z( Tfloat radians=(2*3.1416*angle)/360;
# H% ]1 l8 O2 X. N$ \) e: h0 i y- E# Mfloat cosine=(float)cos(radians); ( M; v5 [/ R( D4 U; k1 N" U
float sine=(float)sin(radians); # h2 D: |% [. a8 q& p( F
float Point1x=(-Source->Height*sine);
2 R6 m' h# }+ D4 T* D- Afloat Point1y=(Source->Height*cosine);
4 P) {3 P) Y; Sfloat Point2x=(Source->Width*cosine-Source->Height*sine); * P- {$ f2 l6 f) t* v4 n3 Z* H
float Point2y=(Source->Height*cosine+Source->Width*sine);
7 ~9 c: k7 s* c1 ]; C# zfloat Point3x=(Source->Width*cosine); $ O0 `7 v7 ^5 y @1 R0 v$ j" Y
float Point3y=(Source->Width*sine);
2 `& X- \/ Y& G' g# zfloat minx=min((float)0,min(Point1x,min(Point2x,Point3x)));
7 \/ L" S6 p7 nfloat miny=min((float)0,min(Point1y,min(Point2y,Point3y)));
( d2 y! M) n m$ ?7 h, t/ t4 Tfloat maxx=max(Point1x,max(Point2x,Point3x));
0 _/ J G/ z6 afloat maxy=max(Point1y,max(Point2y,Point3y));
% g* Q7 k4 y6 n8 W1 uint DestBitmapWidth,DestBitmapHeight;
0 U, D) s/ u+ F3 F' c( I2 Mif(angle>90&&angle<180) 5 `0 h3 G% R9 T; E9 h
DestBitmapWidth=(int)ceil(-minx); ! G% x/ R# d% _- b9 @
else & X: x4 ?8 G, } y7 _% T6 G' u
DestBitmapWidth=(int)ceil(maxx-minx); - X0 i* k R0 Y2 @& D) b1 ]
if(angle>-180&&angle<-90) : E+ t2 B* C: `$ N$ a, j) S
DestBitmapHeight=(int)ceil(-miny);
2 h( f8 U( J+ }! w8 F B. q" m& Delse , V7 o4 u! D" c. S7 [9 k
DestBitmapHeight=(int)ceil(maxy-miny);
1 G$ h4 h( w' C1 B) N+ kNewPic->Height=DestBitmapHeight; 6 @/ j0 x" A! N9 M1 q8 E2 x
NewPic->Width=DestBitmapWidth;
2 W" E4 [, {- Xfor(int x=0;x<DestBitmapWidth;x++) 1 O; }6 r* A0 I: R! g
{ 7 |9 u4 Y, `, ]) L! ]5 l4 K) x
for(int y=0;y<DestBitmapHeight;y++){
- I5 g |8 e( p8 y6 Kint SrcBitmapx=(int)((x+minx)*cosine+(y+miny)*sine);
' R2 ~- l3 i" aint SrcBitmapy=(int)((y+miny)*cosine-(x+minx)*sine);
. f0 K* \4 |/ ^) y3 `; jif(SrcBitmapx>=0&&SrcBitmapx<Source->Width&&SrcBitmapy>=0&&
. d" ?" o! Y+ K, ]% {: LSrcBitmapy<Source->Height)
( w; p' U% C {{
N8 @, q- ~5 x+ WNewPic->Canvas-> ixels[x][y]= ) e a8 a4 ^; H6 L7 A' n
Source->Canvas-> ixels[SrcBitmapx][SrcBitmapy];
5 S+ l3 X* ^- ]* ?3 z3 Z5 h} # U. O. E0 f. \. M. [' S+ C
}
( p' z! l W# [" G6 i4 g} 7 k( W& P3 l- E7 b1 [, u; ~0 B
} |