Constructor of array of Point
-
Hello,
I want to make a matrix like this:
System::Drawing::Drawing2D::Matrix^ L;
L=gcnew( System::Drawing::Drawing2D::Matrix::Matrix(rect,plgpts));System::Drawing::Drawing2D::Matrix^ L; L=gcnew( System::Drawing::Drawing2D::Matrix::Matrix(rect,plgpts));
rect works properly but not plgpts
plgpts is an array of Points.
So I make that:cli::arraySystem::Drawing::Point^ plgpts;
plgpts=gcnew(cli::array<System::Drawing::Point, 3>);and I have this errors:
Error C3149: 'cli::array<Type,dimension>' : cannot use this type here without a top-level '^'
Error C2748: managed array creation must have array size or array initializerI don't know how to solve them.
Could anyone of you help me??Thank you in advanced!
-
Hello,
I'll have a try:
Error C3149: 'cli::array<Type,dimension>' : cannot use this type here without a top-level '^'
System::Drawing::Point is a reference type, so you have to use the "^" to specify this:
cli::array<System::Drawing::Point^>^ plgpts;Error C2748: managed array creation must have array size or array initializer
The sizes of the dimensions (e.g. 10) are missing, you want three of them, i.e.:
plgpts=gcnew cli::array<System::Drawing::Point^, 3>(10, 10, 10);with kind regards,
Probe-Nutzer
-
Thank you for your help but it doesn't work.
I have proved 2 possibilities.
Possibility 1:
cli::arraySystem::Drawing::Point^^ plgpts;
plgpts=gcnew( cli::array<System::Drawing::Point^, 3>(1, 1, 1));Errors:
error C2564: 'cli::array<Type,dimension>' : a function-style conversion to a built-in type can only take one argument
error C2059: syntax error : ';'Possibility 2:
cli::arraySystem::Drawing::Point^^ plgpts;
plgpts=gcnew cli::array<System::Drawing::Point^, 3>(1, 1, 1);error C2440: '=' : cannot convert from 'cli::array<Type,dimension> ^' to 'cli::array<Type> ^'
The errors are different if I make gcnew with or without ().
I don't understand!
If you have another idea...
-
The dimension was missing
:cli::array<System::Drawing::Point^, 3>^ plgpts; // here plgpts=gcnew cli::array<System::Drawing::Point^, 3>(1, 1, 1);with kind regards,
Probe-Nutzer
-
Vieeelen Daaank!!!!
now it works!!!!
if there is no problem could you help me with another thing??To create a point is like that :
System::Drawing::Point^ pt1;
System::Drawing::Point^ pt2;
System::Drawing::Point^ pt3;
pt1=gcnew(System::Drawing::Point::Point(0,0));
pt2=gcnew(System::Drawing::Point::Point(0,2048));
pt3=gcnew(System::Drawing::Point::Point(1536,2048));now I don't know how add this to the array. I mean that I need in the first position the point (0,0), in the second one (0,2048) and in the third one (1536,2048).
How can I make it?Vielen Dank im Voraus!
-
german or english, which language do you prefer
?Actually, you don't need an multidimensional array here if you only want to pass it to the Matrix constructor. You just add three Points to the array like this:
cli::array<System::Drawing::Point^>^ plgpts; // no dimension means single-dimension plgpts = gcnew cli::array<System::Drawing::Point^>(3); // 3 for 3 Points // define Points System::Drawing::Point^ pt1; System::Drawing::Point^ pt2; System::Drawing::Point^ pt3; pt1=gcnew System::Drawing::Point::Point(0,0); pt2=gcnew System::Drawing::Point::Point(0,2048); pt3=gcnew System::Drawing::Point::Point(1536,2048); // add them to the array plgpts[0] = pt1; plgpts[1] = pt2; plgpts[2] = pt3;or:
cli::array<System::Drawing::Point^>^ plgpts = gcnew cli::array<System::Drawing::Point^>{pt1, pt2, pt3};or:
cli::array<System::Drawing::Point^>^ plgpts = {pt1, pt2, pt3};with kind regards,
Probe-Nutzer
-
ich weiß ein bisschen Deutsch aber nicht genug um technische Sachen zu sprechen, jjeje!!
I have proved your suggestions and all of them have the same problem:
error C2059: syntax error : ';'
3 times, one for each of those lines
pt1=gcnew (System::Drawing::Point::Point(0,0)); pt2=gcnew (System::Drawing::Point::Point(0,2048)); pt3=gcnew (System::Drawing::Point::Point(1536,2048));and too
Error C2665: 'System::Drawing::Drawing2D::Matrix::Matrix' : none of the 6 overloads could convert all the argument typesin
L=gcnew( System::Drawing::Drawing2D::Matrix::Matrix(rect,plgpts));but I supposed that it comes from the error of the points.
-
my mistake, try it like this:
// omit one ::Point in all of the Point definitions pt1=gcnew System::Drawing::Point(0,0); ...the same with Matrix:
L=gcnew System::Drawing::Drawing2D::Matrix(rect,plgpts);with kind regards,
Probe-Nutzer
-
I have made these changes and now I have got another error but I don't understand why, it says something about RectangleF and I am not using it. If I change my Rectangle into RectangleF there is also another error.
System::Drawing::Rectangle^ rect; System::Drawing::Bitmap^ img; img=gcnew System::Drawing::Bitmap(image); int nc=img->Width; int nr=img->Height; rect=System::Drawing::Rectangle(0, 0, nc, nr); L=gcnew System::Drawing::Drawing2D::Matrix(rect,plgpts);error C2664: 'System::Drawing::Drawing2D::Matrix::Matrix(System::Drawing::RectangleF,cli::array<Type,dimension> ^)' : cannot convert parameter 1 from 'System::Drawing::Rectangle ^' to 'System::Drawing::RectangleF'
if I declare it as RectangleF this is the error (the same as before)
error C2664: 'System::Drawing::Drawing2D::Matrix::Matrix(System::Drawing::RectangleF,cli::array<Type,dimension> ^)' : cannot convert parameter 1 from 'System::Drawing::RectangleF ^' to 'System::Drawing::RectangleF'
-
both of the System::Drawing::Drawing2D::Matrix constructors with Rectangle(F) arguments expect a value type as first argument. Look at the declaration:
public: Matrix ( Rectangle rect, array<Point>^ plgpts )There's no "^" next to Rectangle, therefore:
System::Drawing::Rectangle rect;is the right way to declare the rect.
with kind regards,
Probe-Nutzer
-
System::Drawing::Drawing2D::Matrix^ L; System::Drawing::Rectangle rect; cli::array<System::Drawing::Point^>^ plgpts; plgpts = gcnew cli::array<System::Drawing::Point^>(3); // 3 for 3 Points System::Drawing::Point^ pt1; System::Drawing::Point^ pt2; System::Drawing::Point^ pt3; pt1=gcnew System::Drawing::Point(0,0); pt2=gcnew System::Drawing::Point(0,2048); pt3=gcnew System::Drawing::Point(2048,1536); plgpts[0] = pt1; plgpts[1] = pt2; plgpts[2] = pt3; System::Drawing::Bitmap^ img; img=gcnew System::Drawing::Bitmap(image); int nc=img->Width; int nr=img->Height; rect=System::Drawing::Rectangle(0, 0, nc, nr); L=gcnew System::Drawing::Drawing2D::Matrix(rect,plgpts);this is what I have until now. Now that there is no problem in the first parameter there is another one with the second one. Puff!!it has no end
error C2664: 'System::Drawing::Drawing2D::Matrix::Matrix(System::Drawing::RectangleF,cli::array<Type,dimension> ^)' : cannot convert parameter 2 from 'cli::array<Type> ^' to 'cli::array<Type,dimension> ^'
-
yet another change:
System::Drawing::Drawing2D::Matrix^ L; System::Drawing::Rectangle rect; cli::array<System::Drawing::Point>^ plgpts; plgpts = gcnew cli::array<System::Drawing::Point>(3); // 3 for 3 Points System::Drawing::Point pt1; System::Drawing::Point pt2; System::Drawing::Point pt3; pt1=System::Drawing::Point(0,0); pt2=System::Drawing::Point(0,2048); pt3=System::Drawing::Point(2048,1536); plgpts[0] = pt1; plgpts[1] = pt2; plgpts[2] = pt3; System::Drawing::Bitmap^ img; img=gcnew System::Drawing::Bitmap(image); int nc=img->Width; int nr=img->Height; rect=System::Drawing::Rectangle(0, 0, nc, nr); L=gcnew System::Drawing::Drawing2D::Matrix(rect,plgpts);with kind regards,
Probe-Nutzer
-
puff!!it's unbelievable that nothing works. Now the errors are in the points
error C2440: '=' : cannot convert from 'System::Drawing::Point ^' to 'System::Drawing::Point'
The constructor of Matrix in the second parameter needs this
cli::arraySystem::Drawing::Point,1^plgptsmaybe there is something wrong with that 1, or we don't need Point to be Point^ but if I try there's the error of above.
-
change the array's initialization:
cli::array<System::Drawing::Point>^ plgpts = gcnew cli::array<System::Drawing::Point>{System::Drawing::Point(0,0), System::Drawing::Point(0,2048), System::Drawing::Point(2048,1536)};then the following lines:
plgpts = gcnew cli::array<System::Drawing::Point>(3); // 3 for 3 Points System::Drawing::Point pt1; System::Drawing::Point pt2; System::Drawing::Point pt3; pt1=System::Drawing::Point(0,0); pt2=System::Drawing::Point(0,2048); pt3=System::Drawing::Point(2048,1536); plgpts[0] = pt1; plgpts[1] = pt2; plgpts[2] = pt3;can be removed.
with kind regards,
Probe-Nutzer
-
wunderbaaaar!!!
IT WORKS!!!!!
Thank you so much for your help and dedication!!