Welcome to WebmasterWorld Guest from 50.17.5.36

Forum Moderators: ocean10000

Message Too Old, No Replies

C# Pointers

how about VB?

     
3:27 am on Nov 15, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 12, 2002
posts:1482
votes: 0


I usually can convert C# to VB no problem, but I've run across some functionality I've never used before. This snippet is part of a image converter that keeps gif transparency. I can't for the life of me figure out how to convert the C# pointers to VB.NET. Would anyone be so kind to flex their conversion muscles? I can get everything but the "byte *" and "*dstp", etc. stuff...

try {
byte *srcp;
byte *dstp;
float m = (float)src.Width / (float)dst.Width;

for (int r = 0; r < dst.Height; ++r) {
dstp = (byte *)dstbd.Scan0;
dstp += dstbd.Stride * r;

for (int c = 0; c < dst.Width; ++c) {
srcp = (byte *)srcbd.Scan0;
srcp += srcbd.Stride * (int)(r * m);
srcp += (int)(c * m);
*dstp++ = *srcp;
}
}
}
finally {
src.UnlockBits(srcbd);
}

1:48 pm on Nov 15, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 2, 2003
posts:1184
votes: 0


matt try kamalpatel.net/ConvertCSharp2VB.aspx

Xoc

7:59 pm on Nov 15, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 18, 2001
posts:1437
votes: 0


That is one of the few things C# can do that VB.NET can't. This is what is called "unsafe" code. It allows you to access memory directly. Done wrongly it can cause GP faults (hence unsafe). VB.NET's philosophy is that you shouldn't be able to do anything unsafe.

In the C# project, there is a setting at the project level that has to be set to allow unsafe code. There is no such setting in VB.NET.

The only solution from VB.NET is to call a DLL that has been written in C#.