大家好,又见面了,我是你们的朋友全栈君。
i use this codeprivate void button12_Click(object sender, EventArgs e)
{
Bitmap bm = new Bitmap(pictureBox1.Image);
Image img = new Image(bm);
double x = 20;
img.Rotate(x, new Gray(255));
pictureBox9.Image = img.ToBitmap();
}
for image rotation
but it doesn’t work ,
why????
解决方案follow this link: http://www.emgu.com/wiki/files/1.4.0.0/html/ae9c1603-5135-1a2f-bd46-1dd736d4d7a8.htm[^]
You will see the Rotate method also has an argument called crop, set this argument false and all information of your image will be preserved.
I think your code should be changed into:
img = img.Rotate(x, new Gray(255),false);
Hope this will help you!
You may have to try this:
Image imgOut= img.Rotate(x, new Gray(255));
pictureBox9.Image= imgOut.ToBitmap();
I did not compile, even though i have emgucv on my machine, but I looked into their libray. I believe you should call like I said above.
see their implementation:
public Image WarpAffine(Matrix mapMatrix, int width, int height, INTER interpolationType, WARP warpType, TColor backgroundColor) where TMapDepth: new()
{
Image image = new Image(width, height);
//this call externs c function
CvInvoke.cvWarpAffine(base.Ptr, image.Ptr, mapMatrix.Ptr, (int) (interpolationType | ((INTER) ((int) warpType))), backgroundColor.MCvScalar);
return image;
}
Well, in case of “it doesn’t work”.
The problem is not that complected.
change this line
img.Rotate(x, new Gray(255));
to
img = img.Rotate(x, new Gray(255));
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/127844.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...