|
void S_PicXZ(Graphics::TBitmap *Source,Graphics::TBitmap *NewPic,int angle)// / U6 k0 G: [3 ^
{ ) } S; c" x5 k. |
if(angle>180)angle=360-angle; - ]# V$ M9 K4 w8 p' g/ E; s/ r
if(angle<-180)angle=360+angle; 9 }7 ?! e' s, p! @
float radians=(2*3.1416*angle)/360; 6 P$ j4 b# v6 Z+ g+ t
float cosine=(float)cos(radians);
$ H% g* q& g; u! G4 l2 W/ t9 ofloat sine=(float)sin(radians);
6 z) y* W* B. a/ t- T. M( r) Ufloat Point1x=(-Source->Height*sine); , R% m% {( I- g* I
float Point1y=(Source->Height*cosine); 3 N7 B& ]$ L8 J9 S( m
float Point2x=(Source->Width*cosine-Source->Height*sine); C' d" p" Y q: I& |% L4 h
float Point2y=(Source->Height*cosine+Source->Width*sine);
- ]" C& J* z. ^1 }- ]6 tfloat Point3x=(Source->Width*cosine); * @0 H$ ]- f9 O4 J( r3 x; b' S% S
float Point3y=(Source->Width*sine); 9 M4 ~9 |# P2 N2 T% \2 M* r. H* L
float minx=min((float)0,min(Point1x,min(Point2x,Point3x)));
7 r1 C8 T4 y; V4 ?float miny=min((float)0,min(Point1y,min(Point2y,Point3y)));
% G) K8 G: c2 {2 pfloat maxx=max(Point1x,max(Point2x,Point3x));
# `+ V% g4 J- Ufloat maxy=max(Point1y,max(Point2y,Point3y));
" S! c& `# D0 a- A6 sint DestBitmapWidth,DestBitmapHeight;
4 u) I4 q6 Y7 i2 t% L. Lif(angle>90&&angle<180)
: h8 C, H D) gDestBitmapWidth=(int)ceil(-minx); . y) q/ R$ J0 F
else + G( O, a2 }8 u- ?" @7 g! w6 s
DestBitmapWidth=(int)ceil(maxx-minx); " q! g+ s; C* d2 T" g0 V( H
if(angle>-180&&angle<-90) 4 ]# v1 _+ y, z* s
DestBitmapHeight=(int)ceil(-miny); W# g. z9 M* Z, U9 z! o
else : h' D# h) u" b, r8 u$ ~
DestBitmapHeight=(int)ceil(maxy-miny);
# ^# c M" x0 DNewPic->Height=DestBitmapHeight;
: {' b0 z1 y8 Y3 yNewPic->Width=DestBitmapWidth;
7 N+ s8 v) i. Afor(int x=0;x<DestBitmapWidth;x++) & I$ Z- X& U" E/ i$ q: x# T1 t
{ ; u6 e# ?2 O, ^- E i6 ?3 O
for(int y=0;y<DestBitmapHeight;y++){
. X# C" X( I8 ]int SrcBitmapx=(int)((x+minx)*cosine+(y+miny)*sine);
% ^1 @- |3 b$ d% d0 M# r* ~int SrcBitmapy=(int)((y+miny)*cosine-(x+minx)*sine);
$ y, M' z+ f) \& n# aif(SrcBitmapx>=0&&SrcBitmapx<Source->Width&&SrcBitmapy>=0&& ' K ^6 P+ A" G3 e) |% t
SrcBitmapy<Source->Height)
b* G3 k8 y2 `' t" S2 \. [{ , e& e% Y- e2 V
NewPic->Canvas-> ixels[x][y]= 1 C. |$ p* Q4 \' y9 o4 D5 _! a
Source->Canvas-> ixels[SrcBitmapx][SrcBitmapy]; : I4 W* I* R( V& X, }
} 6 F" F' U7 t, Z( U3 h1 B
}
+ T8 H! |$ c/ ?3 {7 H6 o} 5 p" ^6 J" r" a) s
} |