| C# Pointers how about VB? |
mattglet

msg:955370 | 3:27 am on Nov 15, 2005 (gmt 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); }
|
Easy_Coder

msg:955371 | 1:48 pm on Nov 15, 2005 (gmt 0) | matt try kamalpatel.net/ConvertCSharp2VB.aspx
|
Xoc

msg:955372 | 7:59 pm on Nov 15, 2005 (gmt 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#.
|
|
|