views:

239

answers:

2

There is an FastBitmap class for C#, that lets you acces and modify pixel information of am bitmap. I have already used it in some C# project, but I need it now in VB.NET. The problem is that that class uses unsafe code, that is not supported in VB.NET.

The question is. Can I compile the FastBitmap class in a dll and use it in VB.NET?

[EDIT] Or is there some library that can be used to modfy pixel data in VB.NET?

+2  A: 

Fast answer, yes. By the way, did you try it?

eKek0
No, I didn't try it. I was busy at the moment that I came with the idea and didn't have time to experiment.
Aaron de Windt
+2  A: 

Yes, you can do that.

If the class doesn't expose any unsafe features in its public interface (e.g. method taking a pointer) then you shouldn't have any problems using it from VB.NET. The common language runtime (CLR) supports unsafe code, so C# doesn't do any magic when you write unsafe programs.

If you wanted, you could also reimplement the FastBitmap class in VB.NET using the Marshall class, which gives you fast access to memory using a standard .NET interface accessible from VB.NET as well. But the ability to mix multiple languages in a single project is a great advantage of .NET.

Tomas Petricek