forked from misakamm/xege
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: 修复部分函数使用 ege_transform_matrix 参数做变换时崩溃的问题 #234
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5814a10
fix: 修复 ege_path 相关函数传入 ege_transform_matrix 参数会导致崩溃的问题
yixy-only 055e1b5
fix: 修复坐标变换中变换矩阵参数为 NULL 时引起程序崩溃的问题
yixy-only dd5afd7
refactor: 使用 Gdiplus::Matrix 类的 TransformPoints 函数对坐标进行变换
yixy-only a38e7d7
refactor: 变换矩阵类型转换改为由引用返回结果
yixy-only 69720a0
refactor: 矩阵类型转换使用引用参数
yixy-only File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "ege_head.h" | ||
#include "gdi_conv.h" | ||
|
||
namespace ege | ||
{ | ||
|
||
/** | ||
* 将ege_transform_matrix 转换为 Gdiplus::Matrix | ||
* matrix 参数不为 NULL 时返回 Matrix 对象指针,否则返回 NULL | ||
*/ | ||
Gdiplus::Matrix* matrixConvert(const ege_transform_matrix* matrix) | ||
{ | ||
if (matrix != NULL) { | ||
return new Gdiplus::Matrix( | ||
matrix->m11, matrix->m12, | ||
matrix->m21, matrix->m22, | ||
matrix->m31, matrix->m32 | ||
); | ||
} | ||
|
||
return NULL; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include "ege_head.h" | ||
|
||
namespace ege | ||
{ | ||
/* 矩阵类型转换*/ | ||
Gdiplus::Matrix* matrixConvert(const ege_transform_matrix* matrix); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种设计方式不太好吧, 返回一个需要delete的对象, 直接传入引用, 然后 return 对象是不是更好, 也不用处理 NULL 的情况了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
就算是按 C 风格的设计模式, 应该也是把输出一起传入才对? 比如
itoa
啥的...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wysaid OK,可以改成引用的方式。当时这么设计主要是考虑两点:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为是 C 形式的接口,ege_transform_matrix 是指针参数,所以空指针判断操作避免不了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
主要还是要保持的 c++ 版本比较低, 不然你可以用 std::optional 之类的 来防止 new, 也能很好利用 RVO/NRVO 啥的....
要封装成函数确实麻烦... 如果封装成宏定义, 倒是简单很多...
我看你还单独为这个函数单独弄了个头文件....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wysaid 因为后续可能还会加不少类似的类型转换,就单独建一个源文件了,转换操作统一放里面
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wysaid 改好了,看看这样可以不