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 100571A A. Cursed Query 离线

    A. Cursed QueryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100571/problem ...

  2. C#三种模拟自动登录和提交POST信息的实现方法

    网页自动登录(提交Post内容)的用途很多,如验证身份.程序升级.网络投票等,以下是用C#实现的方法.       网页自动登录和提交POST信息的核心就是分析网页的源代码(HTML),在C#中,可以 ...

  3. Android Socket编程学习笔记

    http://blog.csdn.net/eyu8874521/article/details/8847173 度娘给出的描述:通常也称作"套接字",用于描述IP地址和端口,是一个 ...

  4. ElasticSearch使用

    安装之前,请参考https://github.com/richardwilly98/elasticsearch-river-mongodb根据你的MongoDB版本号决定需要的elasticsearc ...

  5. 一个坐标点围绕任意中心点旋转--C#实现

    假设对图片上任意点(x,y),绕一个坐标点(rx0,ry0)逆时针旋转RotaryAngle角度后的新的坐标设为(x', y'),有公式: x'= (x - rx0)*cos(RotaryAngle) ...

  6. windows下的python扩展包下载地址

    比如lxml什么的 Unofficial Windows Binaries for Python Extension Packages pip install xxx.whl

  7. 配置phpmyadmin使登录时可填写IP管理多台MySQL 连接多个数据库 自动登录

    一.如何设置phpMyAdmin自动登录? 首先在根目录找到config.sample.inc.php复制一份文件名改为config.inc.php(如果已经存在 config.inc.php 文件, ...

  8. c#_错误处理_基础

    attribute: using System; using System.Collections.Generic; using System.Linq; using System.Web; usin ...

  9. 用联想wndows8系统做android调试开发,adb server无法启动的原因

    今天换了台笔记本,联想V480的,装好开发软件,配置好一环境,于是打算先试一下能不能用,结果在eclipse devices中死活看不到设备,于是开如找各种问题,最后在度娘的帮助下终于找到了答案,我的 ...

  10. Windows 7中使用Eclipse 使用CDT and WinGW 开发C/C++(转载)

    以前使用visual studio 2010编写C/C++,后来接触了Eclipse后,据说eclipse也可以编写C/C++,以前觉得Visual studio 2010还蛮不错的,也没有多大好奇心 ...