Hi!
It's been a while since i last posted, and now I'm in need of some expert assistance.
I've found this Control written in C# with .NET 1.0 on vbAccelerator and wanted to use it with my current project. I decided to convert the entire code to VB.NET but one of the subs contains "pointer code".
I know you can use combinations of IntPtr, Marshal and GCHandle to emulate(?) pointer handling, but I don't know how.
I would very much appreciate some help with converting this portion of the code.
More specifically those lines that contain "pointer code" (marked with red).
BitmapData bmData = glyph.LockBits(
new Rectangle(0, 0, glyph.Width, glyph.Height),
ImageLockMode.ReadWrite,
PixelFormat.Format24bppRgb);
IntPtr scan0 = bmData.Scan0;
int nOffset = bmData.Stride - glyph.Width * 3;
unsafe
{
byte * pDest = (byte *)(void *)scan0;
for (int y = 0; y < glyph.Height; ++y)
{
for (int x = 0; x < glyph.Width; ++x)
{
// Check whether transparent:
if (transColor.R == pDest[2] &&
transColor.G == pDest[1] &&
transColor.B == pDest[0])
{
// set to background colour
pDest[2] = backColor.R;
pDest[1] = backColor.G;
pDest[0] = backColor.B;
}
else
{
// Get HLS of existing colour:
Color pixel = Color.FromArgb(pDest[2], pDest[1], pDest[0]);
float lumPixel = pixel.GetBrightness();
if (lumPixel <= 0.9F)
{
float lumOffset = lumPixel / transLuminance;
lumPixel = backLuminance * lumOffset;
if (lumPixel > 1.0F)
{
lumPixel = 1.0F;
}
}
// Calculate the new colour
HLSRGB newPixel = new HLSRGB(backHue, lumPixel,
backSaturation);
// set the values:
pDest[0] = newPixel.Blue;
pDest[1] = newPixel.Green;
pDest[2] = newPixel.Red;
}
// Move to next BGRA
pDest += 3;
}
pDest += nOffset;
}
}
glyph.UnlockBits(bmData);
Any help or suggestions would be helpful.
Thanks!