• Advertisement
Sign in to follow this  

StretchBlt and wide bitmaps ?

This topic is 4707 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've been trying to stretch a very long bitmap (3600 pixels wide, 150 pixels high) down to 2400 pixels wide and 100 pixels high and like the last couple of hundred pixels are messed up. When I stretch the same bitmap down to 1200 pixels wide and 50 pixels high, it works fine. I was wondering, is there a width limitation on StretchBlt? here's the code I am using
   //create a BMP to which we will paste the cut fragment of base; medium size
   //we multiply MedX by number of frames to achieve correct width
   BMPadd = CreateCompatibleBitmap(HDCbase, MedX * Frames, MedY); 
   //select it to the HDC
   oldbmp2 = (HBITMAP)SelectObject(HDCadd, BMPadd);
   
   //now blit and resize the part of base bmp we want
   //we multiply BigX by number of frames to achieve correct width
   StretchBlt(HDCadd, 0,0, MedX * Frames, MedY, HDCbase, 0,0, BigX * Frames, BigY, SRCCOPY);  

/*
BMPadd => HBITMAP
HDCadd => hdc containing the bitmap to which we will paste the stretched one (2400 x 100)
HDCbase => hdc containing the bitmap to be stretched (3600 x 100)
MedX => 100  
MedY => 100
BigX => 150
BigY => 150
Frames => 24
*/

If this is indeed too wide for stretchblit, then I guess I would have to stretch the first and second half of the bitmap separately, no?

Share this post


Link to post
Share on other sites
Advertisement
Have you tried playing around with the painting types? i.e. change SRCCOPY to SRCPAINT or SRCAND and see what you get. I don't believe StretchBlt has a limitation but it is a slow way to render something. After you have stretched the bitmap, try refreshing the hDC or the dialog box and that should fix the problem with your screwed up pixels.

Share this post


Link to post
Share on other sites
SCRAND and SCRPAINT simply blit the bitmap using the AND and OR operator, so that wont change anything.
What do you mean by refreshing the hdc ? I am drawing the bitmap through a different hdc later in the code so I am pretty sure it is a problem with the HBITMAP, not the HDC...

Share this post


Link to post
Share on other sites
Try adding
SetStrechBltMode(HDCadd, HALFTONE);

before the call to StretchBlt.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anon Mike
Try adding
SetStrechBltMode(HDCadd, HALFTONE);

before the call to StretchBlt.


nope :/

EDIT: When I change the width of the bitmap that that holds the stretched bitmap to 1200 from 2400 and blit only the second half of the original bitmap, it works fine. However, if I leave it at 2400 and still blit the second half of the original bitmap - the same messed up pixles.
This means I need to stretchblit the first half of the original bitmap to a 1200x100px bitmap, then blit that bitmap to the first half of the 2400x100px bitmap and do the same for the second half. ARGH !

[Edited by - Koobazaur on April 1, 2005 6:17:16 PM]

Share this post


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

  • Advertisement