Here I have write an ink app using COM, now I want to save the ink data to a png image. But only an empty png file is created, maybe there is something wrong in my code, please help me! The code is follow:
HDC hDC = XXX; // DC handle IInkOverlay *pInkOverlay = XXX; // the InkOverlay object
...
IInkRenderer *render = NULL; pInkOverlay->get_Renderer(&render); IInkDisp *ink = XXX; pInkOverlay->get_Ink(&ink); IInkRectangle *rect = NULL; int->GetBoundingBox(IBBM_CurveFit, &rect); long l, t, r, b; rect->GetRectangle(&t, &l, &b, &r); long cx = r - l; long cy = b - t; render->InkSpaceToPixel((LONG_PTR)hDC, &l, &t); render->InkSpaceToPixel((LONG_PTR)hDC, &cx, &cy); IInkStrokes *strokes = NULL; pInk->get_Strokes(&strokes); CLSID clsid; GetImageEncoderClsid(L"image/png", &clsid) Bitmap bitmap(cx, cy); Graphics *graphics = Graphics::FromImage(&bitmap); if (graphics) { graphics->Clear(Color::Transparent); render->Draw((LONG_PTR)graphics->GetHDC(), strokes); bitmap.Save(L"c:\\ink.png", &clsid); delete graphics; }