外部库错误 c++
External library errors c++
我在编译DLL文件项目时遇到了一些问题。有 2 个文件 CDLL.h 和 CDLL.cpp:
CDLL.h:
#pragma once
namespace CDLL {
class CDLL
{
static unsigned char TransLut[256];
public:
__declspec(dllexport) void build_lookup_table ( int contr);
__declspec(dllexport) bool Contrast(HBITMAP * phBitmap, int iCount);
};
}
CDLL.cpp:
#include "Stdafx.h"
#include "CDLL.h"
#include <math.h>
#include <windows.h>
namespace CDLL
{
void CDLL::build_lookup_table(int contr)
{
float step, step_value;
for (int i=0; i < 256; i++)
TransLut[i] = i;
if (contr > 0)
{
unsigned int MinBin = contr;
unsigned int MaxBin = 255 - contr;
step = sqrt((double)contr)/contr;
step_value = 0.0;
for (int i = 0; i < MinBin; i++)
{
TransLut[i] = (unsigned char)step_value;
step_value += step;
}
step = 256.0f / (float)(MaxBin-MinBin);
for (int i = MinBin; i <= MaxBin; i++)
{
if (step_value > 255.0f)
{
step_value = 255.0f;
step = 0.0f;
}
TransLut[i] = (unsigned char)step_value;
step_value += step;
}
for (int i = MaxBin + 1; i < 256; i++)
TransLut[i] = 255;
}
else if (contr < 0)
{
step = (256.0+(float)(contr*2))/256.0;
step_value = (float)contr * -1.0;
for (int i = 0;i < 256; i++)
{
TransLut[i] = (unsigned char)step_value;
step_value += step;
}
}
}
bool CDLL::Contrast(HBITMAP * phBitmap, int iCount)
{
BITMAP bm;
BYTE * pBits;
RGBQUAD * pRgb;
WORD wByteCount;
int i, iPixels, gray;
build_lookup_table(iCount);
// Take BITMAP structure from HBITMAP
GetObject(*phBitmap, sizeof(BITMAP), &bm);
// Calculate bytes to read
wByteCount = bm.bmHeight * (2 * ((bm.bmWidth * bm.bmBitsPixel + 15) / 16));
// Alocate momory for bits od pixels and get pointers
pBits = (BYTE *) malloc(wByteCount);
GetBitmapBits(*phBitmap, wByteCount, pBits);
// Convert pointer to byte to pointer to RGBQUAD
pRgb = (RGBQUAD *) pBits;
// Operate on pixel's colors
iPixels = wByteCount / (bm.bmBitsPixel / 8);
for(int i = 0; i < iPixels; i++, pRgb++)
{
gray = (pRgb->rgbRed + pRgb->rgbGreen + pRgb->rgbBlue) / 3;
int k = TransLut[gray]-gray;
pRgb->rgbRed = min(pRgb->rgbRed + k, 255);
pRgb->rgbGreen = min(pRgb->rgbGreen + k, 255);
pRgb->rgbBlue = min(pRgb->rgbBlue + k, 255);
}
SetBitmapBits(*phBitmap, wByteCount, pBits);
return TRUE;
}
}
我不明白为什么我会收到这样的错误:
- 错误
- C2061:语法错误:标识符"HBITMAP"CDLL.h
- 错误 C2511:"布尔 CDLL::CDLL::对比度(HBITMAP *,int)":重载在"CDLL::CDLL"中找不到成员函数 .cpp
#2 不是关于头文件中的方法声明吗?我应该如何解决这个问题?
HBITMAP
类型是特定于窗口的类型。在您的代码中,您似乎忘记包含适当的标头。这可能是问题所在。
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 错误:未在此范围内声明'reverse'