缺少GDI +方法

问题描述

因此,我尝试使用GDI +中的方法Bitmap::GetHistogram,但显然它不存在。我已经确保要使用

初始化所有内容
    Gdiplus::GdiplusstartupInput gdiplusstartupInput;
    ULONG_PTR gdiplusToken;
    Gdiplusstartup(&gdiplusToken,&gdiplusstartupInput,NULL);

在WinMain开始时,这是有问题的代码段:

    UINT numEntries;
    Gdiplus::Bitmap myBitmap(pszFilePath);
    Gdiplus::Image myImage(pszFilePath);

    UINT iHeight = myImage.GetHeight(); // works
    UINT iWidth = myImage.GetWidth(); // works
    myBitmap.GetHistogramSize(HistogramFormatRGB,&numEntries); // not defined

这些都是所有的头文件

#include <Unknwn.h>
#include <windows.h>
#include <Gdiplus.h>
#include <stdio.h>
#include <iostream>
#include <commdlg.h>
#include <commctrl.h>
#include <winioctl.h>
#include <Objbase.h>
#include <shobjidl.h>
#include <objidl.h>
#include <strsafe.h>

方法根本不存在:

enter image description here

这可能是什么原因导致的,我该如何解决

解决方法

我很好奇为什么会发生

因为该方法需要gdiplusbitmap.h中的GDIPVER> = 0x0110:

#if (GDIPVER >= 0x0110)
...
inline Status
Bitmap::GetHistogram(
    IN HistogramFormat format,IN UINT NumberOfEntries,_Out_writes_bytes_(sizeof(UINT)*256) UINT *channel0,_Out_writes_bytes_(sizeof(UINT)*256) UINT *channel1,_Out_writes_bytes_(sizeof(UINT)*256) UINT *channel2,_Out_writes_bytes_(sizeof(UINT)*256) UINT *channel3
)
{
    return DllExports::GdipBitmapGetHistogram(
        static_cast<GpBitmap *>(nativeImage),format,NumberOfEntries,channel0,channel1,channel2,channel3
        );
}

inline Status 
Bitmap::GetHistogramSize(
    IN HistogramFormat format,OUT UINT *NumberOfEntries
)
{
    return DllExports::GdipBitmapGetHistogramSize(
        format,NumberOfEntries
        );
}

#endif // (GDIPVER >= 0x0110)

所有最新操作系统(> = Vista)均具有GDIPlus 1.1。但是,如果您没有为0x0110指定GDIPVER来启用版本1.1的功能,则默认版本将在gdiplus.h中指定为1.0:

// Define the Current GDIPlus Version
#ifndef GDIPVER
#define GDIPVER 0x0100
#endif