BitBlt
BitBlt
BitBlt
BitBlt
BitBlt
BitBlt BitBlt BitBlt BitBlt BitBlt BitBlt BitBlt BitBlt
BitBlt BitBlt
BitBlt
Go Back  Xtreme Visual Basic Talk > > > BitBlt


Reply
 
Thread Tools Display Modes
  #1  
Old 07-17-2005, 08:07 PM
Norm Norm is offline
Newcomer
 
Join Date: Jul 2005
Location: Leicester, England
Posts: 17
Default BitBlt


Right. Further to my last post, I've decided that I will infact learn BitBlt and it will not beat me. I found a great tutorial on planet source code so decided to keep trying

Only problem I have at the moment, is that having coded some BitBlt, everytime I try and move the image it leaves a big smear behind. Here's the code for the simple little programme :

Code:
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer Dim PosX As Integer Dim PosY As Integer Const SRCAND = &H8800C6 Const SRCPAINT = &HEE0086 Dim Tickz As Integer Dim CurrentMove As String Private Sub Form_Load() PosX = 100 PosY = 10 End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) CurrentMove$ = "Left" End Sub Private Sub Timer1_Timer() If CurrentMove$ = "Left" Then BitBlt Picture1.hDC, PosX, PosY, 45, 45, dChr2.hDC, Tickz, 0, SRCPAINT BitBlt Picture1.hDC, PosX, PosY, 45, 45, dChr1.hDC, Tickz, 0, SRCAND End If PosX = PosX - 1 End Sub
Attached Images
File Type: jpg strange effect.JPG (12.8 KB, 24 views)
__________________
Bool isStupid = True
Reply With Quote
  #2  
Old 07-17-2005, 08:41 PM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 854
Default

You need to set the picturebox autoredraw property to true
and after you have performed all your bitblt operations, you
then need to refresh the picturebox. Picture1.Refresh


***Edit***

I forgot to mention that you really dont need to use the 2 Const
SRCCOPY and SRCPAINT. Vb has it's own built-in Const to handle
that. VBSrcCopy is the same as SRCCOPY and VBSrcPaint is the same
as SRCPAINT and VBSrcAnd is the same as SRCAND.

Last edited by VB_Alien; 07-17-2005 at 08:48 PM.
Reply With Quote
  #3  
Old 07-17-2005, 09:35 PM
passel's Avatar
passelBitBlt passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

It is smearing because you are not clearing your previous drawing.
As VB_Alien say's you will probably want to have AutoRedraw set, so that you will avoid flashing when you erase the previous picture, and drawn your object in it's new location.
How did they erase the object being moved in the tutorial your read?
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #4  
Old 07-18-2005, 02:32 PM
Norm Norm is offline
Newcomer
 
Join Date: Jul 2005
Location: Leicester, England
Posts: 17
Default

Quote:
Originally Posted by passel
How did they erase the object being moved in the tutorial your read?
By using
Code:
Picture1.cls

Whe I use this, I get various parts of the drawing flash up and then disappear. I will work it out

The tutorial is attached for all to read, as I feel it is a great file for everyone coming into BitBlt
Attached Files
File Type: zip BitBlt+Aut1509021262002.zip (58.7 KB, 15 views)
__________________
Bool isStupid = True
Reply With Quote
  #5  
Old 07-18-2005, 07:20 PM
passel's Avatar
passelBitBlt passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

It's tearing and flashing because you don't have AutoRedraw set True.
If you set AutoRedraw to True, then the Cls and bitblt occur in memory, not on the screen. If VB knows you've changed the picture (which is will since you used Cls, but VB wouldn't if you just used bitblt), then it will refresh the screen from memory when you give it a chance.
If you code is still using a timer, then when you exit the timer VB should have a chance to update the screen, and it will be refreshed all at once, so you shouldn't get flashing.

If you were using a gameloop, and avoiding VB drawing commands, then you would have to manually bitblt from the backbuffer to the screen, or issue a object.Refresh to tell VB to update the screen from the AutoRedraw buffer.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
BitBlt
BitBlt
BitBlt BitBlt
BitBlt
BitBlt
BitBlt BitBlt BitBlt BitBlt BitBlt BitBlt BitBlt
BitBlt
BitBlt
 
BitBlt
BitBlt
 
-->