Home All Groups Group Topic Archive Search About

How to convert this code from C# to VB.NET?

Author
30 Jun 2005 4:36 PM
Chris
When I run this code in VB.NET, it hangs on the GeneratePerlinTexture call.
I think it is because I am not calling it correctly.

The C# code that works:

[DllImport("PerlinDLL.dll")]
static extern unsafe void GeneratePerlinTexture(void *ARGB32_pixels, int w,
int h);

....later...

BitmapData bmData;
Rectangle rect = new Rectangle(0,0,bmp_ARGB32.Width,bmp_ARGB32.Height);
bmData = bmp_ARGB32.LockBits(rect, ImageLockMode.ReadWrite,
PixelFormat.Format32bppArgb);
GeneratePerlinTexture(bmData.Scan0.ToPointer(), bmp_ARGB32.Width,
bmp_ARGB32.Height);
bmp_ARGB32.UnlockBits(bmData);



What I've done in VB.NET:

Declare Sub GeneratePerlinTexture Lib "Perlindll.dll" Alias
"GeneratePerlinTexture" (ByVal ARGB32_pixels As System.IntPtr, ByVal x As
Integer, ByVal y As Integer)

....later...

Dim bmData As Drawing.Imaging.BitmapData
Dim rect = New Rectangle(0, 0, my_bitmap.Width, my_bitmap.Height)
bmData = my_bitmap.LockBits(rect, Imaging.ImageLockMode.ReadWrite,
Imaging.PixelFormat.Format32bppArgb)
GeneratePerlinTexture(bmData.Scan0, my_bitmap.Width, my_bitmap.Height)
'Hangs here
my_bitmap.UnlockBits(bmData)



I have the source code for the DLL if needed.
I cannot figure it out!
Thank you if you can help.

Chris

Author
30 Jun 2005 8:37 PM
Crouchie1998
Chris

On this site somewhere is a list of C# to VB.NET convertors

Crouchie1998
BA (HONS) MCP MCSE
Author
30 Jun 2005 8:45 PM
Herfried K. Wagner [MVP]
"Crouchie1998" <crouchie1998@spamcop.net> schrieb:
> On this site somewhere is a list of C# to VB.NET convertors

?!?

The OP already supplied VB.NET code...

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
30 Jun 2005 9:09 PM
Chris
I've tried some converters, they do not work.  Some just spit out the same
c# code with no explanation.
Thank you!
Chris

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:u4$LpSbfFHA.3936@tk2msftngp13.phx.gbl...
> "Crouchie1998" <crouchie1998@spamcop.net> schrieb:
>> On this site somewhere is a list of C# to VB.NET convertors
>
> ?!?
>
> The OP already supplied VB.NET code...
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
30 Jun 2005 10:05 PM
Ryan Chavez
I would just make sure that you values being passed to the
GeneratePerlinTexture are correct.
ie Make sure that my_bitmap.Width contains the actual width of the rect.
Show quoteHide quote
"Chris" <j**@shmoe.com> wrote in message
news:u1bOVgbfFHA.2152@TK2MSFTNGP14.phx.gbl...
> I've tried some converters, they do not work.  Some just spit out the same
> c# code with no explanation.
> Thank you!
> Chris
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> news:u4$LpSbfFHA.3936@tk2msftngp13.phx.gbl...
>> "Crouchie1998" <crouchie1998@spamcop.net> schrieb:
>>> On this site somewhere is a list of C# to VB.NET convertors
>>
>> ?!?
>>
>> The OP already supplied VB.NET code...
>>
>> --
>> M S   Herfried K. Wagner
>> M V P  <URL:http://dotnet.mvps.org/>
>> V B   <URL:http://classicvb.org/petition/>
>
>
Author
1 Jul 2005 12:28 AM
David Anton
The on-line converters have a lot of issues - try our Instant VB C# to VB.NET
converter, downloadable from www.instantvb.com

David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter

Show quoteHide quote
"Chris" wrote:

> I've tried some converters, they do not work.  Some just spit out the same
> c# code with no explanation.
> Thank you!
> Chris
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> news:u4$LpSbfFHA.3936@tk2msftngp13.phx.gbl...
> > "Crouchie1998" <crouchie1998@spamcop.net> schrieb:
> >> On this site somewhere is a list of C# to VB.NET convertors
> >
> > ?!?
> >
> > The OP already supplied VB.NET code...
> >
> > --
> > M S   Herfried K. Wagner
> > M V P  <URL:http://dotnet.mvps.org/>
> > V B   <URL:http://classicvb.org/petition/>
>
>
>
Author
1 Jul 2005 7:19 AM
gabe
just a stab here, but the c# code has an unsafe void - i didnt think that
vb.net supported unsafe code.  might that be the problem?

aware of my ignorance,
gabe

Show quoteHide quote
"Chris" wrote:

> When I run this code in VB.NET, it hangs on the GeneratePerlinTexture call.
> I think it is because I am not calling it correctly.
>
> The C# code that works:
>
> [DllImport("PerlinDLL.dll")]
> static extern unsafe void GeneratePerlinTexture(void *ARGB32_pixels, int w,
> int h);
>
> ....later...
>
> BitmapData bmData;
> Rectangle rect = new Rectangle(0,0,bmp_ARGB32.Width,bmp_ARGB32.Height);
> bmData = bmp_ARGB32.LockBits(rect, ImageLockMode.ReadWrite,
> PixelFormat.Format32bppArgb);
> GeneratePerlinTexture(bmData.Scan0.ToPointer(), bmp_ARGB32.Width,
> bmp_ARGB32.Height);
> bmp_ARGB32.UnlockBits(bmData);
>
>
>
> What I've done in VB.NET:
>
> Declare Sub GeneratePerlinTexture Lib "Perlindll.dll" Alias
> "GeneratePerlinTexture" (ByVal ARGB32_pixels As System.IntPtr, ByVal x As
> Integer, ByVal y As Integer)
>
> ....later...
>
> Dim bmData As Drawing.Imaging.BitmapData
> Dim rect = New Rectangle(0, 0, my_bitmap.Width, my_bitmap.Height)
> bmData = my_bitmap.LockBits(rect, Imaging.ImageLockMode.ReadWrite,
> Imaging.PixelFormat.Format32bppArgb)
> GeneratePerlinTexture(bmData.Scan0, my_bitmap.Width, my_bitmap.Height)
> 'Hangs here
> my_bitmap.UnlockBits(bmData)
>
>
>
> I have the source code for the DLL if needed.
> I cannot figure it out!
> Thank you if you can help.
>
> Chris
>
>
>