我通过手机拍摄倾斜图像.我想在两侧的两个矩形之间切割图像的部分/部分,以找出它们之间的圆圈.我有中间部分的所有4个坐标,如(x0,y0),(x1,y1),(x2,y2),(x3,y3).
但作物功能我有类似的东西
public static Bitmap CropImage(int x, int y, int width, int height, Bitmap bitmap)
{
Bitmap croppedImage;
var originalImage = bitmap;
{
Rectangle crop = new Rectangle(x, y, width, height);
croppedImage = originalImage.Clone(crop, originalImage.PixelFormat);
} // Here we release the original resource - bitmap in memory and file on disk.
return croppedImage;
}
Run Code Online (Sandbox Code Playgroud)
但上面的功能切割部分为矩形,如第1和第2红色框所示.
我正在寻找切割第3个红色矩形所示部分的代码.我搜索了代码并找到了下面的代码
List<IntPoint> corners = new List<IntPoint>();
corners.Add(new IntPoint(x0, y0));
corners.Add(new IntPoint(x3, y3));
corners.Add(new IntPoint(x1 + 30, y1 + 20));
corners.Add(new IntPoint(x2 + 30, y2 …Run Code Online (Sandbox Code Playgroud) 如果我有一个整数变量,其最大值被指定(2,147,483,647)为32位整数,如果我将它递增1,那么它将转为(-2147483648)负值
码
int i = int.MaxValue; // i = 2,147,483,647
i = i + 1;
Response.Write(i); // i = -2,147,483,648
Run Code Online (Sandbox Code Playgroud)
有人能解释一下吗?我没有找到值变化的确切原因.
我已经log4net在Windows服务中实现了它,并且按预期工作,并根据配置设置使用当前日期创建了新文件。
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" />
</configSections>
<log4net>
<appender name="file" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="Logs\log-%utcdate{yyyy-MM-dd}.txt" />
<staticLogFileName value="false" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="5MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %level %logger - %message%newline" />
</layout>
<param name="DatePattern" value="dd.MM.yyyy'.log'" />
</appender>
<root>
<level value="ALL" />
<appender-ref ref="file" />
</root>
</log4net>
Run Code Online (Sandbox Code Playgroud)
这里的问题是,如果我的服务从最近2天开始运行,那么它将不会使用当前日期创建新文件,它会保留2天旧文件的引用并将日志添加到旧文件中,而不是在那一天创建新文件。
记录器代码就像
public static class Logger
{
public static log4net.ILog Log { get; set; }
static Logger()
{
Log = …Run Code Online (Sandbox Code Playgroud) 我有具有 2 个按钮的 c# 应用程序。首先有运行 10k 次的 for 循环。每个循环代码执行需要 1 秒才能完成。
for(int i=0;i<10000;i++){
//My running code take 1 sec for each loop
}
Run Code Online (Sandbox Code Playgroud)
有时我想通过单击另一个按钮“停止”来停止此循环/执行,但它不起作用。请建议我什么解决方案。