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. .net简单录音和播放音频文件代码

    本代码特点:不用DirectX ,对于C/S .B/S都适用. 方法: //mciSendStrin.是用来播放多媒体文件的API指令,可以播放MPEG,AVI,WAV,MP3,等等,下面介绍一下它的 ...

  2. 保存form配置信息INI

    (* 功能:IniFormState1 保存和读取 窗体的大小2 保存和读取 窗体在屏幕上的位置//让程序第1次出现在屏幕的中心点获取屏幕的中心点POSITION:poScreenCenter //不 ...

  3. TV

    https://github.com/Xs4allWebTV/androidhttps://github.com/mode89/video-feedhttp://www.javaapk.com/sou ...

  4. [Javascript] IO Functor

    IO functor doesn't like Maybe(), Either() functors. Instead of get a value, it takes a function. API ...

  5. 空间的配置和释放 std::alloc

    看完了对象的构造行为和内存释放前的对象的析构行为,我们现在来看看内存的配置和释放. 对象构造前的空间分配和析构后的空间释放,定义在头文件<stl_alloc.h>中.其设计思想是: 向sy ...

  6. Android基本控件之GridView

    我们在使用手机的过程中,会看到一些图片配上文字的一些情况,今天我们就来介绍一下安卓控件的GridView GridView组件用来以网格方式排列视图,与矩阵类似,当屏幕上有很多元素(文字.图片或其他元 ...

  7. cocos2d-x, protobuf, no config.h, #error "No suitable threading library available."

    在用cocos2d-x3.2 + protobuf编译Android项目的时候,protobuf出现了两个问题: 1. 首先是config.h找不到,查阅自后说是通过命令或工具生成的,里面的内容根据不 ...

  8. ASP.NET MVC and jqGrid 学习笔记 2-如何从本地获得数据

    上回说到jqgrid的基本配置,同时演示了显示数据的一种方法——datatype: "local".这种方法是从本地获取的,确切地说是在前端页面的javascript里写的硬编码. ...

  9. 计算 MD5值

    // // MD5Value.h // iOSEdu // // Created by littest on 16/2/26. // Copyright © 2016年 littest. All ri ...

  10. c编写程序完成m名旅客和n辆汽车的同步程序代写

    jurassic公园有一个恐龙博物馆和一个公园,有m名旅客和n辆汽车,每辆汽车仅能允许承载一名旅客.旅客在博物馆参观一阵,然后排队乘坐旅行车.当一辆车可用时,他载入一名旅客,再绕花园行驶任意长的时间. ...