|
void S_PicXZ(Graphics::TBitmap *Source,Graphics::TBitmap *NewPic,int angle)// * m" t" y8 f/ s6 Y
{
" i' e! x) o1 x& G- b# Uif(angle>180)angle=360-angle; 3 @, j8 ^! y; S2 b* J
if(angle<-180)angle=360+angle; $ s+ t! T9 U) b
float radians=(2*3.1416*angle)/360;
: x5 h2 x8 p1 W8 @/ |( V; Vfloat cosine=(float)cos(radians); ' `& \; P; f% D0 ]) v: F8 `4 [
float sine=(float)sin(radians); ) ]$ h/ p1 l6 [1 O
float Point1x=(-Source->Height*sine);
" |; T: W, h1 E1 afloat Point1y=(Source->Height*cosine);
- q+ y0 `+ q% M8 vfloat Point2x=(Source->Width*cosine-Source->Height*sine); : o/ \9 _9 d! t9 X7 I
float Point2y=(Source->Height*cosine+Source->Width*sine); d0 w+ j1 p2 O) h
float Point3x=(Source->Width*cosine); , S9 `) _# ?* Z9 D3 B4 o4 X
float Point3y=(Source->Width*sine);
+ Q2 c) L* z/ b2 d) rfloat minx=min((float)0,min(Point1x,min(Point2x,Point3x))); C1 D& n5 c# b
float miny=min((float)0,min(Point1y,min(Point2y,Point3y)));
1 p& z- i: R3 ]" @float maxx=max(Point1x,max(Point2x,Point3x));
$ X) |. {0 L# H; u* `+ X7 w/ ofloat maxy=max(Point1y,max(Point2y,Point3y)); . S6 J( h) L3 C) o; P
int DestBitmapWidth,DestBitmapHeight;
. w V; A5 Y+ g- v P; |8 qif(angle>90&&angle<180)
/ e$ Q& z# _& l3 B# oDestBitmapWidth=(int)ceil(-minx); 2 H" o' Y* j( A1 x i; E
else 3 d! D- u4 b2 i; }; D( M, Y
DestBitmapWidth=(int)ceil(maxx-minx);
6 o! i, F" M) `2 Y# j2 V+ Y# N0 Wif(angle>-180&&angle<-90) / i* m% o; c4 v4 I
DestBitmapHeight=(int)ceil(-miny);
* D& Z, J2 V: E& } eelse : d4 x7 Q3 N0 a9 o2 ^! W
DestBitmapHeight=(int)ceil(maxy-miny); 0 m( F4 J: d/ i& i
NewPic->Height=DestBitmapHeight; 5 l; O7 i4 P# M* _. R6 q
NewPic->Width=DestBitmapWidth;
. [( k& x0 r0 v3 H3 i: R: I# [for(int x=0;x<DestBitmapWidth;x++) ; Y x' x; U: Z& {/ Y$ j2 Y% k
{ * B0 t( H# w& x# o5 ~" B* K
for(int y=0;y<DestBitmapHeight;y++){
; R8 f7 A8 Y( {/ K! cint SrcBitmapx=(int)((x+minx)*cosine+(y+miny)*sine);
( ^7 I2 n$ K' [( ~* z! qint SrcBitmapy=(int)((y+miny)*cosine-(x+minx)*sine);
; ?' k: e- d% Y3 E- H: kif(SrcBitmapx>=0&&SrcBitmapx<Source->Width&&SrcBitmapy>=0&& 3 H s E+ p+ W |7 L% V9 l
SrcBitmapy<Source->Height) ' S4 h. q e/ ^
{ . A6 ]. Y0 i% R3 _
NewPic->Canvas-> ixels[x][y]=
/ b, u* b+ J( z. DSource->Canvas-> ixels[SrcBitmapx][SrcBitmapy]; 3 H& ]5 c" M/ y" A. z
} & g1 C4 `. Z# S- `8 e
} * x2 p" ?8 q4 O3 \- w
} 0 H( O/ ]9 A# J- {5 ]4 T$ V" G
} |