IÒ‘m testing your CadImage.dll example program that iÒ‘ve downloaded from your website (http://www.cadsofttools.com/download/cadimage.zip). Im developing in VB.net so iÒ‘ve picked the demovb.net projekt. Loading DWG-files and saving as Bitmap works fine. IÒ‘ve tried a simple modifiaction to change the DefaultColor. Therefore iÒ‘ve added following code to the imports list:
Code: Select all
<DllImport("cadimage.dll", _
SetLastError:=<b>True</b>, CharSet:=CharSet.Ansi, _
ExactSpelling:=<b>True</b>, _
CallingConvention:=CallingConvention.StdCall)> _
<b>Public Shared Function</b> SetDefaultColor(<b>ByVal</b> hObject <b>As</b> IntPtr, <b>ByVal</b> ADefaultColor <b>As</b> System.Drawing.Pen) <b>As Integer
End Function</b>
Code: Select all
<b>Private</b> Sub MenuItem11_Click(<b>ByVal</b> sender <b>As</b> System.Object, <b>ByVal</b> e <b>As</b> System.EventArgs) <b>Handles</b> MenuItem11.Click
<b>Dim</b> CrDraw <b>As</b> CADDRAW = <b>New CADDRAW</b>
<b>Dim</b> K <b>As Single</b>
<b>Dim</b> AbsWidth <b>As Single</b>
<b>Dim</b> AbsHeight <b>As Single</b>
CD.FileName = ""
CD.Filter = "Bmp files (bmp)|*.bmp"
CD.ShowDialog()
GetBoxCAD(CADImage, AbsWidth, AbsHeight)
<b>If</b> AbsWidth = 0 <b>Then</b>
K = 1
<b>Else</b>
K = AbsHeight / AbsWidth
<b>End If</b>
CrDraw.Size = Len(CrDraw) 'size of CADDRAW
CrDraw.R = <b>New</b> Rect
GetClientRect(panel1, CrDraw.R)
CrDraw.R.Bottom = CrDraw.R.Right * K
CrDraw.R.Right = CrDraw.R.Right * FScale / 100
CrDraw.R.Bottom = CrDraw.R.Bottom * FScale / 100
CrDraw.DrawMode = 0 ' color mode
<b> SetDefaultColor(CADImage, New Pen(Color.White))</b>
<b>Dim</b> i = SaveCADtoBitmap(CADImage, CrDraw, CD.FileName)
<b>End Sub</b>
The first time I save the bitmap the color gets blue. The second time I save the bitmap it gets white. The third time I save the bitmap it gets turquise.
IÒ‘ve launched the compiled vbdemo.exe and try it again with the following results:
1. Call -> Color gets Brown
2. Call -> Color gets Green
3. Call -> Color gets Black
IÒ‘ve no idea how to fix this problem. Please help me.