Re: Drawing Text on Image object with GDI+
- From: "Mark Salsbery [MVP]" <MarkSalsbery[MVP]@newsgroup.nospam>
- Date: Thu, 6 Mar 2008 10:03:06 -0800
<marcusadeleon@xxxxxxxxx> wrote in message news:99bf821c-6de2-43c4-bf73-945b2e7cc27a@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 5 Mar, 23:59, "Mark Salsbery [MVP]"
<MarkSalsbery[MVP]@newsgroup.nospam> wrote:
Yes, that's what I did, but when I saved the bitmap to the hard drive
there is no text. Is there anything else I have to do to save the
image after I draw on it and keep it?
This works for me:
Bitmap TextBitmap(640, 480, PixelFormat24bppRGB);
Graphics TextGraphics(&TextBitmap);
SolidBrush whiteBrush(Color(255, 255, 255, 255));
TextGraphics.FillRectangle(&whiteBrush, 0, 0, 320, 240);
Gdiplus::Font myFont(L"Arial", 40);
PointF origin(0.0f, 0.0f);
SolidBrush blackBrush(Color(255, 0, 0, 0));
TextGraphics.DrawString(L"Sample Text", 11, &myFont, origin, &blackBrush);
CLSID bmpClsid;
GetEncoderClsid(L"image/bmp", &bmpClsid);
TextBitmap.Save(L"e:\\TextImage.bmp", &bmpClsid);
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
.
- References:
- Drawing Text on Image object with GDI+
- From: marcusadeleon
- Re: Drawing Text on Image object with GDI+
- From: marcusadeleon
- Drawing Text on Image object with GDI+
- Prev by Date: Re: Drawing Text on Image object with GDI+
- Next by Date: Re: Closing Enh Metafile device contex
- Previous by thread: Re: Drawing Text on Image object with GDI+
- Next by thread: Converting a DIB into a Gdiplus::Bitmap
- Index(es):
Relevant Pages
|