473,320 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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
Nov 21 '05 #1
6 1720
Chris

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

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2
"Crouchie1998" <cr**********@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/>
Nov 21 '05 #3
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]" <hi***************@gmx.at> wrote in message
news:u4**************@tk2msftngp13.phx.gbl...
"Crouchie1998" <cr**********@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/>

Nov 21 '05 #4
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.
"Chris" <jo*@shmoe.com> wrote in message
news:u1**************@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]" <hi***************@gmx.at> wrote in message
news:u4**************@tk2msftngp13.phx.gbl...
"Crouchie1998" <cr**********@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/>


Nov 21 '05 #5
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

"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]" <hi***************@gmx.at> wrote in message
news:u4**************@tk2msftngp13.phx.gbl...
"Crouchie1998" <cr**********@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/>


Nov 21 '05 #6
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

"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

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
6
by: Ricardo Quintanilla | last post by:
i have a code that sends data to a socket listening over as400 platform, the socket responds to me as a "byte array". then i need to convert the "byte array" into a string. the problem is that...
5
by: simon | last post by:
I have datetime variable: Datetime tsEndTime; Should I use (DateTime): tsEndTime=(DateTime)rdr.GetValue(15) or is better to use: tsEndTime=Convert.ToDateTime(rdr.GetValue(15))
3
by: Thubaiti | last post by:
Hi, I have this code in my ASP.NET and I want to convert it to C# (code behind) <asp:Repeater id="subCategoryRepeater" runat="server"> <ItemTemplate> <ul> <li> <asp:HyperLink...
25
by: Charles Law | last post by:
I thought this was going to be straight forward, given the wealth of conversion functions in .NET, but it is proving more convoluted than imagined. Given the following <code> Dim ba(1) As...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
6
by: patang | last post by:
Could someone please tell me where am I supposed to put this code. Actually my project has two forms. I created a new module and have put the following code sent by someone. All the function...
3
by: mrajanikrishna | last post by:
Hi Friends, I am accepting a number from the user entered in a textbox. I want to assign to a variable in my code and assignt this to that variable. double num1 = (double)txtNum1.text; ...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.