Graphics::GetHalftonePalette 方法 (gdiplusgraphics.h)

Graphics::GetHalftonePalette 方法获取 Windows 半色调调色板。

语法

HPALETTE GetHalftonePalette();

返回值

类型: 静态

此方法返回 Windows 半色调调色板的句柄。

注解

Graphics::GetHalftonePalette 方法的目的是使 GDI+ 在显示器使用每像素 8 位时生成更高质量的半色调。 若要使用半色调调色板显示图像,请使用以下过程:

  1. 调用 Graphics::GetHalftonePalette 以获取 GDI+ 半色调调色板。
  2. 在设备上下文中选择半色调调色板。
  3. 通过调用 RealizePalette 函数实现调色板。
  4. 从设备上下文的句柄构造 Graphics 对象。
  5. 调用 Graphics 对象的 Graphics::D rawImage 方法。
使用完调色板后,请务必将其删除。 如果不遵循上述过程,则在每像素 8 位显示设备上,使用默认的 16 色处理,这会导致质量较低的半色调。

示例

下面的示例绘制了两次相同的图像。 第二次绘制图像之前,代码获取一个半色调调色板,将调色板选入设备上下文,并实现调色板。

VOID Example_GetHalftonePalette(HDC hdc)
{
   Image image(L"Mosaic.png");
   
   Graphics* graphics1 = new Graphics(hdc);
   graphics1->DrawImage(&image, 10, 10);
   delete graphics1;
   
   HPALETTE hPalette = Graphics::GetHalftonePalette();
   SelectPalette(hdc, hPalette, FALSE);
   RealizePalette(hdc);
   Graphics* graphics2 = new Graphics(hdc);
   graphics2->DrawImage(&image, 300, 10);
   delete graphics2;
   DeleteObject(hPalette);
}

要求

   
最低受支持的客户端 Windows XP、Windows 2000 Professional [仅限桌面应用]
最低受支持的服务器 Windows 2000 Server [仅限桌面应用]
目标平台 Windows
标头 gdiplusgraphics.h (包括 Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

另请参阅

GetPalette

显卡

RealizePalette

SetPalette