Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 BitBlt VB.NET Style Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Fraxx Daidouji
Neophyte

8 Posts

Posted - Jul 17 2005 :  8:16:53 PM  Show Profile  Reply with Quote
Earsed.
Figured it out.
Read my last post.


Edited by - Fraxx Daidouji on Jul 19 2005 2:28:43 PM

Eric Coleman
Gladiator

USA
811 Posts

Posted - Jul 19 2005 :  11:50:04 AM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
In the code
  
Private Sub TileSet1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TileSet1.MouseUp  
Dim x As Single = e.X  
Dim y As Single = e.Y + 28  
  


Remove the "+ 28" from the 3rd line. That's why you're getting the wrong tile.


As for your second problem, your "CopyTile" function only requires a source rectangle, and does not allow you to specify the source coordinates for the BitBlt operation.

You are using
BitBlt(HDC2, 0, 0, rect.Width, rect.Height, HDC1, rect.X, rect.Y, 13369376)  


And as you can see, you're specifying the coordinate 0,0 as the destination location for the bitblt. 0,0 is the top left corner.

Go to Top of Page

Eric Coleman
Gladiator

USA
811 Posts

Posted - Jul 19 2005 :  12:18:16 PM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
Even if you fix the errors I pointed out, there is still a flaw in your object oriented design.

The function BitBlt main purpose is to simply copy a section of bytes from one device context to another device context. Since you're doing some strange stuff to even get to that level, I suspect there must be a "more correct" way to achieve this within VB.NET.

I suggest you use the DrawImage method of the Graphics class instead of trying to use a low level and unmanaged legacy API.
Go to Top of Page

Fraxx Daidouji
Neophyte

8 Posts

Posted - Jul 19 2005 :  2:19:17 PM  Show Profile  Reply with Quote
I put this right under Public Class Luna

VB:
--------------------------------------------------------------------------------
Private CurrentRect As New Rectangle
--------------------------------------------------------------------------------





VB:
--------------------------------------------------------------------------------
Private Sub TileSet1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TileSet1.MouseMove
Try
Dim RectColor As New Pen(System.Drawing.Color.White)
Dim Graphics1 As System.Drawing.Graphics
Dim x1 As Integer
Dim y1 As Integer


'calculate starting coordinates
x1 = CInt(e.X \ 32) * 32
y1 = CInt(e.Y \ 32) * 32

'If it is already hightlight then exit.
If CurrentRect.X = x1 And CurrentRect.Y = y1 Then
Exit Sub
Else
Graphics1 = TileSet1.CreateGraphics

With CurrentRect
.X = x1
.Y = y1
.Height = CInt(32)
.Width = CInt(32)
End With
End If

'clear existing
TileSet1.Refresh()

'draw box around current tile
Graphics1.DrawRectangle(RectColor, CurrentRect)


'Clean Up
RectColor = Nothing
Graphics1 = Nothing
Catch

End Try
End Sub
--------------------------------------------------------------------------------



I stoped trying to do it the way I been doing it and tried it a whole different way and it worked.

Now I don't have to use bitblt anymore to do what I wanted to do. I don't like bitblt and I am more happier do it this way. It is faster and I understand it better then bitblt. I'm not a professional at VB.NET but I can program something if I know how it works and what process it must go through. So I just stoped using bitblt, earsed all the bitblt code and everything and just started with something I understod and got it working.


Edited by - Fraxx Daidouji on Jul 19 2005 2:34:35 PM
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.11 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.