|
-
Aug 9th, 2000, 06:09 AM
#1
I know that the Image control is the only (except for the Label) control that is not a wrapper of Windows own controls.
I.e VB draws the picture directly on the form so it doesn't have it's own window (therefor the lack of a hWnd).
But how does VB stretch the picture when you set the Stretch property to True?
I have always assumed that it uses the StretchBlt function but when I use StretchBlt to draw a picture to a PictureBox at aprox. 1/8 of the original size the image (that is mostly green) gets mostly black. But when I load the same picture to an Image control and size it to the same size you can see all the original colours.
So the question is if VB doesn't use StretchBlt to stretch the image what does it use?
-
Aug 9th, 2000, 06:41 AM
#2
transcendental analytic
I'm almost sure it's paintpicture, that also implemented in all pictureboxes and forms, it's also faster than stretchblt.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 9th, 2000, 07:32 AM
#3
Thanks Kedaman.
But PaintPicture is a VB function and must be a wrapper for some API functions. I have always assumed that it was a wrapper for BitBlt but though it can stretch an image I suppose it's not.
So the question remains; what GDI functions except for StretchBlt can you use to stretch an image?
-
Aug 9th, 2000, 08:09 AM
#4
It's StretchBlt. Both the ImageBox and PaintPicture use this API function.
-
Aug 9th, 2000, 08:22 AM
#5
transcendental analytic
ACtually I have no idea, Paintpicture is slightly faster than Stretchblt so it can't be stretchblt
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 9th, 2000, 08:34 AM
#6
Paintpicture is StretchBlt. Likewise the Line method is using the LineTo API, and showing and hiding objects is using the ShowWindow API.
-
Aug 9th, 2000, 11:07 AM
#7
Originally posted by Megatron
Paintpicture is StretchBlt
I don't think so because during my testing I actually found that PaintPicture is more then 8-10 times faster then StretchBlt. I also can't get the same result using StretchBlt as I can using PaintPicture so how can then PaintPicture use StretchBlt?
You can make the test yourself.
I just timed how long it would take to make 1000 calles to PaintPicture and how long it would take to do the same with StretchBlt.
The difference is HUGE!
-
Aug 9th, 2000, 11:25 AM
#8
StretchBlt, StretchDlBits (and I think SetBitmapDimensionsEx) are the only functions that can do this, so it must be one of them.
The difference in Timing is probably the time it takes VB to extract the function from the library.
-
Aug 9th, 2000, 03:55 PM
#9
transcendental analytic
The difference in Timing is probably the time it takes VB to extract the function from the library.
What do you mean? How would that differ if you call paintpicture or stretchblt?
And Joacim, Paintpicture is about 30% faster, you probably leaved autoredraw out
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 9th, 2000, 04:05 PM
#10
PaintPicture is located in VB and StretchBlt is located in the DLL. For the sake of argument, let's assume that PaintPicture is StretchBlt. If PaintPicture is faster, the reason is that it's faster to get the information from VB. If StretchBlt is faster (slower), it's because of the time it takes VB to extract the function from the library (DLL).
-
Aug 9th, 2000, 04:25 PM
#11
transcendental analytic
No Meg, the paintpicture method is in the VB runtimes. If it's using Stretchblt it would be slower since you have to call the runtimes and from the runtimes to GDI32
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 9th, 2000, 05:09 PM
#12
Monday Morning Lunatic
Whoa. Calm it down, guys. We've already had this conversation turn strange.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 9th, 2000, 05:13 PM
#13
Most of VB's graphical functions are based on API's. Paintpicture is one of them. Whether it's slower or faster, it's still an API call.
-
Aug 9th, 2000, 05:32 PM
#14
Lively Member
When I used stretchblt in a program of mine I noticed that when shrinking images the image becomes distorted alot (it gets black lines in it). Since you seem to be shrinking the image a lot, this might be what is happening.
Solution: Set the stretchblt properties as follows. You have to declare the SetStretchBlt API
Code:
SetStretchBltMode Picture1.hdc, 3
For you who have tested the speed...does the StretchBlt setting affect the speed much?
-
Aug 9th, 2000, 05:59 PM
#15
transcendental analytic
*away trying your suggestion*
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 9th, 2000, 06:05 PM
#16
Setting HALFTONE for the mode would probably slow it down a little because it requires more processing then the rest but the image quality is a lot better.
-
Aug 10th, 2000, 04:26 AM
#17
Kedaman: I didn't leave AutoRedraw out. In my test PaintPicture where about 8 times faster then StretchBlt.
But then again this was just ONE test which i run from the VB environment. The time difference might alter if i had compiled the program.
And I agree with you on the fact that if PaintPicture calles StretchBlt it would have run slower then calling StretchBlt directly. Just the fact that PaintPicture also have added some error checking as well would have maid the procedure slower.
Illuminator: Thank you for suggestion using SetStretchBltMode. Now at least I get the image the way I want using StretchBlt, but since PaintPicture is noticeably faster I will go with that until I find any API that runs faster.
To finish this up; Megatron, Kedaman and Illuminator: Thank you all guys for taking your time disscusing and testing my little problem. This is actually the first time I use this forum to ASK a question. 
Once again thank you all very much.
Best regards
[Edited by Joacim Andersson on 08-10-2000 at 05:31 AM]
-
Aug 10th, 2000, 05:27 PM
#18
transcendental analytic
Back with the results:
StretchBlt seems to get about 10% faster using SetStretchBltMode but still 20% slower than Painpicture which stays the same. Should confirm enough there is no connection between Stretchblt and Paintpicture.
BTW Joacim, is it the destination picturebox that autoredraw is set to true?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 11th, 2000, 06:25 AM
#19
Originally posted by kedaman
BTW Joacim, is it the destination picturebox that autoredraw is set to true?
Well of course it is!
What good would it do to set AutoRedraw on the source?
-
Aug 11th, 2000, 07:10 AM
#20
transcendental analytic
Sorry, i just wanted to be sure, but we still get different results, can you post your testing method?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 11th, 2000, 07:53 AM
#21
Actually, when I run the test again PaintPicture was 47 times faster!!!
This is what I used:
The source picture is a bitmap with the size 256x1024 pixels.
The destination size is 64x256 pixels.
The computer is a Dell laptop Pentium III 650 Mhz with 256MB RAM running Windows NT Workstation 4.0 SP6a.
I have VB6 SP3 and the code I'm using is the following:
Code:
Private Sub Command1_Click()
Dim i%
Dim sngTime As Single
With Picture1
sngTime = Timer
For i = 1 To 1000
StretchBlt .hdc, 0&, 0&, _
.ScaleWidth, .ScaleHeight, _
Picture2.hdc, 0&, 0&, _
Picture2.ScaleWidth, Picture2.ScaleHeight, _
vbSrcCopy
Next
Label1 = Timer - sngTime
End With
End Sub
The code for PaintPicture is exactly the same (I just exchanged the call to StretchBlt with PaintPicture)
The result was
StretchBlt: 229.7 sec
PaintPicture: 4.8 sec
-
Aug 11th, 2000, 09:53 AM
#22
I think it is a wrapper for BitBlt, several items in the MSDN also mention this:
The PaintPicture function, which is simply a wrapper function of the BitBlt Window API function, lets us avoid making an API declaration.
and
The PaintPicture method can be used in place of the BitBlt Windows API function to perform a wide variety of bit operations while moving a rectangular block of graphics from one position to any other position.
(Source: http://msdn.microsoft.com/library/de...ylocations.htm )
[Edited by Azzmodan on 08-11-2000 at 10:58 AM]
-
Aug 11th, 2000, 12:17 PM
#23
If it was just a wrapper for BitBlt then how does PaintPicture stretch an image when BitBlt can't?
-
Aug 11th, 2000, 02:25 PM
#24
transcendental analytic
How can you possibly use Bitblt since it lack the parameters to resize?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 11th, 2000, 03:48 PM
#25
Lively Member
you can resize it by changing the width and height of the new image.....
YC Sim
Teenage Programmer
UIN 37903254
-
Aug 11th, 2000, 04:00 PM
#26
BitBlt and StretchBlt both work with DC's, whereas PaintPicture works with Picture objects.
-
Aug 11th, 2000, 04:15 PM
#27
Hyperactive Member
I agree with Megatron, most VB graphical functions are just calls to the windows APIs. Maybe PaintPicture is faster because the code from the StretchBlt API has just been reprogrammed into the VB runtimes. I can't see PaintPicture being better coded then StretchBlt, but just easy for VB to access.
-
Aug 11th, 2000, 04:35 PM
#28
Well rino_2 if PaintPicture is faster I must say that it's better coded that StretchBlt.
-
Aug 11th, 2000, 04:56 PM
#29
Hyperactive Member
I do see the logic in that Joacim Andersson but what I'm saying is maybe its not better coded then StretchBlt but just easier for VB to access becasue its part of VBs runtimes.
-
Aug 11th, 2000, 07:02 PM
#30
transcendental analytic
Rhino, that doesn't make sense
If Vb access the stretchblt directly, you would have
App - API
while if if paintpicture access API
App - Runtimes - API
which would be at least one call more than calling stretchblt.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 12th, 2000, 02:10 AM
#31
Lively Member
maybe vb has its own stretching algo?
YC Sim
Teenage Programmer
UIN 37903254
-
Aug 12th, 2000, 05:24 AM
#32
Hyperactive Member
Thats what I'm saying ycsim. I think that the PaintPicture function isn't calling StretchBlt. I think that StretchBlt has just been reprogrammed into VBs runtimes. This would mean that no API is being used so would result in more speed.
-
Aug 12th, 2000, 07:37 AM
#33
Lively Member
yeah, since microsoft made both windows and vb
YC Sim
Teenage Programmer
UIN 37903254
-
Aug 12th, 2000, 08:05 AM
#34
Hyperactive Member
-
Aug 13th, 2000, 05:33 PM
#35
But when VB calles a function in the run time library it's calling an API. All functions in the run-time library is actually API functions.
-
Aug 13th, 2000, 05:37 PM
#36
Monday Morning Lunatic
Good point, but the runtimes are already loaded for that app, so it doesn't need to get them again...or am I not making any sense??? On a similar note, you can access VB runtime functions from non-VB apps, by using LoadLibrary().
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 13th, 2000, 05:45 PM
#37
Yeah well the GDI library is loaded at Windows start up!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|