打印Alpha图像

时间:2014-12-31 03:57:51

标签: printing mfc gdi+

我是打印机的新手

如何打印alpha图像?

我正在使用Gdi +的DrawImage来绘制图像。

Image with Alpha

(浅灰色部分为黑色,20%alpha)

但是,结果并不像我预期的那样。

似乎丢弃了alpha。

Image Printed

我正在使用以下代码进行打印

#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>

#pragma comment(lib, "gdiplus.lib")
using namespace Gdiplus;

INT main()
{
   // Initialize GDI+.
   GdiplusStartupInput gdiplusStartupInput;
   ULONG_PTR gdiplusToken;
   GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

   // Get a device context for the printer.
   HDC hdcPrint = CreateDC(NULL, TEXT("\\\\printserver\\HP CP3505_2F"), NULL, NULL);

   DOCINFO docInfo;
   ZeroMemory(&docInfo, sizeof(docInfo));
   docInfo.cbSize = sizeof(docInfo);
   docInfo.lpszDocName = L"GdiplusPrint";

   Bitmap image(L"e:\\__.png");
   StartDoc(hdcPrint, &docInfo);
   StartPage(hdcPrint);
      Graphics* graphics = new Graphics(hdcPrint);
      Pen* pen = new Pen(Color(255, 0, 0, 0));

      graphics->DrawImage(&image, 50, 50);

      delete pen;
      delete graphics;
   EndPage(hdcPrint);
   EndDoc(hdcPrint);

   DeleteDC(hdcPrint);
   GdiplusShutdown(gdiplusToken);
   return 0;
}

但是,按预期打印使用Word(MS-Office)图像。

请帮忙。


编辑:

GDI Alphablend函数将图像alpha部分绘制为灰色。

看起来很好。

但是,重叠alpha无法正常工作。

它只是画了两次灰色alpha部分。

不是alpha混合。

source

0 个答案:

没有答案