easyx中如何将画的图形抗锯齿

1

如题

ava
Luckily

2021-8-19

1

可以使用GDI+ 绘图贴图到IMAGE的DC上来实现, 具体代码如下

注意, [IMAGE]result需要使用透明贴图, 我的代码中为了省事就没有使用透明贴图, 否则会有黑底

#include <graphics.h>
#include <conio.h>
#include <gdiplus.h>

#pragma comment(lib, "gdiplus.lib")

int main()
{
	initgraph(640, 480);

	IMAGE result;

	// 启动GDI+
	Gdiplus::GdiplusStartupInput input;
	ULONG_PTR                    token;
	Gdiplus::GdiplusStartup(&token, &input, NULL);

	Gdiplus::Graphics graphics(GetImageHDC(&result));
	Gdiplus::Pen      pen(Gdiplus::Color(255, 255, 255));

	// 设置绘图质量为高质量
	graphics.SetSmoothingMode(Gdiplus::SmoothingMode::
					SmoothingModeHighQuality);
	// 调用GDI+绘图
	graphics.DrawEllipse(&pen, Gdiplus::Rect { 0, 0, 80, 80 });

	// 关闭GDI+
	Gdiplus::GdiplusShutdown(token);

	// 将结果贴图
	putimage(0, 0, &result);

	_getch();

	return 0;
}
ava
Margoo

2021-8-23

0

这需要自己写算法实现。

例如这个程序可以参考下:https://codebus.cn/yangw/filter-carrier-wave-effect

ava
慢羊羊

2021-8-20

技术讨论社区