Sign in to follow this  

Scaling a bitmap with text

This topic is 3444 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

Hi, I am doing an application which takes snapshots of a rich edit control containing text. I take the snap shots and scale them up/down based on some threshold values. I scale the bitmaps using StretchBlt. The problem is that text gets all screwed up when I scale it down. What can I do to avoid this? Thanks, M

Share this post


Link to post
Share on other sites
Is there a specific reason you need to scale those shots? It'll only malform the snapshots, so unless there's a good reason I wouldn't scale anything at all.

Either way, perhaps retargeting could be useful here. Content aware image resizing.

Share this post


Link to post
Share on other sites
When you set the stretchbltmode to HALFTONE instead of the default COLORONCOLOR (see MSDN: SetStretchBltMode), you'll get smoother scaling. While that may look a little better, it'll still blur the text.

Instead, you should think about not capturing the rich edit control directly, but either scaling its contents (it is a *richt text* control after all -- you can just set a bigger/smaller font) or perhaps tell it to redraw itself into a device context with a higher DPI setting (read up on the CreateDC and especially DEVMODE documentation in MSDN).

Share this post


Link to post
Share on other sites
Hi,
Yes. I have a good reason for scaling the bitmaps as they have to be made to fit in a finite area.

I already tried setting halftone. It still doesn't look good ( not even reasonably good ).

I'll try to change content size.

Thanks,
M

Share this post


Link to post
Share on other sites
Text looks like crap with bitmap scaling, that's really all there is to it. You can improving things marginally by using better scaling methods (e.g. HALFTONE), turing off antialiasing (particularly cleartype) might help a bit as well. Although it sounds like you don't really have control over the data source and even if you do you run the risk of making it look like crap before the scaling as well as after. It's never going to look nearly as good as text properly scaled by the text renderer.

Share this post


Link to post
Share on other sites
Hi,
I tried to zoom the text using EM_SETZOOM of RichEdit. While I was able to SEE the zoomed text in rich edit, when I took a bitmap of the contents of the rich edit control after zooming, the bitmap contained the original text (without zooming). So I tried to look af CPreviewView class of MFC to see how print preview is being implemented. But I've not been able to find out HOW.

Share this post


Link to post
Share on other sites
Hi,
Can someone please help me with this :

1. Does EM_FORMATRANGE respect changes made by EM_SETZOOM? Calling EM_SETZOOM before/after EM_FORMATRANGE doesn't seem to work.

2. If it doesn't, can I call WM_PRINTCLIENT in a windowless rich edit control? I'm getting an empty bitmap when I call WM_PRINTCLIENT. Calling it with Parent hwnd doesn't work either.

Thanks,
M

Share this post


Link to post
Share on other sites

This topic is 3444 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this