首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >缺少GDI+方法

缺少GDI+方法
EN

Stack Overflow用户
提问于 2020-10-04 11:48:01
回答 1查看 126关注 0票数 0

因此,我尝试使用来自GDI+的方法GDI+,但显然它并不存在。我已经确保初始化了所有的

代码语言:javascript
复制
    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

在WinMain的开头,下面是一些有问题的片段:

代码语言:javascript
复制
    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

这些是包括的所有头文件:

代码语言:javascript
复制
#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>

这个方法根本不存在:

是什么导致了这一切,我该如何解决呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-05 09:09:23

我很好奇为什么会发生这种事

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

代码语言:javascript
复制
#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。但是,如果不将GDIPVER指定为0x0110以启用Version1.1的功能,则在gtwus.h中,默认版本将指定为1.0:

代码语言:javascript
复制
// Define the Current GDIPlus Version
#ifndef GDIPVER
#define GDIPVER 0x0100
#endif
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64194224

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档