Archived

This topic is now archived and is closed to further replies.

Stretchblt looking ugly...

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

I have an image that I stretchblt to the screen. It is a large image so that it will print properly. The problem is that when it is displayed on the screen, it looks ugly, like when you write with a pen that is leaking ink. The lines are very thick and it kind of blends together. I understand the reason is that it is because I am taking a large bitmap and squishing it into a smaller space, but is there a way to make it look better? It is a black and white bitmap with text on it. I''m using SRCCOPY in Stretchblt.

Share this post


Link to post
Share on other sites
AFAIK the only way to make it look good is to stretch it by a power of 2

example:
original size = 320x240
stretched size = 640x480 (2x)

also be sure to keep aspect ratio when you stretch

hope that helps !
Matt

Share this post


Link to post
Share on other sites
StretchBlt isn''t a very good graphic function when you need to resize something. Depending on your needs, it might be simpler to just write your own resizing function.

StretchBlt just makes the image fit in the space you provide it and trims the pixels that don''t make it fit in there. For instance, with a 1.00:0.75 scale ratio, every 4th pixel gets dumped. This can result in pretty yucky stuff. When you resize the image to make it bigger, it just copies extra pixels to fill in the gaps (with a 1.00:1.25 ratio, it would copy every 4th pixel).

You could write a quick and dirty function that averages every point on the image you''re using; kinda add an additional step to what stretchblt does. Instead of removing pixels, interpolate the color with the neighbouring pixels or something like that.

Your other option is to just resize the image in a good image editing program and drop the whole resizing bit.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I once experienced that SetStretchBltMode had some influence on the quality of the result, maybe you should play around with that a bit.

Share this post


Link to post
Share on other sites
Awesome. I played around with the different options for setStretchbltmode and it gave me exactly what I wanted. I just had to use HALFTONE. Thanks a lot! ^_^
I do have one more question though. It''s not really related to my last one. The problem is that when another window is dragged over my application, it doesn''t repaint itself. Other applications look fine after you drag, say calculator, over it, but mine just leaves the beige background color. Even once I give focus back to my window and move it around, it doesn''t repaint...
Any ideas or suggestions?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Your window should get something like WM_PAINT when it has to be repainted. In that case... do so :-)

Share this post


Link to post
Share on other sites
okay! so HALFTONE would be the key to this...

Hmmm... to test my image loader I was using the typical BMP loader in all DDraw tutorials and it always gave me an ugly image when downsizing... this could be the key?

Share this post


Link to post
Share on other sites