开发者

Write multiple line string with GDI+

开发者 https://www.devze.com 2023-04-11 19:56 出处:网络
I have a small display on my keyboard, it\'s 320x240, I\'m creating a plugin that allows me to see skype messages on this display even when I\'m playing full screen games.

I have a small display on my keyboard, it's 320x240, I'm creating a plugin that allows me to see skype messages on this display even when I'm playing full screen games.

The biggest problem I have, after solving all things about interacting with skype, is that I need to show chat messages in such a small area.

I'm using a font with size 10 to avoid unreadable text, this will allow me nothing more than 7 lines and around 40 characters per line.

I need a way to write a string on multiple lines, I've imagined some ways but I don't want to reinvent the wheel, I'm开发者_StackOverflow中文版 sure someone found the best solution for this, otherwise I couldn't have written this question :)

So, how to write multiple line string with gdi+ on an image of size 320x240? (well, we should consider it of size 290x240 because I have a header).


I solved the problem by myself: First, drawstring method do already "what i want" (makes the text fill a rectangle, if possible, otherwise keep writing it increasing height and not width).

With measurestring method, you can do the job.

I managed to split the string in multiple lines using some custom algorithms that worked well talking about performance. I won't enter into details because the algorithm is focused on my application and is definitely not generic.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号