Page 1 of 1

Rotate Picture using Script

Posted: Mon May 05, 2014 5:30 am
by ingoharj
I want to rotate picture continuously when certain event occur.

I have tried following code: But, there are some error which i could not able to solve. It is showing errors like: System.Drawig.Graphics does not contain a definition for 'TranslateTransform' & 'RotateTransform" and no extension method accepting a first argument of type 'System.Drawing.Grraphics' could be found(are you missing a using directive or an assembly reference?)

If you can guide me then it will be great help to resolve my long standing problem.

thanking you advance.

regards,

Arjun Gohil


namespace Neo.ApplicationFramework.Generated
{
using System.Windows.Forms;
using System;
using System.Drawing;
using Neo.ApplicationFramework.Tools;
using Neo.ApplicationFramework.Common.Graphics.Logic;
using Neo.ApplicationFramework.Controls;
using Neo.ApplicationFramework.Interfaces;


public partial class ScriptModule1
{
public static Bitmap RotateImage(Image image, float rotateAtX, float rotateAtY, float angle, bool bNoClip)
{
int W, H, X, Y;
if (bNoClip)
{
double dW = (double)image.Width;
double dH = (double)image.Height;

double degrees = Math.Abs(angle);
if (degrees <= 90)
{
double radians = 0.0174532925 * degrees;
double dSin = Math.Sin(radians);
double dCos = Math.Cos(radians);
W = (int)(dH * dSin + dW * dCos);
H = (int)(dW * dSin + dH * dCos);
X = (W - image.Width) / 2;
Y = (H - image.Height) / 2;
}
else
{
degrees -= 90;
double radians = 0.0174532925 * degrees;
double dSin = Math.Sin(radians);
double dCos = Math.Cos(radians);
W = (int)(dW * dSin + dH * dCos);
H = (int)(dH * dSin + dW * dCos);
X = (W - image.Width) / 2;
Y = (H - image.Height) / 2;
}
}
else
{
W = image.Width;
H = image.Height;
X = 0;
Y = 0;
}

//create a new empty bitmap to hold rotated image
Bitmap bmpRet = new Bitmap(W, H);
bmpRet.SetResolution(image.HorizontalResolution, image.VerticalResolution);

//make a graphics object from the empty bitmap
Graphics g = Graphics.FromImage(bmpRet);

//Put the rotation point in the "center" of the image
g.TranslateTransform(rotateAtX+X, rotateAtY+Y);

//rotate the image
g.RotateTransform(angle);

//move the image back
g.TranslateTransform(-rotateAtX - X, -rotateAtY - Y);

//draw passed in image onto graphics object
g.DrawImage(image, new PointF(0+X, 0+Y));

return bmpRet;
}
}
}

Re: Rotate Picture using Script

Posted: Wed May 14, 2014 7:35 am
by bjornidar
iX does not have all the features that ex. Visual Studio has.
So if you rescieve errors like this, it is most likely because the iX compilator doesn't support it as default.

You then would have to include some references to System.- dlls