1

Is there a way to get rendered bitmap image using DirectWrite and Direct2D ?

Like FreeType2's FT_GlyphSlot->bitmap...

user2170124
  • 105
  • 2
  • 8

2 Answers2

1

I think you can create a ID2D1Bitmap first, then use ID2D1Bitmap::CopyFromRenderTarget to copy the data from render target.

zdd
  • 8,258
  • 8
  • 46
  • 75
  • Thank you. Is this a most simple way? Isn't DirectWrite provide bitmap utility api ? (I couldn't found it) – user2170124 Jul 01 '13 at 11:30
  • Do you mean convert font to a bitmap? – zdd Jul 01 '13 at 13:00
  • Yes. I checked out and found that ID2D1Factory->CreateWicBitmapRenderTarget() is needed and some more procedure to get actual bitmap data. I feel too complex to do such a simple task... – user2170124 Jul 06 '13 at 12:36
  • not sure if this can help you, http://www.codeproject.com/Articles/376597/Outline-Text-With-DirectWrite – zdd Jul 06 '13 at 12:42
1

It is possible, and you don't need to use Direct2D for that. Use CreateGlyphRunAnalysis and then call GetAlphaTextureBounds to get resulting bitmap bounds, then allocated buffer and call CreateAlphaTexture. This fills your buffer with opacity mask for a glyph run you want to render.

bunglehead
  • 1,104
  • 1
  • 14
  • 22