have you tried (math.abs(xMin) + xMax) / 2 That is if xMin is "-200" and xMax is 400 the result is (200 + 400) / 2 = 300 EDIT: Unless you are already using negative values in X, Y then you would use ((math.abs(xMin) + xMax) / 2) - math.abs(xMin) or ((200 + 400) / 2) - 200 = 100
The Cadde
Posts
-
Graphing calculator problem (VB.NET) -
Help with PostMessageI have no clue what you are talking about with the PostMessage deal but my i suggest making a thread that handles the c++ to vb messaging like a background worker?
-
[SOLVED!!!] Trying to draw custom form bitmapI SOLVED THIS MYSELF. If you need to know how, please visit http://www.xtremevbtalk.com/showthread.php?p=1301781&posted=1#post1301781[^] ------------------------------------------------------------------------------------------ I have been bashing my head against this wall for quite some time, there is a lack of information on the subject. I am trying to draw a .png with it's alpha channel as a graphic on a form. The alpha channel works well when i draw on the existing form background but i want nothing BUT the image to be drawn. No background and any semi transparent pixels are to be drawn as is. (see through) I have tried plenty of methods until i came across http://www.codeproject.com/KB/vb/xDock.aspx[^] Now here is the question(s) i have: * What steps do i need to take to override all painting functions of a form and only use GDI and GDI+ to draw Bitmaps. * And what steps do i need to take to draw .png files with alpha transparency on that said form using GDI and GDI+ * I have the source code from the XDock example but there is very little explanation to how it works, i would love it if someone could explain HOW it does the job and how i can write my own version to understand it. At this current time my source code is a cluster**** of different approaches, the current lines i am trying to get to work is:
Public Sub SetBitmap(ByVal bitmap As Bitmap, ByVal opacity As Byte)
If Not (bitmap.PixelFormat = PixelFormat.Format32bppArgb) Then
Throw New ApplicationException("The bitmap must be 32ppp with alpha-channel.")
End If
hBitmap = bitmap.GetHbitmap(Color.FromArgb(0))
oldBitmap = Win32.SelectObject(memDc, hBitmap)
Dim size As Win32.Size = New Win32.Size(bitmap.Width, bitmap.Height)
Dim pointSource As Win32.Point = New Win32.Point(0, 0)
Dim topPos As Win32.Point = New Win32.Point(Left, Top)
Dim blend As Win32.BLENDFUNCTION = New Win32.BLENDFUNCTION
blend.BlendOp = Win32.AC_SRC_OVER
blend.BlendFlags = 0
blend.SourceConstantAlpha = opacity
blend.AlphaFormat = Win32.AC_SRC_ALPHA
Win32.UpdateLayeredWindow(Handle, screenDc, topPos, size, memDc, pointSource, 0, blend,