GDI+绘制简单图形
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment(lib, "gdiplus.lib")
VOID OnPaint(HDC hdc) {
Graphics graphics(hdc);
Pen pen(Color(255, 0, 0, 255));
FontFamily fontFamily(L"宋体");
Font font(&fontFamily, 12, FontStyleRegular, UnitPixel);
PointF pointF1(30.0f, 60.0f),pointF2(230.0f, 60.0f);
SolidBrush solidBrush(Color(255, 0, 0, 255));
StringFormat stringFormat;
WCHAR testString[] = L"Hello034∠你好";
stringFormat.SetFormatFlags(StringFormatFlagsDirectionVertical);
graphics.SetSmoothingMode(SmoothingModeDefault);
graphics.DrawLine(&pen, 0, 0, 200, 100);
graphics.DrawEllipse(&pen, 10, 10, 190, 90);
graphics.SetTextRenderingHint(TextRenderingHintSystemDefault);
graphics.DrawString(testString, -1, &font, pointF1, &stringFormat, &solidBrush);
graphics.SetSmoothingMode(SmoothingModeHighQuality);
graphics.DrawLine(&pen, 200, 0, 400, 100);
graphics.DrawEllipse(&pen, 210, 10, 190, 90);
graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);
graphics.DrawString(testString, -1, &font, pointF2, &stringFormat, &solidBrush);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
HDC hdc;
PAINTSTRUCT ps;
switch(message) {
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
OnPaint(hdc);
EndPaint(hWnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
}
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow) {
HWND hWnd;
MSG msg;
WNDCLASS wndClass;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = TEXT("GettingStarted");
RegisterClass(&wndClass);
hWnd = CreateWindow(
TEXT("GettingStarted"), // window class name
TEXT("Getting Started"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL); // creation parameters
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
while(GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
GdiplusShutdown(gdiplusToken);
return 0;
}
GDI+绘制简单图形的更多相关文章
- 学习笔记:HTML5 Canvas绘制简单图形
HTML5 Canvas绘制简单图形 1.添加Canvas标签,添加id供js操作. <canvas id="mycanvas" height="700" ...
- Java入门:绘制简单图形
在上一节,我们学习了如何使用swing和awt工具创建一个空的窗口,本节学习如何绘制简单图形. 基本绘图介绍 Java中绘制基本图形,可以使用Java类库中的Graphics类,此类位于java.aw ...
- CSS绘制简单图形
究竟该用字体图标.图片图标.还是CSS画一个图标?我也不知道.各有千秋吧.本文将介绍如何用css绘制简单的图形,所有测试在chrome58.0完成,如果你不能得到正确结果请到caniuse查一查看看是 ...
- Windows控制台下绘制简单图形
最近接触到一个很有意思的问题,如何在Windows控制台下画图,翻遍了C的头文件也没找到画图的函数,好吧,那就用Windows提供的API函数吧,看来想移植是没戏了.先画一个简单的图,类似心电图那种吧 ...
- shape-自绘制简单图形
shape 可以绘制简单的图形,颜色等.它主要就是应用于selector 的一些状态. 本文内容参考自http://www.cnblogs.com/cyanfei/archive/2012/07/27 ...
- 在高德地图上用svg.js绘制简单图形
这段时间做的一个项目,需要在地图上绘制简单的图形.在学习高德地图JS API的过程中,发现高德地图提供的点.线等API并不能满足我的需求,还好它开放了自定义图层CustomLayer,官方说自定义图层 ...
- 利用 turtle库绘制简单图形
turtle库是python的基础绘图库,这个库被介绍为一个最常用的用来介绍编程知识的方法库,其主要是用于程序设计入门,是标准库之一,利用turtle可以制作很多复杂的绘图. turtle名称含义为“ ...
- Quartz 2D绘制简单图形
在Quartz 2D中,绘图是通过图形上下文进行绘制的,以下绘制几个简单的图形 首先先创建一个QuartzView.swift文件继承自UIView,然后实现drawRect方法: import UI ...
- Golang 绘图基础 -绘制简单图形
前一节讲的是 绘图到不同输出源,请看地址: http://www.cnblogs.com/ghj1976/p/3440856.html 上一节的例子效果是通过设置每一个点的的RGBA属性来实现的,这是 ...
随机推荐
- MySQL 动态sql语句运行 用时间做表名
1. 描写叙述 在使用数据的时候,我时候我们须要非常多数据库,并且想用时间来做表名以区分.可是MySQL在存储过程中不支持使用变量名来做表名或者列名. 比方,有一个表我们想以"2015-07 ...
- mybatis如何根据mapper接口生成其实现类(springboot)
序 mybatis里头给sqlSession指定执行哪条sql的时候,有两种方式,一种是写mapper的xml的namespace+statementId,如下: public Student fin ...
- QQ2010如何开启透明效果皮肤
QQ2010可在WIN7下实现皮肤透明效果. 腾讯已于近日发布了QQ2010的BETA版本,经笔者试验,可在WIN7下实现皮肤透明化效果. 设置如下: 1.先打开QQ皮肤控制面板,如下: 2.然后任选 ...
- android开发步步为营之67:使用android开源项目android-async-http异步下载文件
android-async-http项目地址 https://github.com/loopj/android-async-http.android-async-http顾名思义是异步的http请求, ...
- uva 701 - The Archeologists' Dilemma
题目链接:uva 701 - The Archeologists' Dilemma 题目大意:给出x,求一个e,使得x * 10 ^ y ≤ 2 ^ e < (x + 1) * 10 ^ y. ...
- spring boot 环境搭建
1.开发工具 https://spring.io/tools/sts/all 2.demo https://start.spring.io 3.下载maven https://maven.apache ...
- windows 配置ftp server
- 关闭xp防火墙
在控制面版关闭防火墙 禁用“Security Center”服务 禁用“WindowsFirewall/InternetConnectionSharing(ICS)”服务 删除服务:开始运行CMD,命 ...
- 短信api接口
1.需要用到的结构 typedef struct _SM_PARAM { char SCA[16];//+8613552678753// 短消息服务中心号码(SMSC地址) char TPA[16]; ...
- lr如何获取当前系统时间戳
lr如何获取当前系统时间戳 一般使用time函数,获取当前unix时间戳 lr程序如下: int t1; char a[20]; t1=time();//获取当前系统时间 //根据不同情况,将时间存储 ...