BitBlt in VB.NET

B

brian

I'm having some trouble using BitBlt in vb.net, I used it before in
vb6, and I have googled it but cant get it to work. I know I can use
the gdi+, but wanna test bitblt out for speed purposes. All I need to
do is bitblt "c:\a.jpg" onto the form. Nothing complex or special, or
on a picturebox, just a plain form. If someone could help out I'd be
really grateful.

-b
 
B

brian

Sure, following example from:
http://www.codeproject.com/KB/GDI-plus/BitBlt.aspx
works just fine when doing picturebox to picturebox, but when I try to
load "c:\a.jpg" into a bitmap (no pictureboxes involved), then bitblt
to the form it doesn't work.
The bitmap itself is fairly large, larger than the form maximized, and
scrolling/panning the bitmap around the form using GDI+ (drawimage,
and cliping drawing area to visible form) is fairly slow.
 
T

timothy

Just to clearify a bit more, I made a app just to test moving a large
image, its just an empty maximized form, with double buffering on.
code:


Dim blnMouseDown As Boolean = False
Dim curX As Long = 0
Dim curY As Long = 0
Dim isX As Long = 0
Dim isY As Long = 0
Dim curPX As Long = 0
Dim curPY As Long = 0
Dim wasPX As Long = 0
Dim wasPY As Long = 0
Dim blnFirstLoad As Boolean = True
Dim myBMP As New _
System.Drawing.Bitmap("C:\a.jpg")


Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
blnMouseDown = True
Me.Invalidate()
blnMouseDown = False
End Sub

Private Sub MyMouseMove(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
isX = e.X
isY = e.Y

If blnMouseDown Then
Me.Invalidate()
End If
End Sub

Private Sub MyMouseUp(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
blnMouseDown = False
wasPX = curPX
wasPY = curPY
End Sub

Private Sub MyMouseDown(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
curX = e.X
curY = e.Y
blnMouseDown = True
End Sub

Private Sub MyPaint(ByVal sender As Object, ByVal e _
As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

If blnMouseDown = True Or blnFirstLoad = True Then
curPX = wasPX + isX - curX
curPY = wasPY + isY - curY

e.Graphics.DrawImageUnscaled(myBMP, curPX, curPY)
End If
End Sub

Again, im just using this to test moving a large image. The image size
is 2560x1600, my screen res is 1920x1200. And when moving this image
around its pretty choppy... Which is why I wanted to try using BitBlt
instead of .DrawImage.
If anyone knows how to get smoother movement tho, i'd appreciate the
help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top