Rank: Member
Groups: Guest
Joined: 8/3/2006(UTC) Posts: 5
|
Hi, I have been using Graphics Mill to try to produce PNG images of text strings. These text strings need to be stretched to fit a set size which may not correspond to any standard font size (e.g. it might be taller than the font is). I have this working, except that when I draw the text on a bitmap, and then resize it, I get dirty edges around the text. I am using white text, and I get gray lines around it after resizing. The only thing I've found to fix this is to use NearestNeighbour interpolation, but that is low-quality interpolation and has its own problems. Any suggestions as to how to fix this and have high-quality text? I've attached some sample code. (If there are any other things I'm doing that aren't the best way, feel free to let me know that, too. I need the text to be anti-aliased on a transparent background, which is why I'm using GDI+.) Thanks! Chris
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello Chris, Are you sure that this is the code snippet which you have intended to send? Or I just don't understand something? :) The source code you have posted produces fully white images with no text at all and with solid non-transparent alpha channel. Also I don't understand what purpose of these objects: tmpBitmap, tmpGraphics, blackBoxSize. |
|
|
|
|
Rank: Member
Groups: Guest
Joined: 8/3/2006(UTC) Posts: 5
|
Sorry, there was a change I needed to make. newBitmap should not have been given a white background; it should be transparent. I'm not sure how that got in there. tmpBitmap, tmpGraphics, and blackBoxSize are all because I need a graphics object so that I can call MeasureString so that I know how big to make the real bitmap (newBitmap). I rewrote this part so that it just uses newBitmap and resizes it to the size returned by MeasureString. I've attached the new file. Sorry about the mistake and confusion. Thanks, Chris
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello Chris, Thank you for the code sample, I've played with it a little and rewrited a bit. It seems that black pixels are result of the interpolation with black area outside the text. So I tried to create fully white image with the text printed in the alpha channel. As far as I can see this approach gives cleaner result. You can find modified code in the attached file. If you have any another ideas or request - feel free to contact us, it was rather interesting to investigate this issue ;) |
|
|
|
|
Rank: Member
Groups: Guest
Joined: 8/3/2006(UTC) Posts: 5
|
That seems to do exactly what I want. I figured it had to do with anti-aliasing with black, but the things I tried to fix it didn't work. Thanks very much!
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.