PDA

Click to See Complete Forum and Search --> : Issues with StretchBlt() under Windows2000 Pro ?


plenderj
Nov 15th, 2001, 02:15 AM
Howdy.

I've developed an app, as a college project, that performs a traceroute to a number of different hosts, and then displays the routes graphically.
I got some nice pics off Sastraxi (which I think he probably "borrowed" from Windows), and was originally BitBlt'ing them onto a picturebox. But it was getting a bit cluttered.
So I decided I would StretchBlt into the picturebox and reduce the pictures by 1.5

So thats what I did. It works absolutely perfectly on my WinME laptop, but when I went into college to test it yesterday, StretchBlt didn't seem to be doing its thang.

The images werent being displayed, but, after I loaded the app for about the 3rd or 4th time, the images were being displayed.
I'm also setting the StretchBlt mode to HalfTone if thats of any consequence...

PsychoMark
Nov 15th, 2001, 02:47 AM
Do you shrink all nodes by 1.5? If so, why don't you just rip the original picture from Windows and shrink that? :)

Btw, just tested StretchBlt here with Windows 2000 (halftone? what? how? where?), works fine, maybe an ancient video card?

plenderj
Nov 15th, 2001, 02:54 AM
I suppose I could just shrink them... hadnt thought of that ;)

Oh and to set the StretchBlt mode, you just use the SetStretchBltMode() API :


Public Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long

Public Const BLACKONWHITE As Long = 1
Public Const WHITEONBLACK As Long = 2
Public Const COLORONCOLOR As Long = 3
Public Const HALFTONE As Long = 4


Quote from MSDN on it :

SetStretchBltMode
The SetStretchBltMode function sets the bitmap stretching mode in the specified device context.

int SetStretchBltMode(
HDC hdc, // handle to device context
int iStretchMode // bitmap stretching mode
);

Parameters
hdc
Handle to the device context.

iStretchMode
Specifies the stretching mode. It can be one of the following values: Value Description


BLACKONWHITE Performs a Boolean AND operation using the color values for the eliminated and existing pixels. If the bitmap is a monochrome bitmap, this mode preserves black pixels at the expense of white pixels.
COLORONCOLOR Deletes the pixels. This mode deletes all eliminated lines of pixels without trying to preserve their information.
HALFTONE Maps pixels from the source rectangle into blocks of pixels in the destination rectangle. The average color over the destination block of pixels approximates the color of the source pixels.
WHITEONBLACK Performs a Boolean OR operation using the color values for the eliminated and existing pixels. If the bitmap is a monochrome bitmap, this mode preserves white pixels at the expense of black pixels.

PsychoMark
Nov 15th, 2001, 03:01 AM
Shrinking would be easier/faster/less code :)



Tested again (SetStretchBltMode :eek:, great function!), works fine...

plenderj
Nov 15th, 2001, 03:08 AM
Yes shrinking would be easier.
I shall do that instead :)