[.net] System.ArgumentException... blah

Started by
2 comments, last by machine_gun_man 19 years, 8 months ago
I have currently gone through the tough stuff of using directdraw and direct3d with gdi windows using visual basic... Now, If you don't know my dellemma... I am creating a voxel out of a couple views saving the person a lot of time creating similar 3d objects from scratch. what is stopping myself is the ... System.ArgumentException If I, along with your help defeat this elusive foe the fate of a really cool program would be saved. here is the file that contains the graphics engine the problem resides in the "voxel.from3Views(...,...,...)" procedure when it's reading color values in the for loop of doom...

Imports Microsoft.DirectX.DirectDraw
Imports Microsoft.DirectX.Direct3D
Imports Microsoft.DirectX



'here is the 3d part of my graphics library
Public Class graphics3d
    Dim d3d9device As Microsoft.DirectX.Direct3D.Device = Nothing
    Dim d3d9params As New Microsoft.DirectX.Direct3D.PresentParameters()
    Dim d3d9camera As New camera3d()
    Dim d3d9object As New sprite3d()





    Dim hwnd As IntPtr



    Sub init(ByVal window As IntPtr)

        hwnd = window

        d3d9params.BackBufferCount = 1
        d3d9params.Windowed = True
        d3d9params.SwapEffect = SwapEffect.Discard
        d3d9params.EnableAutoDepthStencil = True
        d3d9params.AutoDepthStencilFormat = DepthFormat.D16



        d3d9device = New Microsoft.DirectX.Direct3D.Device(0, DeviceType.Hardware, hwnd, Microsoft.DirectX.Direct3D.CreateFlags.HardwareVertexProcessing Or Microsoft.DirectX.Direct3D.CreateFlags.MultiThreaded, d3d9params)

        ' Now create the vertex buffer
        d3d9device.RenderState.Lighting = False
        d3d9device.RenderState.Ambient = System.Drawing.Color.White
        d3d9device.RenderState.ZBufferEnable = True
        d3d9device.RenderState.FillMode = FillMode.Solid
        d3d9device.RenderState.ShadeMode = ShadeMode.Gouraud
        d3d9device.RenderState.CullMode = Cull.CounterClockwise

        d3d9camera.init(d3d9device, 0, 0, 0, 1, 12, -20, 0, 0, 0, 45)
        d3d9object.init(d3d9device, "tank.x", 0, 0, 0)

    End Sub
    Sub uninit()
        d3d9params = Nothing
        d3d9device = Nothing
    End Sub
    Sub frame()
        'clear the back buffer to a certain color
        'd3d9device.Clear(ClearFlags.Target, System.Drawing.Color.FromArgb(255, 255, 0, 255), 1.0F, 0)
        d3d9device.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, System.Drawing.Color.FromArgb(255, 155, 155, 155), 1.0F, 0)

        'start drawing to the back buffer
        d3d9device.BeginScene()

        d3d9camera.updatecamera()
        d3d9object.render()


        'end rendering to the back buffer
        d3d9device.EndScene()

        'display the backbuffer by means of placing it into the front buffer
        d3d9device.Present()

    End Sub
End Class

Public Class camera3d
    Dim device As Microsoft.DirectX.Direct3D.Device = Nothing
    Dim d3d9worldmatrix As Microsoft.DirectX.Matrix = Nothing
    Dim vcamera As Microsoft.DirectX.Vector3 = Nothing
    Dim vtarget As Microsoft.DirectX.Vector3 = Nothing

    Dim fov As Decimal
    Public xrot As New Single()
    Public yrot As New Single()
    Public zrot As New Single()
    Dim degtorad As Decimal = Math.PI / 180


    Sub init(ByVal dev As Microsoft.DirectX.Direct3D.Device, ByVal rx As Int32, ByVal ry As Int32, ByVal rz As Int32, ByVal cx As Int32, ByVal cy As Int32, ByVal cz As Int32, ByVal tx As Int32, ByVal ty As Int32, ByVal tz As Int32, ByVal view As Int32)
        device = dev

        vcamera.X = cx
        vcamera.Y = cy
        vcamera.Z = cz

        vtarget.X = tx
        vtarget.Y = ty
        vtarget.Z = tz

        xrot = rx
        yrot = ry
        zrot = rz

        fov = view


    End Sub
    Sub uninit()
        device = Nothing
    End Sub
    Sub rotateworld(ByVal x As Integer, ByVal y As Integer, ByVal z As Integer)
        xrot = xrot + x
        yrot = yrot + y
        zrot = zrot + z
        If xrot < 0 Then xrot = xrot + 360
        If yrot < 0 Then yrot = yrot + 360
        If zrot < 0 Then zrot = zrot + 360
        If xrot > 360 Then xrot = xrot - 360
        If yrot > 360 Then yrot = yrot - 360
        If zrot > 360 Then zrot = zrot - 360


    End Sub
    Sub updatecamera()
        'device.Transform.World = Matrix.RotationX(xrot * degtorad)
        device.Transform.World = Matrix.RotationY(yrot * degtorad)
        ' d3d9device.Transform.World = Matrix.RotationZ(zrot * degtorad)
        device.Transform.View = d3d9worldmatrix.LookAtLH(vcamera, vtarget, New Microsoft.DirectX.Vector3(0, 1, 0))
        device.Transform.Projection = d3d9worldmatrix.PerspectiveFovLH(CSng(fov * degtorad), 1, 1, 100)
    End Sub
End Class

Public Class sprite3d
    Dim device As Microsoft.DirectX.Direct3D.Device = Nothing
    Dim d3d9mesh As Mesh = Nothing ' Our mesh object in sysmem
    Dim d3d9material() As Microsoft.DirectX.Direct3D.Material ' Materials for our mesh
    Dim d3d9texture() As Texture ' Textures for our mesh
    Dim x As Integer
    Dim y As Integer
    Dim z As Integer

    Sub init(ByVal dev As Microsoft.DirectX.Direct3D.Device, ByVal source As String, ByVal px As Integer, ByVal py As Integer, ByVal pz As Integer)
        device = dev
        x = px
        y = py
        z = pz

        Dim exmaterial As ExtendedMaterial() = Nothing

        ' Set the directory up two to load the right data (since the default build location is bin\debug or bin\release
        System.IO.Directory.SetCurrentDirectory((Application.StartupPath + "\..\"))

        d3d9mesh = Mesh.FromFile(source, MeshFlags.SystemMemory, device, exmaterial)


        If d3d9texture Is Nothing Then
            ' We need to extract the material properties and texture names 
            d3d9texture = New Texture(exmaterial.Length) {}
            d3d9material = New Direct3D.Material(exmaterial.Length) {}
            Dim i As Integer
            For i = 0 To exmaterial.Length - 1
                d3d9material(i) = exmaterial(i).Material3D
                ' Set the ambient color for the material (D3DX does not do this)
                d3d9material(i).Ambient = d3d9material(i).Diffuse

                ' Create the texture
                d3d9texture(i) = TextureLoader.FromFile(device, exmaterial(i).TextureFilename)
            Next i
        End If

    End Sub
    Sub uninit()
        device = Nothing
    End Sub
    Sub render()
        Dim i As Integer
        For i = 0 To d3d9material.Length - 1
            ' Set the material and texture for this subset
            device.Material = d3d9material(i)
            device.SetTexture(0, d3d9texture(i))

            ' Draw the mesh subset
            d3d9mesh.DrawSubset(i)
        Next i
    End Sub
    Sub rotate(ByVal rx, ByVal ry, ByVal rz)

    End Sub
    Sub scale(ByVal multiplier)

    End Sub
    Sub moveto(ByVal vx, ByVal vy, ByVal vz)

    End Sub
End Class

Public Class light3d

End Class

'here is the 2d part of my graphics library

Public Class voxelengine
    Dim dd9device As Microsoft.DirectX.DirectDraw.Device = Nothing
    Dim primary As Microsoft.DirectX.DirectDraw.Surface = Nothing
    Dim sdprimary As New Microsoft.DirectX.DirectDraw.SurfaceDescription()
    Dim scprimary As New Microsoft.DirectX.DirectDraw.SurfaceCaps()
    Dim secondary As Microsoft.DirectX.DirectDraw.Surface = Nothing
    Dim sdsecondary As New Microsoft.DirectX.DirectDraw.SurfaceDescription()
    Dim scsecondary As New Microsoft.DirectX.DirectDraw.SurfaceCaps()
    Dim dd9clipper As Microsoft.DirectX.DirectDraw.Clipper

    Dim window As System.Windows.Forms.Control
    Dim width As Integer
    Dim height As Integer
    Dim rectdest As Rectangle
    Public refreshColor As System.Drawing.Color = System.Drawing.Color.White


    Public Sub init(ByVal win As System.Windows.Forms.Control, ByVal wres As Integer, ByVal hres As Integer)
        window = win
        width = wres
        height = hres

        dd9device = New Microsoft.DirectX.DirectDraw.Device()
        dd9device.SetCooperativeLevel(window, CooperativeLevelFlags.Normal)

        scprimary.PrimarySurface = True
        sdprimary.SurfaceCaps = scprimary
        primary = New Microsoft.DirectX.DirectDraw.Surface(sdprimary, dd9device)

        scsecondary.OffScreenPlain = True
        sdsecondary.SurfaceCaps = scsecondary
        sdsecondary.Width = wres
        sdsecondary.Height = hres
        secondary = New Microsoft.DirectX.DirectDraw.Surface(sdsecondary, dd9device)

        dd9clipper = New Microsoft.DirectX.DirectDraw.Clipper(dd9device)
        dd9clipper.Window = window
        primary.Clipper = dd9clipper

    End Sub

    Public Sub frame()
        Try
            If ((primary Is Nothing) Or (secondary Is Nothing)) Then
                ' Check to make sure both surfaces exist.
                Exit Sub
            End If


            window.Height = IIf(window.Height < 50, 50, window.Height) ' Make sure the height is always valid.

            ' Get the new client size to Draw to.

            rectdest = New Rectangle(window.PointToScreen(New Point(window.ClientRectangle.X, window.ClientRectangle.Y + 40)), window.ClientSize)

            Try
                ' Try and Draw the offscreen surface on to the primary surface.
                primary.Draw(rectdest, secondary, DrawFlags.Wait)
            Catch e As SurfaceLostException
                ' The surface can be lost if power saving
                ' mode kicks in, or any other number of
                ' reasons.
                init(window, width, height) ' Surface was lost. Recreate them.
            End Try
        Catch f As InvalidRectangleException
            Exit Sub
        End Try
    End Sub
    Public Sub clearbuffer()
        secondary.ColorFill(refreshColor)
        secondary.DrawText(0, 100, "hello vincent... this is the voxel window", False)
    End Sub
    Public Function getBuffer() As Microsoft.DirectX.DirectDraw.Surface
        getBuffer = secondary
    End Function
    Public Function getRect() As Rectangle
        getRect = New Rectangle(0, 0, sdsecondary.Width, sdsecondary.Height)
    End Function
End Class

Public Class sideSurface
    Dim surface As Microsoft.DirectX.DirectDraw.Surface = Nothing
    Dim sdsurface As New Microsoft.DirectX.DirectDraw.SurfaceDescription()
    Dim buffer As Microsoft.DirectX.DirectDraw.Surface = Nothing
    Dim rectdest As Rectangle

    Dim converter As System.Drawing.Bitmap


    Public Sub init(ByVal secondary As Microsoft.DirectX.DirectDraw.Surface, ByVal rdest As Rectangle, ByVal file As String)

        converter = New System.Drawing.Bitmap(file)

        surface = New Microsoft.DirectX.DirectDraw.Surface(converter, sdsurface, secondary.DrawDevice)

        buffer = secondary
        rectdest = rdest
    End Sub
    Public Sub render()
        Try
            Try
                ' Try and Draw the offscreen surface on to the primary surface.
                buffer.Draw(rectdest, surface, DrawFlags.Wait)
            Catch e As SurfaceLostException
                ' The surface can be lost if power saving
                ' mode kicks in, or any other number of
                ' reasons.
                Exit Sub
            End Try
        Catch f As InvalidRectangleException
            Exit Sub
        End Try

    End Sub
    Public Function getImage() As Microsoft.DirectX.DirectDraw.Surface
        getImage = surface
    End Function
    Public Function getRect() As Rectangle
        getRect = New Rectangle(0, 0, sdsurface.Width, sdsurface.Height)
    End Function
    Public Function getGDI() As Bitmap
        getGDI = converter
    End Function
End Class


Public Class voxel
    Dim surface As Microsoft.DirectX.DirectDraw.Surface = Nothing
    Dim sdsurface As New Microsoft.DirectX.DirectDraw.SurfaceDescription()
    Dim scsurface As New Microsoft.DirectX.DirectDraw.SurfaceCaps()
    Dim buffer As Microsoft.DirectX.DirectDraw.Surface = Nothing
    Dim rectdest As Rectangle

    Dim width As Integer
    Dim height As Integer
    Dim fov As Decimal

    Dim vox(,,) As Integer
    Dim voxwidth As Integer = 0
    Dim voxlength As Integer = 0
    Dim voxheight As Integer = 0

    Public Sub init(ByVal secondary As Microsoft.DirectX.DirectDraw.Surface, ByVal rdest As Rectangle, ByVal wres As Integer, ByVal hres As Integer, ByVal fovs As Integer)
        width = wres
        height = hres
        Try
            fov = Math.Tan((fovs * (Math.PI / 180)))
        Catch e As DivideByZeroException
            fov = 1
        End Try

        buffer = secondary
        rectdest = rdest

        scsurface.OffScreenPlain = True
        sdsurface.SurfaceCaps = scsurface
        sdsurface.Width = width
        sdsurface.Height = height

        surface = New Microsoft.DirectX.DirectDraw.Surface(sdsurface, secondary.DrawDevice)

    End Sub

    Public Sub from3Views(ByVal surfacexy As Bitmap, ByVal surfaceyz As Bitmap, ByVal surfacexz As Bitmap)



        'redimension the voxel to its appropiate width length and height
        ReDim vox(surfacexy.Width, surfacexy.Height, surfaceyz.Height)
        voxwidth = surfacexy.Width
        voxlength = surfacexy.Height
        voxheight = surfaceyz.Height

        'one might usually load different sized surfaces
        'therefore as a precaution, we scale some surfaces to a specific width and height

        Dim bityz As Bitmap = surfaceyz.Clone(New Rectangle(0, 0, voxlength, voxheight), Drawing.Imaging.PixelFormat.Format32bppArgb)
        Dim bitxz As Bitmap = surfacexz.Clone(New Rectangle(0, 0, voxwidth, voxheight), Drawing.Imaging.PixelFormat.Format32bppArgb)

        Dim transxy As Color 'this is the transparent color for the x,y plane
        Dim transyz As Color 'this is the transparent color for the y,z plane
        Dim transxz As Color 'this is the transparent color for the x,z plane

        Dim x As Integer
        Dim y As Integer
        Dim z As Integer


        
        'lock all surfaces to gain access to them



        'figure out the transparent colors of each image by having a reference to its upper left corner
        transxy = surfacexy.GetPixel(0, 0)
        transyz = bityz.GetPixel(0, 0)
        transxz = bitxz.GetPixel(0, 0)

        'compare each pixel on each plane to check weather it transparent or not
        'then, if it is, make the voxel -1 for transparent

        For x = 0 To voxwidth
            For y = 0 To voxlength
                For z = 0 To voxheight
                    'is the corresponding pixels not transparent?
                    Try
                        If (surfacexy.GetPixel(x, y).ToArgb() <> transxy.ToArgb()) Then
                            If (surfaceyz.GetPixel(y, z).ToArgb() <> transyz.ToArgb()) Then
                                If (surfacexz.GetPixel(x, z).ToArgb() <> transxz.ToArgb()) Then
                                    'filler up with the top color value!
                                    vox(x, y, z) = Color.Black.ToArgb() 'xycolor.ToArgb()

                                Else
                                    ' make it blank...
                                    vox(x, y, z) = -1

                                End If
                            End If
                        End If
                    Catch e As ArgumentException

                    End Try

                Next
            Next
        Next

    End Sub
    Public Sub drawscene()
        Dim pointx As Integer
        Dim pointy As Integer

        Dim x As Integer
        Dim y As Integer
        Dim z As Integer

        Dim gdisurface As Bitmap



        surface.ColorFill(System.Drawing.Color.White)


        gdisurface = New Bitmap(surface.SurfaceDescription.Width, surface.SurfaceDescription.Height, Drawing.Imaging.PixelFormat.Format32bppArgb)


        For x = 0 To voxwidth
            For y = 0 To voxlength
                For z = 0 To voxheight

                    Try
                        pointx = ((x * (width / fov)) / y) + (width / 2)
                        pointy = ((z * (height / fov)) / y) + (height / 2)
                    Catch e As DivideByZeroException
                        pointx = width / 2
                        pointy = height / 2
                    End Try

                    If vox(x, y, z) <> -1 Then
                        gdisurface.SetPixel(pointx, pointy, System.Drawing.Color.FromArgb(vox(x, y, z)))
                    End If

                Next
            Next
        Next

        surface = New Microsoft.DirectX.DirectDraw.Surface(gdisurface, sdsurface, buffer.DrawDevice)

    End Sub
    Public Sub render()
        Try
            Try
                ' Try and Draw the offscreen surface on to the primary surface.
                buffer.Draw(rectdest, surface, DrawFlags.Wait)
            Catch e As SurfaceLostException
                ' The surface can be lost if power saving
                ' mode kicks in, or any other number of
                ' reasons.
                Exit Sub
            End Try
        Catch f As InvalidRectangleException
            Exit Sub
        End Try
    End Sub

End Class

if you slolve the problem to the voxel.from3views() procedure, you'd have there two nice graphics engines and a few graphics engine independent classes. a definite must for beginner programmers. [Edited by - machine_gun_man on August 16, 2004 9:02:50 PM]
Advertisement
Do you have the code that instantiates these Classes ?


I'm pretty sure that the problem is because one of your x/y/z co-ordinates is out of range for the Surface you used, but I'd like to see yoru full code in action.
Do you have the code that instantiates these Classes ?


I'm pretty sure that the problem is because one of your x/y/z co-ordinates is out of range for the Surface you used, but I'd like to see your full code in action.
nevermind....
I spent a few more hours attemting to solve the problem of manipulating a managed direct draw surface by means of gdi to no avail...

Therefore, i have rewrittwn every piece of code for the 2d engine
now that i'm using the actual 7th verion of directdraw i can blit pixels to the surface in piece, the only problem i'm having now is transferring the color values from the bitmap object to the direct draw surface for compatabiility of multiple file types, not just "*.bmp"

here is the graphics engine code

Imports DxVBLib 'for directdraw version 7 not managed directdrawImports Microsoft.DirectX'here is the 2d part of my graphics libraryPublic Class voxelengine    Dim dx7 As New DxVBLib.DirectX7()    Dim dd7 As DxVBLib.DirectDraw7    Dim primary As DxVBLib.DirectDrawSurface7    Dim sdprimary As New DxVBLib.DDSURFACEDESC2()    Dim secondary As DxVBLib.DirectDrawSurface7    Dim sdsecondary As New DxVBLib.DDSURFACEDESC2()    Dim dd7clipper As DxVBLib.DirectDrawClipper        Dim window As System.Windows.Forms.Control    Dim width As Integer    Dim height As Integer    Dim rectdest As RECT    Dim rectsource As RECT    Public refreshColor As System.Drawing.Color = System.Drawing.Color.White    Public Sub init(ByVal win As System.Windows.Forms.Control, ByVal wres As Integer, ByVal hres As Integer)        window = win        width = wres        height = hres        dd7 = dx7.DirectDrawCreate("")        dd7.SetCooperativeLevel(window.Handle.ToInt32(), CONST_DDSCLFLAGS.DDSCL_NORMAL)        sdprimary.lFlags = CONST_DDSURFACEDESCFLAGS.DDSD_CAPS        sdprimary.ddsCaps.lCaps = CONST_DDSURFACECAPSFLAGS.DDSCAPS_PRIMARYSURFACE        'sdprimary.lWidth = window.ClientRectangle.Width        'sdprimary.lHeight = window.ClientRectangle.Height        primary = dd7.CreateSurface(sdprimary)                sdsecondary.lFlags = CONST_DDSURFACEDESCFLAGS.DDSD_CAPS Or CONST_DDSURFACEDESCFLAGS.DDSD_WIDTH Or CONST_DDSURFACEDESCFLAGS.DDSD_HEIGHT        sdsecondary.ddsCaps.lCaps = CONST_DDSURFACECAPSFLAGS.DDSCAPS_OFFSCREENPLAIN        sdsecondary.lWidth = wres        sdsecondary.lHeight = hres        secondary = dd7.CreateSurface(sdsecondary)        rectsource.Top = 0        rectsource.Left = 0        rectsource.Right = wres        rectsource.Bottom = hres        secondary.BltColorFill(rectsource, refreshColor.ToArgb())        dd7clipper = dd7.CreateClipper(0)        dd7clipper.SetHWnd(window.Handle.ToInt32())        primary.SetClipper(dd7clipper)            End Sub    Public Sub frame()        If ((primary Is Nothing) Or (secondary Is Nothing)) Then            ' Check to make sure both surfaces exist.            dd7.RestoreAllSurfaces()            Exit Sub        End If        window.Height = IIf(window.Height < 50, 50, window.Height) ' Make sure the height is always valid.        ' Get the new client size to Draw to.        ' rectdest.Top = window.ClientRectangle.X        ' rectdest.Left = window.ClientRectangle.Y        ' rectdest.Right = window.ClientRectangle.Width        ' rectdest.Bottom = window.ClientRectangle.Height        dx7.GetWindowRect(window.Handle.ToInt32(), rectdest)        ' Try and Draw the offscreen surface on to the primary surface.        primary.Blt(rectdest, secondary, rectsource, CONST_DDBLTFLAGS.DDBLT_WAIT)    End Sub    Public Sub clearbuffer()        secondary.BltColorFill(rectsource, refreshColor.ToArgb())        secondary.DrawText(0, 100, "hello vincent... this is the voxel window", False)    End Sub    Public Function getBuffer() As DxVBLib.DirectDrawSurface7        getBuffer = secondary    End Function    Public Function getRect() As RECT        getRect = rectsource    End FunctionEnd ClassPublic Class sideSurface    Dim surface As DxVBLib.DirectDrawSurface7    Dim sdsurface As New DxVBLib.DDSURFACEDESC2()    Dim buffer As DxVBLib.DirectDrawSurface7    Dim rectdest As RECT    Dim rectsource As RECT    Dim converter As System.Drawing.Bitmap    Public Sub init(ByVal secondary As DxVBLib.DirectDrawSurface7, ByVal rdest As RECT, ByVal file As String)        buffer = secondary        rectdest = rdest        Dim x As Integer = 0        Dim y As Integer = 0        converter = New System.Drawing.Bitmap(file)        Try            sdsurface.lFlags = CONST_DDSURFACEDESCFLAGS.DDSD_CAPS Or CONST_DDSURFACEDESCFLAGS.DDSD_WIDTH Or CONST_DDSURFACEDESCFLAGS.DDSD_HEIGHT            sdsurface.ddsCaps.lCaps = CONST_DDSURFACECAPSFLAGS.DDSCAPS_OFFSCREENPLAIN            sdsurface.lWidth = converter.Width            sdsurface.lHeight = converter.Height            surface = buffer.GetDirectDraw().CreateSurface(sdsurface)            rectsource.Left = 0            rectsource.Top = 0            rectsource.Right = sdsurface.lWidth            rectsource.Bottom = sdsurface.lHeight            surface.BltColorFill(rectsource, Color.White.ToArgb())            Dim pointcolor As Integer = 0            surface.Lock(rectsource, sdsurface, CONST_DDLOCKFLAGS.DDLOCK_WAIT, 0)            For x = 0 To sdsurface.lWidth                For y = 0 To sdsurface.lHeight                    pointcolor = converter.GetPixel(x, y).ToArgb()                    surface.SetLockedPixel(x, y, pointcolor)                Next            Next            surface.Unlock(rectsource)        Catch e As Exception        End Try    End Sub    Public Sub render()                        ' Try and Draw the offscreen surface on to the primary surface.        buffer.Blt(rectdest, surface, rectsource, CONST_DDBLTFLAGS.DDBLT_WAIT)                End Sub    Public Function getImage() As DxVBLib.DirectDrawSurface7        getImage = surface    End Function    Public Function getRect() As RECT        getRect = rectsource    End Function    Public Function getGDI() As Bitmap        getGDI = converter    End FunctionEnd Class


and as you requested, one of the child windows of my program that uses both the voxelengine class and the sideimage class

Public Class Formview    Inherits System.Windows.Forms.Form    Dim side As New voxelengine()    Dim sideImage As New sideSurface()    Dim filename As String    Public Sub New()        MyBase.New()        'This call is required by the Windows Form Designer.        InitializeComponent()        'Add any initialization after the InitializeComponent() call    End Sub    'Form overrides dispose to clean up the component list.    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)        If disposing Then            If Not (components Is Nothing) Then                components.Dispose()            End If        End If        MyBase.Dispose(disposing)    End Sub    'Required by the Windows Form Designer    Private components As System.ComponentModel.IContainer    'NOTE: The following procedure is required by the Windows Form Designer    'It can be modified using the Windows Form Designer.      'Do not modify it using the code editor.    Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar    Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton    Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()        Me.ToolBar1 = New System.Windows.Forms.ToolBar()        Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton()        Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton()        Me.SuspendLayout()        '        'ToolBar1        '        Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarButton1, Me.ToolBarButton2})        Me.ToolBar1.ButtonSize = New System.Drawing.Size(100, 18)        Me.ToolBar1.DropDownArrows = True        Me.ToolBar1.Name = "ToolBar1"        Me.ToolBar1.ShowToolTips = True        Me.ToolBar1.Size = New System.Drawing.Size(292, 25)        Me.ToolBar1.TabIndex = 0        Me.ToolBar1.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right        '        'ToolBarButton1        '        Me.ToolBarButton1.Tag = "set plane"        Me.ToolBarButton1.Text = "set plane"        '        'ToolBarButton2        '        Me.ToolBarButton2.Tag = "move image"        Me.ToolBarButton2.Text = "move image"        '        'Formview        '        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)        Me.ClientSize = New System.Drawing.Size(292, 273)        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ToolBar1})        Me.Name = "Formview"        Me.ShowInTaskbar = False        Me.Text = "Formview"        Me.ResumeLayout(False)    End Sub        Private Sub Formview_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load        side.init(Me, Me.Width, Me.Height)        sideImage.init(side.getBuffer(), side.getRect(), filename)        side.clearbuffer()    End Sub    Private Sub formview_paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint        sideImage.render()        side.frame()    End Sub    Public Sub loadImage(ByVal file As String)        filename = file        Dim temp As New Bitmap(file)        Me.Width = temp.Width        Me.Height = temp.Height + 40        temp.Dispose()    End Sub    Public Function getImageSurface() As Bitmap        getImageSurface = sideImage.getGDI    End Function    Public Function getImageRect() As DxVBLib.RECT        getImageRect = sideImage.getRect    End FunctionEnd Class


remember that i've rewritten the whole graphics engine
I now no longer have the system.Argument exception, but I'm having a tough time with converting any image file type into a directdraw surface.

This topic is closed to new replies.

Advertisement