GDI+
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+的更多相关文章
- 超全面的.NET GDI+图形图像编程教程
本篇主题内容是.NET GDI+图形图像编程系列的教程,不要被这个滚动条吓到,为了查找方便,我没有分开写,上面加了目录了,而且很多都是源码和图片~ (*^_^*) 本人也为了学习深刻,另一方面也是为了 ...
- (转载)GDI+双缓冲
双缓冲在GDI+里可以有效的提高描画效率.改善显示的质量. 下面的代码是一个最简单的双缓冲的模板.可以根据需要,做简单的修改即可. Bitmap CacheImage( [Width], [Heigh ...
- (转载)解决GDI闪烁
一般的windows 复杂的界面需要使用多层窗口而且要用贴图来美化,所以不可避免在窗口移动或者改变大小的时候出现闪烁. 先来谈谈闪烁产生的原因 原因一:如果熟悉显卡原理的话,调用GDI函数向屏幕输出的 ...
- 通过GDI+绘制 验证码
只为了记录下自己的学习历程,方便日后查看 现在开始言归正传,以下为其完整代码附上 using System; using System.Collections.Generic; using Syste ...
- 【VC++技术杂谈007】使用GDI+进行图片格式转换
本文主要介绍如何使用GDI+对图片进行格式转换,可以转换的图片格式为bmp.jpg.png. 1.加载GDI+库 GDI+是GDI图形库的一个增强版本,提供了一系列Visual C++ API.为了使 ...
- C# GDI绘制矩形框,鼠标左键拖动可移动矩形框,滚轮放大缩小矩形框
最近工作需要,要做一个矩形框,并且 用鼠标左键拖动矩形框移动其位置.网上查了一些感觉他们做的挺复杂的.我自己研究一天,做了一个比较简单的,发表出来供大家参考一下.如觉得简单,可路过,谢谢.哈哈. 先大 ...
- 【Windows编程】系列第五篇:GDI图形绘制
上两篇我们学习了文本字符输出以及Unicode编写程序,知道如何用常见Win32输出文本字符串,这一篇我们来学习Windows编程中另一个非常重要的部分GDI图形绘图.Windows的GDI函数包含数 ...
- GDI+ 笔记
1.GDI+模板 #include<windows.h> #include<GdiPlus.h> #include <time.h> #include <ma ...
- C# GDI+发生一般性错误(A generic error occurred in GDI+))
解决思路: 1. 因为 .net GDI+ 是对底层 的封装. 所以可以尝试用 Marshal.GetLastWin32Error();函数获得底层错误代码. try{ image.Save(file ...
- GDI与GDI+ 贴图性能对比
在做绘图相关工作,由于对显示绘制结果实时性有要求,筛选了GDI , 与GDI+ 贴图性能. 这里假设在内存中已绘制完成一张图片,现需求显示在控件上,同时,总是更新全部区域. GDI+ 实现 priva ...
随机推荐
- delphi 去掉TreeView水平滚动条
使用API函数:声明 FUNCTION ulong ShowScrollBar(ulong hwnd,ulong wBar,ulong bShow) LIBRARY "user32. ...
- Android学习笔记之百度地图
步行路线搜索及RouteOverlay 方式与驾车路线搜索类似,只需将mMKSearch.drivingSearch(null, start, null, end)修改为mMKSearch.walki ...
- android152 笔记 4
42. Android中Task任务栈的分配. 首先我们来看下Task的定义,Google是这样定义Task的:a task is what the user experiences as an &q ...
- android144 360 快捷方式
package com.example; import android.net.Uri; import android.os.Bundle; import android.app.Activity; ...
- Seconds_Behind_Master
http://blog.chinaunix.net/uid-28212952-id-3494560.html 今天同事遇到一个故障,xtrabackup备份中flush tables with rea ...
- The internals of Python string interning
JUNE 28TH, 2014Tweet This article describes how Python string interning works in CPython 2.7.7. A fe ...
- 关于MIUI悬浮窗权限问题的解决方案
先扯会....好久没写Blog了....这段时间有点小忙...瞎忙.....忙的自己都感觉都不应该.....严重影响了生活质量......生活的幸福指数!!!.....到现在还特么的单身!!!求介绍啊 ...
- C++ _access和_waccess的使用方法
C++ _access和_waccess的使用方法 概述 头文件:<io.h> 判断文件的访问权限 原型 int _access( const char *path, int mo ...
- 视频-某hadoop高级应用-搜索提示
看了北风的免费视频,只有一个案例,苦逼买不起几百上千的视频教程 先搭建简单的web项目,基于struts,使用到了bootstrap. 界面: web.xml <filter> <f ...
- Uva120 Stacks of Flapjacks 翻煎饼
水水题.给出煎饼数列, 一次只能让第一个到第i个数列全部反转,要求把数列排序为升序. 算法点破后不值几钱... 只要想办法把最大的煎饼放到最后一个,然后就变成前面那些煎饼的数列的子题目了.递归或循环即 ...