C++如何使用setpixel函数绘制色调曲线(gamma)到图形
C++ how to draw a tone curve (gamma) to graph using setpixel function
如标题所述。我正试图画一条伽马色调曲线,但我不知道如何做。我可以画线性色调曲线,但是当涉及到绘制伽马色调曲线时,我完全失去了它http://www.mediachance.com/pseam/help/curves.html(第1张或第2张图纸)
代码如下
#include <math.h>
static COLORREF red=RGB(255,0,0);
static COLORREF blue=RGB(0,0,255);
static COLORREF green=RGB(0,255,0);
我应该结合在其中绘制伽马色调曲线的部分
for(int y=0; y<bih.biHeight; y++)
{
for(int x=0; x<bih.biWidth; x++)
{
SetPixel(hdc, x, bih.biHeight-x, red);
}
// The X axis of the graph
HPEN hLinePen1;
COLORREF qLineColor1;
qLineColor1 = RGB(255, 0, 0);
hLinePen1 = CreatePen(PS_SOLID, 2, qLineColor1);
hPenOld1 = (HPEN)SelectObject(hdc, hLinePen1);
line(hdc,0, bih.biHeight, bih.biWidth, bih.biHeight);
SelectObject(hdc, hPenOld1);
DeleteObject(hLinePen1);
// The Y axis of the graph
HPEN hLinePen2;
COLORREF qLineColor2;
qLineColor2 = RGB(255, 0, 0);
hLinePen2 = CreatePen(PS_SOLID, 2, qLineColor2);
hPenOld2 = (HPEN)SelectObject(hdc, hLinePen2);
line(hdc,0, bih.biHeight, 0, bih.biWidth-bih.biHeight);
SelectObject(hdc, hPenOld2);
DeleteObject(hLinePen2);
绘制图形应该很简单。对于您拥有的每个X点,计算相应的Y值-在Gamma的情况下,范围为0-255,即y = round(pow(x/255., gamma)*255)
。然后从上一个点到当前点画一条线。
相关文章:
- C++图形类指针混淆
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 如何在内核C++中使用1920x1080x16M图形或类似的16M颜色?(VGA)
- 这是实现图形的坏方法吗
- 打印 ONNXRUNTIME::图形没有模型
- 提升如何在图形可视化中写入边缘的权重?
- Doxygen - 如何在不生成图形的情况下生成文本调用关系结果
- C++ 中的图形菜单
- 将图形属性与 std::unique_ptr 捆绑在一起
- 从流到邻接列表的向量读取图形
- 替代在python中制作邻接列表与图形问题的字典?(如 C++ 中的 vector<vector<int&g
- 将图形表示为unordered_map<字符串、向量>时拓扑排序错误<string>
- 直接显示手动图形内存泄漏
- Directx 12 :在两个进程之间共享图形内存
- Microsoft C++ 用于图形 API 的 Rest SDK
- 如何将到达图形视图右侧(末端)的QGraphicsPixmapItem移动到左侧(开始)侧(就像在贪吃蛇游戏中发生的事情
- 图形初学者C++(跳过控制台)?
- 在 cpp 中最简单的图形实现
- 提升图形库:资源受限的最短周期
- C++如何使用setpixel函数绘制色调曲线(gamma)到图形