Sign in to follow this  
Guest titan_ve

DrawImage with PointF

Recommended Posts

Hi all!!Well I'm trying to do a rotate function for an image but when I try to display the image in the shows nothing, this is my code:PointF nc1(corners[0].X,corners[0].Y); PointF nc2(corners[1].X,corners[1].Y ); PointF nc3(corners[2].X,corners[2].Y ); PointF newcorners[3] = {nc1,nc2,nc3}; const PointF* destPoints[3] = {&newcorners[0],&newcorners[1],&newcorners[2]}; //Image* bm_out = new Bitmap(wid,hgt); //Graphics gr_out(hdc); //gr_out.FromImage(bm_out); //swprintf(buf_wchmsg, L"%4.3f",corners[0].X); //graphics.DrawString(buf_wchmsg, -1, &SmallLetters, pointPower, &whiteBrush); graphics.DrawImage(imgASX,*destPoints,3); delete imgASX; imgASX = NULL;any help will be really appreaciatedRafa

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

You are calling the DrawImage incorrectly. Here are the descriptions for the parameters based on what you're trying to pass.Parametersimage[in] Pointer to an Image object that specifies the source image. destPoints[in] Pointer to an array of PointF objects that specify the area, in a parallelogram, in which to draw the image. count[in] Integer that specifies the number of elements in the destPoints array. A parallelogram is not defined by three points, it is defined by four. As well, if you intend to use a rectangular area, passing a simple RectF structure would be easier to read and perhaps more efficient.

Share this post


Link to post
Share on other sites

There are many ways to use Point or PointF (some of 'em even work!)...Here is one which does work, and is perhaps the simplest example using Point:/* Draw CRS Cheveron */ Point f1(76, 15); Point f2(119, 53); Point f3(163, 15); Point f4(119, 53); Point f5(119, 77); Point hsichv[8] = {f1, f2, f3, f4, f5}; graphics.DrawLines(whitePen, hsichv, 5);Here is a simple example using PointF: PointF gs_arrow [] = { PointF (0.0, 0.0), PointF (6.0, -5.0), PointF (6.0, 5.0), }; graphics.FillPolygon (greenBrush, gs_arrow, 3);

Share this post


Link to post
Share on other sites

Hi!!! thank u very much for ur answers guys!!!let me tell u that I could load the image with the Point array!!! =)but now,do u know any function to rotate an image given the true heading???thank you in advance!!Rafa

Share this post


Link to post
Share on other sites

Hi all!It seems that my DrawImage method just works with Point, but with PointF, i say this 'cuz I can display an image with Point, but when I try to do a rotate function with sin and cos, I cannot display anything, can u help me with this???, can u tell me where can I get the GDI+ who works whith PointF???thank u in advanceRafa

Share this post


Link to post
Share on other sites

Why not "do it" the easy way? Here is an example using PointF and the token variables for adf and heading from the sim. FLOAT64 heading = 0; FLOAT64 adfdir = 0; FLOAT64 adfndl = 0; MODULE_VAR mvheading = { PLANE_HEADING_DEGREES_MAGNETIC }; MODULE_VAR mvadfndl = { ADF_NEEDLE }; lookup_var(&mvheading); heading = mvheading.var_value.n; lookup_var(&mvadfndl); adfndl = mvadfndl.var_value.n; adfdir = (360 + adfndl + heading) ; if (adfdir > 359) { adfdir = adfdir - 360 ; } if (adfdir < 0) { adfdir = adfdir + 360; }/* Draw ADF Needle */ if (adfsignal != 0) { graphics.RotateTransform(adfdir - heading - 1); PointF adf_tail [] = { PointF (-6, 184), PointF (-6, 196), PointF (0, 196), PointF (0, 202), PointF (0, 196), PointF (6, 196), PointF (6, 184), }; PointF adf_head [] = { PointF (-5, -183), PointF (-5, -195), PointF (0, -190), PointF (5, -195), PointF (5, -183), }; graphics.DrawPolygon(whitePen, adf_tail, 7); graphics.DrawPolygon(whitePen, adf_head, 5); }

Share this post


Link to post
Share on other sites

Hi!!!It finally works!!!I had some problems because I was trying to asign floats to int, I changed everything to float and that was! =)Thanks for ur help!!!, and what about if I want to make a gauge the same size of a picture??I'm trying to change:#define GAUGE_W 272but it doesnt seem to get it done well!!can u help me again??Rafa

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this