本文整理汇总了C#中System.Drawing.PointD.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# PointD.ToString方法的具体用法?C# PointD.ToString怎么用?C# PointD.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.PointD
的用法示例。
在下文中一共展示了PointD.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fold
unsafe static Bitmap Fold(Bitmap bmp, double angle)
{
double sin = Math.Sin(angle), cos = Math.Cos(angle);
double wc = (double)(bmp.Width - 1) / 2, hc = (double)(bmp.Height - 1) / 2;
double min = wc - hc, max = wc + hc;
PointD dis = new PointD(wc * (1.0 - cos), Math.Min(hc, max * sin));
Bitmap ans; BITMAP.New(out ans,Math.Max(1, (bmp.Width * cos).Ceiling()), (bmp.Height + min * sin - dis.Y).Ceiling());
BitmapData data_bmp = bmp.GetBitmapData();
BitmapData data_ans = ans.GetBitmapData();
byte* ptr_bmp = data_bmp.GetPointer();
byte* ptr_ans = data_ans.GetPointer();
PointD center = new PointD(wc, hc);
PointD now = (new PointD(0.0, 0.0)) - center;
double sqrt2 = Math.Sqrt(2.0);
for (int h = 0; h < bmp.Height; h++, now.Y += 1.0)
{
double l = (bmp.Height - 1 - h) + min;
for (int w = 0; w < bmp.Width; w++, ptr_bmp += 4, now.X += 1.0)
{
double ratio = (now / center).Hypot() / sqrt2;
int y = (h + l * ratio * sin - dis.Y).Round();
int x = (wc + (w - wc) * cos - dis.X).Round();
if (y == -1) y++;
else if (y == ans.Height) y--;
if (x == -1) x++;
else if (x == ans.Width) x--;
if (!x.AtRange(0, ans.Width - 1) || !y.AtRange(0, ans.Height - 1))
{
string msg = "error" + ans.Size.ToString() + new Point(w, h).ToString() + new Point(x, y).ToString();
msg += "\r\n" + ratio.ToString() + now.ToString() + center.ToString();
MessageBox.Show(msg);
continue;
}
int i = data_ans.Stride * y + 4 * x;
if (ptr_ans[i + 3] != 0) continue;
ptr_ans[i + 0] = ptr_bmp[0];
ptr_ans[i + 1] = ptr_bmp[1];
ptr_ans[i + 2] = ptr_bmp[2];
ptr_ans[i + 3] = ptr_bmp[3];
}
ptr_bmp += data_bmp.Stride - 4 * bmp.Width;
now.X = -center.X;
}
ptr_ans = data_ans.GetPointer();
for (int h = (hc - dis.Y).Round(), w = ans.Width / 2; h < ans.Height; h++)
{
int i = data_ans.Stride * h + 4 * w;
if (ptr_ans[i + 3] != 0) continue;
ptr_ans[i + 0] = 100;
ptr_ans[i + 1] = 100;
ptr_ans[i + 2] = 100;
ptr_ans[i + 3] = 255;
}
bmp.UnlockBits(data_bmp);
ans.UnlockBits(data_ans);
return ans;
}