1,

编译error的话一般是却

#include <comdef.h>
#include <Windows.h>

Windows.h内会包含Windows.h,但是因为在stdafx.h中会智能创建WIN32_LEAN_AND_MEAN宏,会屏蔽comdef.h,这样就会导致声明缺失问题。

删除WIN32_LEAN_AND_MEAN宏或者手动添加包含comdef.h头文件就可以了。

2,

#include <comdef.h>
#include <Windows.h> #include "GDIPlusB.h"
#include <gdiplus.h>
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( ,,);
COLORREF crDark = RGB( , , );
COLORREF crBright = RGB( ,,);
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 = ; //产生渐变的透明画刷
Color GdiClrDark(alpha,r,g,b) ;
Color GdiClrBright(alpha,r1,g1,b1) ; Gdiplus::Point pt_begin , pt_end ;
SetRect( &m_rc , , , + , + ) ;
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, ); 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, , );
graphics.ReleaseHDC( *phdc ) ; }
void CGDIPlusB::DrawGradientBrush( HDC* phdc )
{
COLORREF crBackClr = RGB( ,,);
COLORREF crDark = RGB( , , );
COLORREF crBright = RGB( ,,);
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 = ; //产生渐变的透明画刷
Color GdiClrDark(alpha,r,g,b) ;
Color GdiClrBright(alpha,r1,g1,b1) ; Gdiplus::Point pt_begin , pt_end ;
SetRect( &m_rc , , , + , + ) ;
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 , , , + , + ) ;
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(,,,),Color(,,,));
Color colors[] = {
Color(, , , ), // red
Color(, , , ), //yellow
Color(, , , ), // blue
Color(, , , )}; // green
REAL positions[] = {
0.0f,
0.33f,
0.66f,
1.0f};
linGrBrush.SetInterpolationColors(colors, positions,); 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+的更多相关文章

  1. 超全面的.NET GDI+图形图像编程教程

    本篇主题内容是.NET GDI+图形图像编程系列的教程,不要被这个滚动条吓到,为了查找方便,我没有分开写,上面加了目录了,而且很多都是源码和图片~ (*^_^*) 本人也为了学习深刻,另一方面也是为了 ...

  2. (转载)GDI+双缓冲

    双缓冲在GDI+里可以有效的提高描画效率.改善显示的质量. 下面的代码是一个最简单的双缓冲的模板.可以根据需要,做简单的修改即可. Bitmap CacheImage( [Width], [Heigh ...

  3. (转载)解决GDI闪烁

    一般的windows 复杂的界面需要使用多层窗口而且要用贴图来美化,所以不可避免在窗口移动或者改变大小的时候出现闪烁. 先来谈谈闪烁产生的原因 原因一:如果熟悉显卡原理的话,调用GDI函数向屏幕输出的 ...

  4. 通过GDI+绘制 验证码

    只为了记录下自己的学习历程,方便日后查看 现在开始言归正传,以下为其完整代码附上 using System; using System.Collections.Generic; using Syste ...

  5. 【VC++技术杂谈007】使用GDI+进行图片格式转换

    本文主要介绍如何使用GDI+对图片进行格式转换,可以转换的图片格式为bmp.jpg.png. 1.加载GDI+库 GDI+是GDI图形库的一个增强版本,提供了一系列Visual C++ API.为了使 ...

  6. C# GDI绘制矩形框,鼠标左键拖动可移动矩形框,滚轮放大缩小矩形框

    最近工作需要,要做一个矩形框,并且 用鼠标左键拖动矩形框移动其位置.网上查了一些感觉他们做的挺复杂的.我自己研究一天,做了一个比较简单的,发表出来供大家参考一下.如觉得简单,可路过,谢谢.哈哈. 先大 ...

  7. 【Windows编程】系列第五篇:GDI图形绘制

    上两篇我们学习了文本字符输出以及Unicode编写程序,知道如何用常见Win32输出文本字符串,这一篇我们来学习Windows编程中另一个非常重要的部分GDI图形绘图.Windows的GDI函数包含数 ...

  8. GDI+ 笔记

    1.GDI+模板 #include<windows.h> #include<GdiPlus.h> #include <time.h> #include <ma ...

  9. C# GDI+发生一般性错误(A generic error occurred in GDI+))

    解决思路: 1. 因为 .net GDI+ 是对底层 的封装. 所以可以尝试用 Marshal.GetLastWin32Error();函数获得底层错误代码. try{ image.Save(file ...

  10. GDI与GDI+ 贴图性能对比

    在做绘图相关工作,由于对显示绘制结果实时性有要求,筛选了GDI , 与GDI+ 贴图性能. 这里假设在内存中已绘制完成一张图片,现需求显示在控件上,同时,总是更新全部区域. GDI+ 实现 priva ...

随机推荐

  1. Codeforces Gym 100114 A. Hanoi tower 找规律

    A. Hanoi tower Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descript ...

  2. Nginx 1.4.7图片缓存服务器

    软件包版本: Nginx 1.4.7 Ngx_cache_purge-2.0 Openssl-1.0.1 Pcre-8.32 二.安装编译: a)         下载pcre-8.32.tar.gz ...

  3. day02 Java基础

    1.Java中的关键字都是小写的. 2.Java中的关键字 3.Java中的注释分为:单行注释.多行注释.文档注释 文档注释将被javadoc工具解析生成一个说明书. 4.Java中的常量分为字面值常 ...

  4. C语言的ANSI/ISO标准

    摘自:http://see.xidian.edu.cn/cpp/html/1658.html 从技术上讲有两种C语言标准,一种来自ANSI(American National Standard Ins ...

  5. 已知json类型根据类型封装集合

    1编写帮助类根绝url得到json public static string Post(string url) { string strURL = url; //创建一个HTTP请求 HttpWebR ...

  6. javascript 实现htmlEncode htmlDecode

    屌屌的写法..function htmlEncode(value){ //create a in-memory div, set it's inner text(which jQuery automa ...

  7. 动态缓存技术之CSI,SSI,ESI

    平常我们谈到网络缓存技术,大多是以页面为单位的,比如,新闻网站中将执行后的结果,缓存为一个静态html文件,下次访问时就直接访问这个静态页面了! 减轻了服务器压力!但是,如果一个页面大部分是可静态的, ...

  8. 琐碎-关于hadoop2.X那些端口

    此文转载http://www.aboutyun.com/thread-7513-1-1.html Hadoop集群的各部分一般都会使用到多个端口,有些是daemon之间进行交互之用,有些是用于RPC访 ...

  9. Tick and Tick

    The three hands of the clock are rotating every second and meeting each other many times everyday. F ...

  10. 两个数据库表同步的可视化WEB同步程序

    因业务升级,现有一个数据库中的表需要与先前项目中的表进行数据同步,停用先前的表,这两个表只能按其中相同的一个字段同步,认真研究了一下,用WEB程序进行了处理,可视化显示处理进度,同步操作结果.使用到的 ...