GDI+-创新互联
1,
10年的云南网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。网络营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整云南建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联从事“云南网站设计”,“云南网站推广”以来,每个客户项目都认真落实执行。编译error的话一般是却
#include
#include
Windows.h内会包含Windows.h,但是因为在stdafx.h中会智能创建WIN32_LEAN_AND_MEAN宏,会屏蔽comdef.h,这样就会导致声明缺失问题。
删除WIN32_LEAN_AND_MEAN宏或者手动添加包含comdef.h头文件就可以了。
2,
#include
#include
#include"GDIPlusB.h"
#include
using namespace Gdiplus;
#pragma comment(lib,"gdiplus.lib")
void CGDIPlusB::InitInstance()
{
//GDI+的初始化
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken , &gdiplusStartupInput, NULL);
}
void CGDIPlusB::UnInstance()
{
//关闭GDI+
Gdiplus::GdiplusShutdown(m_gdiplusToken);
}
3,
void CGDIPlusB::DrawAlphaPen( HDC* phdc )
{
COLORREF crBackClr= RGB( 0,0,255);
COLORREF crDark= RGB( 0 , 255 , 0 );
COLORREF crBright= RGB( 255,255,255);
Color GdiClrD,GdiClrB;//用于产生渐变效果; GdiClrD.SetFromCOLORREF(crDark);
GdiClrB.SetFromCOLORREF(crBright);
int r,g,b,r1,g1,b1;//分别得到明色和暗色的R G B值 r = GdiClrD.GetRed();
g= GdiClrD.GetGreen();
b= GdiClrD.GetBlue();
r1= GdiClrB.GetRed();
g1= GdiClrB.GetGreen();
b1= GdiClrB.GetBlue();
int alpha =220 ;
//产生渐变的透明画刷 Color GdiClrDark(alpha,r,g,b) ;
Color GdiClrBright(alpha,r1,g1,b1) ;
Gdiplus::Point pt_begin , pt_end ;
SetRect(&m_rc , 200 ,200 , 200+260 , 200+149 ) ;
pt_begin.X= m_rc.left ;
pt_begin.Y= m_rc.top ;
pt_end.X= m_rc.right ;
pt_end.Y= m_rc.bottom ;
LinearGradientBrush linGrBrush( pt_begin , pt_end , GdiClrDark,GdiClrBright );
Pen pen0(&linGrBrush,16 );
Graphics graphics(*phdc );
graphics.DrawLine(&pen0 , pt_begin , pt_end ) ;
graphics.ReleaseHDC(*phdc ) ;
}
void CGDIPlusB::DrawImage( HDC* phdc )
{
TCHAR img[MAX_PATH];
_stprintf( img,_T("E:\liuhanGit\liuhan_memUI\memUI\memUI_SKIN\p6.png")) ;
Image image( img );
Graphics graphics(*phdc );
graphics.DrawImage(&image, 200,400 );
graphics.ReleaseHDC(*phdc ) ;
}
void CGDIPlusB::DrawGradientBrush( HDC* phdc )
{
COLORREF crBackClr= RGB( 0,0,255);
COLORREF crDark= RGB( 0 , 255 , 0 );
COLORREF crBright= RGB( 255,255,255);
Color GdiClrD,GdiClrB;//用于产生渐变效果; GdiClrD.SetFromCOLORREF(crDark);
GdiClrB.SetFromCOLORREF(crBright);
int r,g,b,r1,g1,b1;//分别得到明色和暗色的R G B值 r = GdiClrD.GetRed();
g= GdiClrD.GetGreen();
b= GdiClrD.GetBlue();
r1= GdiClrB.GetRed();
g1= GdiClrB.GetGreen();
b1= GdiClrB.GetBlue();
int alpha =220 ;
//产生渐变的透明画刷 Color GdiClrDark(alpha,r,g,b) ;
Color GdiClrBright(alpha,r1,g1,b1) ;
Gdiplus::Point pt_begin , pt_end ;
SetRect(&m_rc , 500 ,200 , 500+260 , 200+149 ) ;
pt_begin.X= m_rc.left ;
pt_begin.Y= m_rc.top ;
pt_end.X= m_rc.right ;
pt_end.Y= m_rc.bottom ;
Brush* bsh0 = new LinearGradientBrush( pt_begin , pt_end , GdiClrDark,GdiClrBright ) ;
Graphics graphics(*phdc );
graphics.FillRectangle( bsh0 , m_rc.left , m_rc.top , m_rc.right- m_rc.left , m_rc.bottom - m_rc.top ) ;
delete bsh0 ;
graphics.ReleaseHDC(*phdc ) ;
}
void CGDIPlusB::DrawGradientBrush2( HDC* phdc )
{
Gdiplus::Point pt_begin , pt_end ;
SetRect(&m_rc , 500 ,400 , 500+260 , 400+149 ) ;
pt_begin.X= m_rc.left ;
pt_begin.Y= m_rc.top ;
pt_end.X= m_rc.right ;
pt_end.Y= m_rc.bottom ;
LinearGradientBrush linGrBrush( pt_begin , pt_end ,Color(255,255,0,0),Color(255,0,0,255));
Color colors[]= {
Color(255, 255, 0, 0), // red Color(255, 255, 255, 0), //yellow Color(255, 0, 0, 255), // blue Color(255, 0, 255, 0)};// green REAL positions[] = {
0.0f,
0.33f,
0.66f,
1.0f};
linGrBrush.SetInterpolationColors(colors, positions,4);
Graphics graphics(*phdc );
graphics.FillRectangle(&linGrBrush , m_rc.left , m_rc.top , m_rc.right - m_rc.left , m_rc.bottom - m_rc.top ) ;
graphics.ReleaseHDC(*phdc ) ;
}
分享名称:GDI+-创新互联
本文URL:http://myzitong.com/article/dspjod.html