Reputation: 554
So I'm trying to use the method Bitmap::GetHistogram from GDI+ but apparently it doesn't exist. I already made sure to initialize everything with
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
at the start of WinMain, here's the problematic snippet:
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
These are all the header files included:
#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>
The method simply isn't' there:
What might causing this and how do I fix it?
Upvotes: 0
Views: 215
Reputation: 7170
I'm curious as to why this happened
Because the method needs the GDIPVER >= 0x0110 in gdiplusbitmap.h:
#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)
All recent OS (>= Vista) have GDIPlus 1.1. But if you do not specify GDIPVER
to 0x0110 to enable the function of version 1.1, the default version will be specified as 1.0 in gdiplus.h:
// Define the Current GDIPlus Version
#ifndef GDIPVER
#define GDIPVER 0x0100
#endif
Upvotes: 1