当前位置:网站首页>Basic image transformation in gdi+
Basic image transformation in gdi+
2022-06-09 12:45:00 【litanyuan】
background
Graph transformation refers to the translation of the drawn graph 、 rotate 、 Telescoping and other operations , from Graphics Class provides corresponding member functions for implementation
Translation transformation
①. summary
Translation transform will draw the coordinates of the drawing (x, y) Translate all by one increment (dx, dy), Corresponding member function TranslateTransform , It is equivalent to moving the origin of the coordinate system of the drawing .
②. Translation transformation
void DemoGDI::DrawUser(HDC hdc)
{
Graphics graphics(hdc);// structure Graphics object
Pen m_pen(Color::Blue, 2);
Rect m_rect(30, 30, 180, 120);
graphics.DrawRectangle(&m_pen, m_rect);// Draw a rectangle
graphics.TranslateTransform(20, 40);//x translation 20,y translation 40
graphics.DrawRectangle(&m_pen, m_rect);// Draw a rectangle
}

Rotation transformation
①. summary
Rotate the coordinates of the drawing (x, y) Rotate all α degree , Is the rotation relative to the coordinate origin of the upper left corner . Corresponding member function RotateTransform.
②. Rotation transformation
void DemoGDI::DrawUser(HDC hdc)
{
Graphics graphics(hdc);// structure Graphics object
Pen m_pen(Color::Blue, 2);
Rect m_rect(30, 30, 180, 120);
graphics.DrawRectangle(&m_pen, m_rect);// Draw a rectangle
graphics.RotateTransform(10);// rotate 10 degree
graphics.DrawRectangle(&m_pen, m_rect);// Draw a rectangle
}

Scaling transformation
①. Concept
Stretch transform will draw the shape of the figure in x and y In the direction of the specified scale sx and sy Zoom , Corresponding member function ScaleTransform, The transformation is the value of each coordinate point in the graph .
②. Scaling transformation
void DemoGDI::DrawUser(HDC hdc)
{
Graphics graphics(hdc);// structure Graphics object
Pen m_pen(Color::Blue, 2);
Rect m_rect(30, 30, 180, 120);
graphics.DrawRectangle(&m_pen, m_rect);// Draw a rectangle
graphics.ScaleTransform(0.3f, 0.3f);//x、y Change to the original 0.3
graphics.DrawRectangle(&m_pen, m_rect);// Draw a rectangle
}

③. Mirror transformation
void DemoGDI::DrawUser(HDC hdc)
{
Graphics graphics(hdc);// structure Graphics object
Pen m_pen(Color::Blue, 2);
Font font(L" Song style ", 30, FontStyleRegular, UnitPixel);
SolidBrush solidBrush(Color::Blue);
StringFormat stringFormat;
stringFormat.SetLineAlignment(StringAlignmentCenter);
graphics.TranslateTransform(250, 40);// Change coordinate origin
QString m_text = "GDI+ Text rendering ";
graphics.DrawString(m_text.toStdWString().c_str() , -1, &font, PointF(0.0f, 40.0f), &stringFormat, &solidBrush);
graphics.ScaleTransform(-1, 1);// Symmetry up and down
graphics.DrawString(m_text.toStdWString().c_str(), -1, &font, PointF(0.0f, 40.0f), &stringFormat, &solidBrush);
}

Rectangle scaling
①. summary
Rect Class provides member functions Inflate Used for scaling rectangles , The scaling result is to extend or shrink the four edges of the rectangle by a specified distance .
②.Inflate Use
void DemoGDI::DrawUser(HDC hdc)
{
Graphics graphics(hdc);// structure Graphics object
Pen m_pen(Color::Blue, 2);
Rect m_rect(30, 30, 180, 120);
graphics.DrawRectangle(&m_pen, m_rect);// Draw a rectangle
m_rect.Inflate(-10, -10);//4 The edge shrinks inward 10 Pixel
graphics.DrawRectangle(&m_pen, m_rect);// Draw a rectangle
}

边栏推荐
- JUC-实现Future
- 匿名內部類與局部變量
- JMeter安装教程
- LR11 installation error: vc2005 is missing on this computer_ sp1_ with_ atl_ fix_ Redist, please install all missing required components, and then run this installation again.
- stc8a8k_rgb___LED 888测试代码,还没测试
- .NET基础知识快速通关11
- 柴云鹏:创新能力的培养至关重要|OceanBase 数据库大赛访谈
- Are there any financial products with guaranteed principal and interest in 2022? I want to invest and manage money, but I'm afraid of losing money
- Musk's "cancel transaction" threat worked twitter agreed to open the database for verification
- . Net basic knowledge quick pass 10
猜你喜欢
随机推荐
L'ouverture d'un compte à terme est - elle fiable et sécurisée??
玩转Web3:创建属于自己的ERC-721(NFT)
期貨開戶雲,開戶可靠安全嗎??
推荐的十个Flutter插件
GameFi新的启程,AQUANEE将于6.9日登陆Gate以及BitMart
go语言time.Format的坑
Classes internes anonymes et variables locales
IPO,联结一切的桥梁
勤于奋做国外LEAD的一些习惯
实验室常用工具 | 实验溶液配制 | 摩尔浓度及分子量计算工具 molarity-calculator
1. < tag backtracking, combination and pruning > lt.77 Combination + pruning dyh
Rédaction de documents scientifiques
Tag greedy - brush questions to prepare knowledge - greedy problem solving methods + lt.455 Distribute cookies + lt.376 Wobble sequence
C#/VB.NET 在PDF表格中添加条形码
Common laboratory tools | preparation of experimental solution | molarity calculator
"Forget to learn again" shell Basics - 28. Description of conditional expressions in awk
Leetcode camera minimum problem
简单的聊天室系统Socket实现
6. < tag backtracking and cutting problems > lt.131 Split palindrome string
查看线程名and设置线程名
![[译]PostgreSQL 怎么通过vacuum 加速事务ID回收的速度](/img/15/396fe394af73b19a9ff0dd984c6682.png)







