473,569 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

When I run this code in VB.NET, it hangs on the GeneratePerlinT exture call.
I think it is because I am not calling it correctly.

The C# code that works:

[DllImport("Perl inDLL.dll")]
static extern unsafe void GeneratePerlinT exture(void *ARGB32_pixels, int w,
int h);

....later...

BitmapData bmData;
Rectangle rect = new Rectangle(0,0,b mp_ARGB32.Width ,bmp_ARGB32.Hei ght);
bmData = bmp_ARGB32.Lock Bits(rect, ImageLockMode.R eadWrite,
PixelFormat.For mat32bppArgb);
GeneratePerlinT exture(bmData.S can0.ToPointer( ), bmp_ARGB32.Widt h,
bmp_ARGB32.Heig ht);
bmp_ARGB32.Unlo ckBits(bmData);

What I've done in VB.NET:

Declare Sub GeneratePerlinT exture Lib "Perlindll. dll" Alias
"GeneratePerlin Texture" (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.Heigh t)
bmData = my_bitmap.LockB its(rect, Imaging.ImageLo ckMode.ReadWrit e,
Imaging.PixelFo rmat.Format32bp pArgb)
GeneratePerlinT exture(bmData.S can0, my_bitmap.Width , my_bitmap.Heigh t)
'Hangs here
my_bitmap.Unloc kBits(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 1739
Chris

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

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2
"Crouchie19 98" <cr**********@s pamcop.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******** ******@tk2msftn gp13.phx.gbl...
"Crouchie19 98" <cr**********@s pamcop.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
GeneratePerlinT exture are correct.
ie Make sure that my_bitmap.Width contains the actual width of the rect.
"Chris" <jo*@shmoe.co m> wrote in message
news:u1******** ******@TK2MSFTN GP14.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******** ******@tk2msftn gp13.phx.gbl...
"Crouchie19 98" <cr**********@s pamcop.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******** ******@tk2msftn gp13.phx.gbl...
"Crouchie19 98" <cr**********@s pamcop.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 GeneratePerlinT exture call.
I think it is because I am not calling it correctly.

The C# code that works:

[DllImport("Perl inDLL.dll")]
static extern unsafe void GeneratePerlinT exture(void *ARGB32_pixels, int w,
int h);

....later...

BitmapData bmData;
Rectangle rect = new Rectangle(0,0,b mp_ARGB32.Width ,bmp_ARGB32.Hei ght);
bmData = bmp_ARGB32.Lock Bits(rect, ImageLockMode.R eadWrite,
PixelFormat.For mat32bppArgb);
GeneratePerlinT exture(bmData.S can0.ToPointer( ), bmp_ARGB32.Widt h,
bmp_ARGB32.Heig ht);
bmp_ARGB32.Unlo ckBits(bmData);

What I've done in VB.NET:

Declare Sub GeneratePerlinT exture Lib "Perlindll. dll" Alias
"GeneratePerlin Texture" (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.Heigh t)
bmData = my_bitmap.LockB its(rect, Imaging.ImageLo ckMode.ReadWrit e,
Imaging.PixelFo rmat.Format32bp pArgb)
GeneratePerlinT exture(bmData.S can0, my_bitmap.Width , my_bitmap.Heigh t)
'Hangs here
my_bitmap.Unloc kBits(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
3612
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 of the type the object is instantiated with. In my test program I have Option<std::string> and Option<long>. Here's the code for OptionBase and...
4
9720
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 numeric value according to an arbitrary regular expression.
6
10159
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 the data converted from the byte array into a string , is not what i expect. example: - the data returned from the socket is (byte array)...
5
18702
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
2686
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 id="subCategoryHyperLink" runat="server" NavigateUrl='<%# "subcategory.aspx?subcategoryid=" +
25
7241
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 Byte Dim b As Byte
7
29194
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
1407
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 declaration statments (first lines) e.g. Public Function ConvertCurrencyToEnglish(ByVal MyNumber As Double) As String Private Function...
3
8727
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; this produced an error
0
10737
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 inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not...
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.