我有一个XML文件,并希望将每个时间值替换为秒到毫秒.
例如,替换time="250" to time="250000"
.
我尝试使用以下内容
Run Code Online (Sandbox Code Playgroud)Find: time="([0-9]*)" Replace: time="$1000"
但是,这似乎不起作用 - 它取代了time="250" to time="$1000"
.我能用这种方式解决这个问题吗?
我有一个简单的 WPF 应用程序,我在其中显示一个非常大的图像 (9000x2875),并在其上显示许多小图像 (64x64)。
为此,我有一个Canvas
with one Image
,然后我以编程方式在它们到达时添加小图像。
现在我试图将合成图像的一部分保存为png
文件。我以为我会使用 aRenderTargetBitmap
来渲染Canvas
我想要的部分。我的问题是我找不到保存图像正确部分的好方法。这是我目前的黑客:
private static void SaveImage(Canvas canvas, string file, int x, int y, int width, int height)
{
//changing 0,0 on the canvas so RenderTargetBitmap works as expected.
canvas.RenderTransform = new MatrixTransform(1d, 0d, 0d, 1d, -x, -y);
canvas.UpdateLayout();
RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, 96d, 96d, Pixelformats.Pbgra32);
bmp.Render(canvas);
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmp));
using(Stream s = File.Create(file))
{
encoder.Save(s);
}
}
Run Code Online (Sandbox Code Playgroud)
这样做的明显问题是显示会因 …