Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to draw a halo for text using GDI+
Here is my code:
C++
Bitmap *bm = new Bitmap(100, 40, PixelFormat32bppRGB);
GraphicsPath *pth = new GraphicsPath();
WCHAR text[]  = L"Text Halo";
RectF pnt(20,50,100,40);

pth->AddString(text,
wcslen(text),
new FontFamily(L"Verdana"),
FontStyleRegular,
40,
pnt,
StringFormat::GenericDefault());

Gdiplus::Graphics *graph = new Gdiplus::Graphics(bm);
Matrix *mx = new Matrix(1.0f/15,0,0,1.0f/15,-(1.0f/15),-(1.0f/15));

graph->SetSmoothingMode(SmoothingModeAntiAlias);
graph->GetTransform(mx);
graph->DrawPath(&Pen(Color::Yellow, 3),pth);
graph->FillPath(new SolidBrush(Color::Red),pth);

delete pth;
delete graph;

Gdiplus::Graphics *graph_fin = new Gdiplus::Graphics(backdc);

graph_fin->SetSmoothingMode(SmoothingModeAntiAlias);
graph_fin->SetInterpolationMode(InterpolationModeHighQualityBilinear);
graph_fin->DrawImage(bm,20,50,0,0,100,40,UnitPixel);

delete bm;
delete graph_fin;


But as a result there was painted black rectangle.

Where is the mistake? And what needs to be fixed?
Posted
Comments
The_Inventor 18-Jul-13 0:51am    
Your inputs and outputs don't match what you claim to be doing. I see that create and use 'bm' but not 'backdc'. And then maybe you delete your pointers too soon ...
What / Where is this -> PixelFormat32bppRGB, is it 'Black'?

1 solution

you are drawing some empty stuff.-> bug in coordinates

else you should split your drawing code to find the bug. Start with filling the output with a solid color.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900