implementation methods:
Using GDIPlus FillPie method, take each color piece when the pie charts,
void CRotateAnimation: : DrawPie (HDC HDC)
{
Gdiplus: : Graphics * pGraphics=new Gdiplus: : Graphics (hDC);
PGraphics - & gt; SetSmoothingMode (SmoothingModeHighQuality);
Gdiplus: : Color CLR,0,0,0 (150);
Gdiplus: : SolidBrush * pBrush=new Gdiplus: : SolidBrush (CLR);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//calculate outer ring, inner ring position
Gdiplus: : the Rect rcOut (m_Rect);
Gdiplus: : the Rect rcIn (rcOut);
RcIn. Inflate (- m_ItemSize - m_ItemSize);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//to draw the first outer small squares
Float fStartAngle=- 90;//start drawing Angle
Float fSweepAngle=360/m_AnimationCount;//every small Angle
for(int i=0; I{
The CLR. SetFromCOLORREF (m_pAnimationArray [I] clrOut);
PBrush - & gt; SetColor (CLR);
PGraphics - & gt; FillPie (pBrush, rcOut fStartAngle, fSweepAngle - m_MarginAngle);
FStartAngle=fStartAngle + fSweepAngle;
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//draw the inner circle of small square;
FStartAngle=90;
for(int i=0; I{
The CLR. SetFromCOLORREF (m_pAnimationArray [I] clrIn);
PBrush - & gt; SetColor (CLR);
PGraphics - & gt; FillPie (pBrush, rcIn, fStartAngle fSweepAngle - m_MarginAngle);
FStartAngle=fStartAngle + fSweepAngle;
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//draw the middle circle, use color control filling
RcIn. Inflate (- m_ItemSize - m_ItemSize);
The CLR. SetFromCOLORREF (m_ColorBack);
PBrush - & gt; SetColor (CLR);
PGraphics - & gt; FillEllipse (pBrush, rcIn);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The delete pBrush;
The delete pGraphics;
}
source download
http://blog.csdn.net/cometnet/article/details/53363596
CodePudding user response:
Support, mental commendableCodePudding user response:
Mark the goodCodePudding user response:
Support the open source!!!!!!CodePudding user response:
Open source:# include & lt; Math. H>
# include & lt; String. H>
# include & lt; stdio.h>
# include & lt; Windows. H>
# include & lt; Gdiplus. H>
# pragma comment (lib, "gdiplus. Lib")
Using the namespace Gdiplus;
Would be formats [5] [11]={
L "image/BMP,"
L "image/jpeg",
L "image/GIF",
L "image/tiff,"
L "image/PNG,"
};
Would be exts [5] [5]={
L ". BMP, "
L "JPG",
L ". GIF ",
L ". Tif, "
L "PNG",
};
Int GetEncoderClsid (const WCHAR * format, clsids * pClsid) {
UINT num=0;//number of image encoders
UINT size=0;//the size of the image encoder array in bytes
ImageCodecInfo * pImageCodecInfo=NULL;
GetImageEncodersSize (& amp; Num, & amp; The size);
If (size==0) return 1;//Failure
PImageCodecInfo=(ImageCodecInfo *) (malloc (size));
If (pImageCodecInfo==NULL) return 1;//Failure
GetImageEncoders (num, size, pImageCodecInfo);
For (UINT j=0; J & lt; Num. + + j) {
If (WCSCMP (pImageCodecInfo [j]. Journal of MimeType, format)==0) {
* pClsid=pImageCodecInfo [j]. Journal of clsids;
Free (pImageCodecInfo);
Return j;//Success
}
}
Free (pImageCodecInfo);
return -1;//Failure
}
Int wmain (int arg c, would be * argv []) {
Int r=1;
If (argc<4) {
USAGE:
Srcimg wprintf (L "% s. {BMP | JPG | | GIF tif | PNG | WMF | emf | ico} desimg. {BMP | JPG | | GIF tif | PNG} Angle \ n", argv [0]).
return r;
}
int i;
for (i=0; I<5; I++) {
If (0==_wcsicmp (argv [1] + wcslen (argv [1]) - 4, exts [I])) break;
}
If (i>=5) goto the USAGE;
for (i=0; I<5; I++) {
If (0==_wcsicmp (argv [2] + wcslen (argv [2]) - 4, exts [I])) break;
}
If (i>=5) goto the USAGE;
The GdiplusStartupInput GdiplusStartupInput;
ULONG_PTR gdiplustoken;
GdiplusStartup (& amp; Gdiplustoken, & amp; Gdiplusstartupinput, NULL);
{
The Image of img (argv [1]);
If (Ok==img. GetLastStatus ()) {
UINT height=img. GetHeight ();
UINT width=img. GetWidth ();
The REAL Angle;
If (1==swscanf_s (argv [3], L "% f", & amp; Angle)) {
REAL size.
Size=(REAL) SQRT (1.0 * width * height width + 1.0 * * height);
Matrix mat;
Mat. Translate (size/2.0 f, size/2.0 f);
Mat. Rotate (- Angle, MatrixOrderAppend);
Mat. Translate (size/2.0 f, size/2.0 f, MatrixOrderAppend);
PointF pfTL (/2.0 f (size - the width), (f) 2.0/size - height);
PointF pfTR ((f + width 2.0/size - the width), (f) 2.0/size - height);
PointF pfBL ((size - the width) f/2.0, (the size - height)/2.0 f + height);
PointF pfBR ((size - the width)/2.0 f + width, (size - height)/2.0 f + height);
Graphics TGP (& amp; Img);
Bitmap BMP ((UINT) size, (UINT) size, & amp; The TGP);//Let BMP Resolution equal to img Resolution
Graphics gp (& amp; BMP);
Gp. SetTransform (& amp; Mat);
Gp. DrawImage (& amp; Img, pfTL);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull