public struct VbPointer<T>
where T : IConvertible
Public Structure VbPointer(Of T As IConvertible)
Dim instance As VbPointer(Of T)
generic<typename T>
where T : IConvertible
public value class VbPointer
[<SealedAttribute>]
type VbPointer<'T when 'T : IConvertible> =
struct
inherit ValueType
end
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
' C# original source code that use pointers to invert the colors of a image:
'
' private static Image InvertImageColorsUnsafe(Image img) {
'
' Bitmap bmp = new Bitmap(img);
'
' //Format is BGRA, NOT ARGB.
' BitmapData bmData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
' ImageLockMode.ReadWrite,
' PixelFormat.Format32bppArgb);
'
' int stride = bmData.Stride;
' IntPtr Scan0 = bmData.Scan0;
'
' unsafe {
' byte* p = (byte*)(void*)Scan0;
'
' int nOffset = stride - bmp.Width * 4;
' int nWidth = bmp.Width;
'
' for (int y = 0; y < bmp.Height; y++) {
' for (int x = 0; x < nWidth; x++) {
' p[0] = (byte)(255 - p[0]); // Red
' p[1] = (byte)(255 - p[1]); // Green
' p[2] = (byte)(255 - p[2]); // Blue
' //p[3] is alpha, don't want to invert alpha
' p += 4;
' }
' p += nOffset;
' }
' }
'
' bmp.UnlockBits(bmData);
' return (Image)bmp;
' }
' VB.NET equivalency using the VbPointer class:
Private Shared Function InvertImageColorsUnsafe(originalImg As Image) As Image
Dim bmp As New Bitmap(originalImg)
' Format is BGRA, NOT ARGB.
Dim bmData As BitmapData =
bmp.LockBits(New Rectangle(0, 0, bmp.Width, bmp.Height),
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb)
Dim stride As Integer = bmData.Stride
Dim p As New VbPointer(Of Byte)(bmData.Scan0)
Dim nOffset As Integer = stride - bmp.Width * 4
Dim nWidth As Integer = bmp.Width
For y As Integer = 0 To (bmp.Height - 1)
For x As Integer = 0 To (nWidth - 1)
p(0) = CByte(255 - p(0)) ' Red
p(1) = CByte(255 - p(1)) ' Green
p(2) = CByte(255 - p(2)) ' Blue
'p(3) is alpha, don't want to invert alpha
p += 4
Next
p += nOffset
Next
bmp.UnlockBits(bmData)
Return DirectCast(bmp, Image)
End Function
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
VbPointerT | Initializes a new instance of the VbPointerT struct. |
Value | Gets or sets the value in the pointer. |
Equals |
Determines whether the specified Object is equal to this instance.
(Overrides ValueTypeEquals(Object)) |
GetHashCode |
Returns a hash code for this instance.
(Overrides ValueTypeGetHashCode) |
GetType | Gets the Type of the current instance. (Inherited from Object) |
ReferenceEquals | Determines whether the specified Object instances are the same instance. |
ToString |
Returns a String that represents the current object.
(Overrides ValueTypeToString) |
Addition(VbPointerT, Int32) | Implements the sum operator. |
Equality(VbPointerT, VbPointerT) | Compares two VbPointerT. |
Inequality(VbPointerT, VbPointerT) | Compares two VbPointerT. |
Subtraction(VbPointerT, Int32) | Implements the minus operator. |
CanConvertTo |
Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions) |
CanConvertToT |
Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions) |
ConvertToT |
Converts an object to the specified target type.
If the conversion fails, an exception is thrown.
(Defined by ObjectExtensions) |
ConvertToT |
Converts an object to the specified target type.
If the conversion fails, returns the specified default value.
(Defined by ObjectExtensions) |
IsDisposable |
Determines whether the specified object is a disposable type
(i.e., it implements IDisposable interface).
(Defined by ObjectExtensions) |
Speak |
Speaks the string representation of the source object by using the
operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions) |
Speak |
Speaks the string representation of the source object by using the
operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions) |
ThrowIfNullTException |
Throws the specified exception if the source object is null.
(Defined by ObjectExtensions) |