Re: With a Little Help from my Friends
- From: john@xxxxxxxxxxxxxxxx (John K.Eason)
- Date: Fri, 8 Jul 2005 22:20 +0100 (BST)
Just for amusement I've run that code on an ancient '95 machine using a
233 PII processor and equally ancient ASUS AGP-V3000 graphics adaptor
under VB5. Circles 3 and 4 look identical, but are different to 1 and 2.
They're all different on my XP machine under VB6 (nVidia GeForce2 MX 400
card).
In article <damd6m$hin$1@xxxxxxxxxxxxxxxxxxxx>, Mike@xxxxxxxxxxxxxxxxx
(Mike Williams) wrote:
> *From:* "Mike Williams" <Mike@xxxxxxxxxxxxxxxxx>
>
> Hi all
>
> I'd really appreciate if you would help me out with a little problem.
> I've
> just been doing some work on my Win98 machine and I noticed that the
> StretchBlt API is not working as expected (although it works fine on my
> Win
> XP machine). The funny thing is that I'm pretty sure I remember it also
> working properly on the Win98 machine some time ago. I'm not absolutely
> sure
> if that is the case though, and I'm also not sure if I've fiddled with
> the
> video card drivers since that time. The mind plays funny tricks on you
> at my
> age :-)
>
> Anyway, the machine on which it does not work properly is Win 98 PIII
> 450
> Mhz with a Nvidia Geforce I DDR graphics card (I can't remember at the
> moment which driver version I am currently using with that).
>
> As most of you probably already know, the StretchBlt API is capable of
> working in four different stretch modes and the default mode (unless you
> change it) is mode 1. These four modes normally produce different
> results,
> and each is best suited to a particular purpose. For example, modes 3
> and 4
> are good for normal photos, mode 1 is good for line drawings (especially
> those containing rectangular grids which otherwise tend to "disappear"
> in a
> reduced size image) and mode 4 is very good for clipart and logos and
> "3d
> images" because it produces nice anti-alaised edges when you reduce an
> image. Incidentally, the VB PaintPicture method uses only use mode 3.
> (You're beginnin' to "waffle again, Mike. Get to the point will you!) .
> . .
>
> . . . anyway, as I was saying, the StretchBlt API on my Win98 machine
> refuses to work in any mode other than mode 3. You can actually set the
> mode
> to any value (1 to 4) using the SetStretchBltMode API, and if you ask
> for
> the mode you have set (using the GetStretchBltMode API or by
> alternatively
> looking at the SetStretchBltMode returned value) you will be told that
> your
> setting was accepted. However, the actual "painted" result will in all
> four
> cases look exactly the same as if it was drawn using Mode 3. This
> doesn't
> happen on my WinXP machine (and I'm almost sure it didn't used to
> happen on
> my Win98 machine). On the XP machine all four results are different, as
> you
> would expect them to be.
>
> Another slight oddity (but one which doesn't really bother me at the
> moment)
> is the fact that the LoadImage API in the User32 library (which is
> capable
> of both loading a bitmap from file and also stretching it) also seems
> to use
> a stretching technique very similar (exactly the same, looking out the
> output) to StretchBlt mode 4, and the LoadImage API works fine on both
> machines. A little odd that, but then again maybe the LoadImage API
> doesn't
> actually make use of the StretchBlt API itself. Mind you, most VB
> programmers would never use the LoadImage API because they have the VB
> LoadPicture method. (Bloody hell, he's waffling again . . . get on with
> it,
> will you Mike!)
>
> (Talking to myself now eh! That's another sign of old age creeping up!)
>
> Anyway, to get to the point (at last!) I really would appreciate it if
> as many of you as possible would kindly run the following code for me
> and let me know the result. Paste it into a VB Form containing a
> Picture Box. The code first of all draws a number of concentric circles
> into an invisible 800 x 800 pixel picture box and then it paints the
> resulting image at a smaller size four times onto the Form, using all
> four different stretch modes. On my WinXP machine it produces four
> different images (as it should do) but on my Win98 machine it produces
> four images that all look exactly the same (all looking as though they
> were drawn in mode 3). As I've said, I'm almost sure that my Win98
> machine used to produce four different images at one time, but it
> doesn't do so now! I might try using different drivers when I get the
> time.
>
> If you would like to run the code for me and then tell me the result
> you get
> (whether the four images are all the same, or all different) and the
> details
> of your machine (Windows version and make and type of bgraphics card) I
> would very much appreciate it.
>
> Cheers
>
> Mike
>
> Oops. Almost forgot the code. Here it is . . .
>
> Option Explicit
> Private Declare Function StretchBlt Lib "gdi32" _
> (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
> ByVal nWidth As Long, ByVal nHeight As Long, _
> ByVal hSrcDC As Long, ByVal xSrc As Long, _
> ByVal ySrc As Long, ByVal nSrcWidth As Long, _
> ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
> Private Declare Function SetStretchBltMode Lib "gdi32" _
> (ByVal hdc As Long, ByVal nStretchMode As Long) _
> As Long
> Private Declare Function GetStretchBltMode Lib "gdi32" _
> (ByVal hdc As Long) As Long
>
> Private Sub Form_Load()
> Dim picwide As Long, pichigh As Long
> Dim thumbwide As Long, thumbhigh As Long
> Dim x As Long, y As Long
> Dim mode As Long
> Me.Width = 6000 ' twips
> Me.Height = 6500 ' twips
> Me.Show
> Me.ScaleMode = vbPixels
> Me.AutoRedraw = True
> Picture1.Visible = False
> Picture1.ScaleMode = vbPixels
> Picture1.AutoRedraw = True
> Picture1.BorderStyle = 0
> Picture1.Move 0, 0, 800, 800
> For x = 350 To 20 Step -20
> Picture1.Circle (400, 400), x, vbBlue
> Next x
> picwide = Picture1.Width
> pichigh = Picture1.Height
> thumbwide = Me.ScaleWidth \ 2
> thumbhigh = Me.ScaleHeight \ 2
> For x = 0 To 1
> For y = 0 To 1
> mode = mode + 1
> SetStretchBltMode Me.hdc, mode
> StretchBlt Me.hdc, x * thumbwide, y * thumbhigh, _
> thumbwide, thumbhigh, Picture1.hdc, 0, 0, _
> picwide, pichigh, vbSrcCopy
> CurrentX = x * thumbwide
> CurrentY = y * thumbhigh
> Print GetStretchBltMode(Me.hdc);
> Next y
> Next x
> Me.Refresh
> End Sub
.
- Follow-Ups:
- Re: With a Little Help from my Friends
- From: Mike Williams
- Re: With a Little Help from my Friends
- References:
- With a Little Help from my Friends
- From: Mike Williams
- With a Little Help from my Friends
- Prev by Date: Re: With a Little Help from my Friends
- Next by Date: Re: With a Little Help from my Friends
- Previous by thread: Re: With a Little Help from my Friends
- Next by thread: Re: With a Little Help from my Friends
- Index(es):
Relevant Pages
|