Jump to content
  • Advertisement
Sign in to follow this  
Wh0p

GDI+ DrawString Invalid Parameter

This topic is 1787 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

 

I am about to create a SpriteFont generator. Therefore I wanted to utilize GDI+ to draw all the characters I need to a bitmap and then use the data as a texture.

 

Proplem is, that every DrawString call i make results in an invalid parameter status. However for testing reasons I pretty much opy pasted the msdn code sample and still got an invalid exception.

 

I do check all the results when I create or maipulate objects and until the DrawString all results as Ok.

 

Here is the code:

// Create the font
	Gdiplus::Font font (_Name.c_str (), _Size, _Style, Gdiplus::Unit::UnitPixel);
	GdiPlusCall (font.GetLastStatus ());

	// Solid white brush for text rendering
	Gdiplus::SolidBrush brush (Gdiplus::Color (255, 255, 255, 255));
	GdiPlusCall (brush.GetLastStatus ());


	// Setup bitmap and graphics object for rendering the texture
	Gdiplus::Bitmap texBitmap (texWidth, _TexHeight, PixelFormat32bppARGB);
	GdiPlusCall (texBitmap.GetLastStatus ());

	Gdiplus::Graphics texGraphics (&texBitmap);
	GdiPlusCall (texGraphics.GetLastStatus ());

	GdiPlusCall (texGraphics.Clear (Gdiplus::Color (0, 255, 255, 255)));
	GdiPlusCall (texGraphics.SetCompositingMode (Gdiplus::CompositingMode::CompositingModeSourceCopy));

	// Just for test reasons
	WCHAR asd[2];

	asd[0] = 'A';
	asd[1] = '\0';

	Gdiplus::Status s = texGraphics.DrawString (asd, 1, &font, Gdiplus::PointF (0.0f, 0.0f), &brush);

	// s == Gdiplus::Status::InvalidParameter - but why????

where GdiPlusCall is a makro that returns false, if the result is not Ok.

 

I can't figure out what I am doing wrong, please help.

Share this post


Link to post
Share on other sites
Advertisement

Allready tried that, neither -1 nor 2 works properly. I still get the InvalidParameter result.

 

Update:

So far I have tried all possible overloads of DrawString with the same result... However other draw calls (like DrawRectangle) work just fine. Which leads me to belief that there is somthing messed up with the font. Is there a posibility to retrieve further information on the error of that function call?

Edited by Wh0p

Share this post


Link to post
Share on other sites

Ok, sorry for the sort of multi post but i see this issue as resolved now.

 

Problem is, that on Win8 Graphics.DrawString and Graphics.SetCompositingMode(CompositingModeSourceCopy) don't go along with each other.

I think this is a known issue (http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/7f02b531-529d-4940-a220-cde46e61e88f/windows-8-garbled-text-with-gdi-graphicsdrawstring) but noone cares at MS...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!