Hello everyone, i'm porting an application from C# to C++, and i find the syntax and all that of C++ rather cumbersome (though C/C++ was my first language).
I have a very specific question, and another few more-or-less general ones.
The specific question:
In C#:
Bitmap image;
BitmapData ImageData;
ImageData=image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, image.PixelFormat);
byte* walker = (byte*)ImageData.Scan0;
//Sift through the bytes using a for
for(int i=0; i< image.Height*ImageData.Stride;i++)
{
string bit = Convert.ToString(*walker, 2);
//Get the byte represented by walker, by dereferencing it
//and convert the number (e.g. 235) to base 2, getting
//a string of 1's and 0's.
walker++;
//Increment the pointer
}
Easy enough, huh?
Here's the C++ version, where i'm having difficulties:
Bitmap^ image;
BitmapData^ ImageData;
ImageData=image->LockBits(Rectangle(0,0,image->Width,image->Height),ImageLockMode::ReadWrite,image->PixelFormat);
IntPtr walker=ImageData->Scan0;
for(int i=0; i<Image->Height * ImageData-> Stride; i++)
{
//1.How do i get the value at IntPtr?? Dereference does
//not work.
//2.How do i increment the pointer?
}
So my problems are, how do i increment IntPtr, and how do i get the value at its address (dereference) ?.
Thank you.
And now, general questions:
1. Why do i need to put the '^' sign when declaring stuff.
String^ myString;
2.How do i know when to use scope resolution operator :: or arrow sign -> ?
3.Why does this instruction:
if(!Regex::IsMatch(myString, "\[[0-9]{8}\]"))
{ //something }
give a warning that ']' and '[' are unrecognized escape characters? (in C# it worked...)
Thank you very much!