本文整理汇总了C#中System.Windows.Media.Imaging.WriteableBitmap.DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C# WriteableBitmap.DrawLine方法的具体用法?C# WriteableBitmap.DrawLine怎么用?C# WriteableBitmap.DrawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.WriteableBitmap
的用法示例。
在下文中一共展示了WriteableBitmap.DrawLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PreviewTool
public override WriteableBitmap PreviewTool()
{
var bmp = new WriteableBitmap(_wvm.Brush.Width + 1, _wvm.Brush.Height + 1, 96, 96, PixelFormats.Bgra32, null);
bmp.Clear();
if (_wvm.Brush.Shape == BrushShape.Square || _wvm.Brush.Height <= 1 || _wvm.Brush.Width <= 1)
bmp.FillRectangle(0, 0, _wvm.Brush.Width, _wvm.Brush.Height, Color.FromArgb(127, 0, 90, 255));
else if (_wvm.Brush.Shape == BrushShape.Left)
bmp.DrawLine(0, 0, _wvm.Brush.Width, _wvm.Brush.Height, Color.FromArgb(127, 0, 90, 255));
else if (_wvm.Brush.Shape == BrushShape.Right)
bmp.DrawLine(0, _wvm.Brush.Height, _wvm.Brush.Width, 0, Color.FromArgb(127, 0, 90, 255));
else
bmp.FillEllipse(0, 0, _wvm.Brush.Width, _wvm.Brush.Height, Color.FromArgb(127, 0, 90, 255));
_preview = bmp;
return _preview;
}
示例2: EraseObject
public override void EraseObject(List<MyObject> list, WriteableBitmap wb, Color c)
{
wb.DrawLine(StartPoint, EndPoint, c, Width);
if (list.Contains(this))
{
list.Remove(this);
}
}
示例3: DrawAndAddLine
public void DrawAndAddLine(WriteableBitmap wb, MyLine myLine, Color color)
{
Color = color;
StartPoint = myLine.StartPoint;
EndPoint = myLine.EndPoint;
UpdateBoundaries();
wb.DrawLine(myLine.StartPoint, myLine.EndPoint, color, Width);
}
示例4: Init
public void Init(Syscalls syscalls, Core core, Runtime runtime)
{
PhoneApplicationFrame frame = (PhoneApplicationFrame)Application.Current.RootVisual;
double screenWidth = System.Windows.Application.Current.Host.Content.ActualWidth;
double screenHeight = System.Windows.Application.Current.Host.Content.ActualHeight;
if ((int)screenHeight == 0)
throw new Exception("screenHeight");
PhoneApplicationPage mainPage = (PhoneApplicationPage)frame.Content;
Image mainImage = new Image();
mainPage.Width = screenWidth;
mainPage.Height = screenHeight;
mainImage.Width = screenWidth;
mainImage.Height = screenHeight;
mainPage.Content = mainImage;
// no apparent effect on memory leaks.
runtime.RegisterCleaner(delegate()
{
MoSync.Util.RunActionOnMainThreadSync(() =>
{
mainPage.Content = null;
});
});
mBackBuffer = new WriteableBitmap(
(int)screenWidth,
(int)screenHeight);
mFrontBuffer = new WriteableBitmap(
(int)screenWidth,
(int)screenHeight);
mainImage.Source = mFrontBuffer;
mCurrentDrawTarget = mBackBuffer;
mCurrentWindowsColor = System.Windows.Media.Color.FromArgb(0xff,
(byte)(mCurrentColor >> 16),
(byte)(mCurrentColor >> 8),
(byte)(mCurrentColor));
syscalls.maSetColor = delegate(int rgb)
{
int oldColor = (int)mCurrentColor;
mCurrentColor = 0xff000000 | (uint)(rgb & 0xffffff);
mCurrentWindowsColor = System.Windows.Media.Color.FromArgb(0xff,
(byte)(mCurrentColor >> 16),
(byte)(mCurrentColor >> 8),
(byte)(mCurrentColor));
return oldColor & 0xffffff;
};
syscalls.maSetClipRect = delegate(int x, int y, int w, int h)
{
};
syscalls.maGetClipRect = delegate(int cliprect)
{
};
syscalls.maPlot = delegate(int x, int y)
{
mCurrentDrawTarget.SetPixel(x, y, (int)mCurrentColor);
};
syscalls.maUpdateScreen = delegate()
{
System.Array.Copy(mBackBuffer.Pixels, mFrontBuffer.Pixels, mFrontBuffer.PixelWidth * mFrontBuffer.PixelHeight);
InvalidateWriteableBitmapOnMainThread(mFrontBuffer);
};
syscalls.maFillRect = delegate(int x, int y, int w, int h)
{
mCurrentDrawTarget.FillRectangle(x, y, x + w, y + h, (int)mCurrentColor);
};
syscalls.maLine = delegate(int x1, int y1, int x2, int y2)
{
mCurrentDrawTarget.DrawLine(x1, y1, x2, y2, (int)mCurrentColor);
};
TextBlock textBlock = new TextBlock();
textBlock.FontSize = mCurrentFontSize;
syscalls.maDrawText = delegate(int left, int top, int str)
{
String text = core.GetDataMemory().ReadStringAtAddress(str);
if (text.Length == 0) return;
MoSync.Util.RunActionOnMainThreadSync(() =>
{
textBlock.Text = text;
textBlock.Foreground = new SolidColorBrush(mCurrentWindowsColor);
WriteableBitmap b = new WriteableBitmap(textBlock, null);
mCurrentDrawTarget.Blit(new Rect(left, top, b.PixelWidth, b.PixelHeight),
b,
new Rect(0, 0, b.PixelWidth, b.PixelHeight));
});
};
syscalls.maGetTextSize = delegate(int str)
{
//.........这里部分代码省略.........
示例5: DrawGrid
private void DrawGrid(WriteableBitmap bitmap)
{
if (CentralPoint.X == 0 && CentralPoint.Y == 0)
{
CentralPoint = new Point(bitmap.PixelWidth/2, bitmap.PixelHeight/2);
}
WriteableBitmap tempbitmap = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight, bitmap.DpiX,
bitmap.DpiY, PixelFormats.Pbgra32, bitmap.Palette);
tempbitmap.DrawLine(0, (int) CentralPoint.Y - 5, bitmap.PixelWidth, (int) CentralPoint.Y - 5, Colors.White);
tempbitmap.DrawLine(0, (int) CentralPoint.Y + 5, bitmap.PixelWidth, (int) CentralPoint.Y + 5, Colors.White);
tempbitmap.DrawLine((int) CentralPoint.X - 5, 0, (int) CentralPoint.X - 5, bitmap.PixelHeight, Colors.White);
tempbitmap.DrawLine((int) CentralPoint.X + 5, 0, (int) CentralPoint.X + 5, bitmap.PixelHeight, Colors.White);
bitmap.Blit(new Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight), tempbitmap,
new Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight));
DrawPreviewImage(bitmap);
}
示例6: Draw
/// <summary>
/// Draws the L-System to a WriteableBitmap. First computes the state string,
/// then computes a starting turtle position and then does a fold over the
/// state string, interpreting the characters as turtle commands.
/// </summary>
/// <param name="image"></param>
public void Draw(WriteableBitmap image)
{
var state = this.Step();
var start = new Turtle(
StartPos,
0.0,
ImmutableStack<Turtle.TurtleState>.Empty,
(a, b, c, d, color) => image.DrawLine(a, b, c, d, color),
Colors.Black);
state.Aggregate(start, (t, c) => {
switch (c) {
case 'F': return t.Forward(this.Distance);
case '+': return t.Rotate(this.Angle);
case '-': return t.Rotate(-this.Angle);
case '[': return t.Push();
case ']': return t.Pop();
case '1': return t.ChangeColor(Color.FromRgb(140, 80, 60));
case '2': return t.ChangeColor(Color.FromRgb(24, 180, 24));
case '3': return t.ChangeColor(Color.FromRgb(48, 220, 48));
default: return t;
}
});
}
示例7: DrawLoop_Terminator
private void DrawLoop_Terminator(WriteableBitmap bitmap, System.Drawing.Rectangle r, String name)
{
bitmap.DrawEllipse(r.Left, r.Top, r.Width + r.Left, r.Height + r.Top, color);
bitmap.DrawEllipse(r.Left + 1, r.Top + 1, r.Width - 1 + r.Left, r.Height - 1 + r.Top, color);
bitmap.DrawEllipse(r.Left + 2, r.Top + 2, r.Width - 2 + r.Left, r.Height - 2 + r.Top, color);
var x1 = r.Left + r.Width / 2;
var y1 = r.Top;
bitmap.DrawLine(x1, y1, x1 + 50, y1 - 50, color);
bitmap.DrawLine(x1, y1 - 1, x1 + 50, y1 - 1 - 50, color);
bitmap.DrawLine(x1, y1 - 2, x1 + 50, y1 - 2 - 50, color);
bitmap.DrawLine(x1 + 50, y1 - 50, x1 + 100, y1 - 50, color);
bitmap.DrawLine(x1 + 50, y1 - 50 - 1, x1 + 100, y1 - 50 - 1, color);
bitmap.DrawLine(x1 + 50, y1 - 50 - 2, x1 + 100, y1 - 50 - 2, color);
DrawText(bitmap, name, 16, x1 + 100 + 5, y1 - 50 - 20);
}
示例8: DrawCross
private void DrawCross(Point pos, WriteableBitmap img, Color color)
{
if(_showPoints)
{
if(pos.X > _baseImage.PixelWidth - 5 || pos.Y > _baseImage.PixelHeight - 5 ||
pos.X < 5 || pos.Y < 5)
return;
img.DrawLine((int)Math.Max(pos.X - 2, 0), (int)Math.Max(pos.Y - 2, 0),
(int)Math.Min(pos.X + 2, img.PixelWidth), (int)Math.Min(pos.Y + 2, img.PixelHeight), color);
img.DrawLine((int)Math.Min(pos.X + 2, img.PixelWidth), (int)Math.Max(pos.Y - 2, 0),
(int)Math.Max(pos.X - 2, 0), (int)Math.Min(pos.Y + 2, img.PixelHeight), color);
}
}
示例9: DrawGrid
private void DrawGrid(WriteableBitmap writeableBitmap)
{
System.Windows.Media.Color color = Colors.White;
color.A = 50;
if (OverlayActivated)
{
if ((SelectedOverlay != null && File.Exists(SelectedOverlay)) || OverlayUseLastCaptured)
{
if (OverlayUseLastCaptured)
{
if (File.Exists(ServiceProvider.Settings.SelectedBitmap.FileItem.LargeThumb) &&
_lastOverlay != ServiceProvider.Settings.SelectedBitmap.FileItem.LargeThumb)
{
_lastOverlay = ServiceProvider.Settings.SelectedBitmap.FileItem.LargeThumb;
_overlayImage = null;
}
}
if (_overlayImage == null)
{
BitmapImage bitmapSource = new BitmapImage();
bitmapSource.DecodePixelWidth = writeableBitmap.PixelWidth;
bitmapSource.BeginInit();
bitmapSource.UriSource = new Uri(OverlayUseLastCaptured ? _lastOverlay : SelectedOverlay);
bitmapSource.EndInit();
_overlayImage = BitmapFactory.ConvertToPbgra32Format(bitmapSource);
_overlayImage.Freeze();
}
int x = writeableBitmap.PixelWidth*OverlayScale/100;
int y = writeableBitmap.PixelHeight*OverlayScale/100;
int xx = writeableBitmap.PixelWidth*OverlayHorizontal/100;
int yy = writeableBitmap.PixelWidth*OverlayVertical/100;
System.Windows.Media.Color transpColor = Colors.White;
//set color transparency for blit only the alpha chanel is used from transpColor
if (OverlayTransparency < 100)
transpColor = System.Windows.Media.Color.FromArgb((byte) (0xff*OverlayTransparency/100d), 0xff, 0xff, 0xff);
writeableBitmap.Blit(
new Rect(0 + (x / 2) + xx, 0 + (y / 2) + yy, writeableBitmap.PixelWidth - x,
writeableBitmap.PixelHeight - y),
_overlayImage,
new Rect(0, 0, _overlayImage.PixelWidth, _overlayImage.PixelHeight), transpColor,
WriteableBitmapExtensions.BlendMode.Alpha);
}
}
switch (GridType)
{
case 1:
{
for (int i = 1; i < 3; i++)
{
writeableBitmap.DrawLine(0, (int)((writeableBitmap.Height / 3) * i),
(int)writeableBitmap.Width,
(int)((writeableBitmap.Height / 3) * i), color);
writeableBitmap.DrawLine((int)((writeableBitmap.Width / 3) * i), 0,
(int)((writeableBitmap.Width / 3) * i),
(int)writeableBitmap.Height, color);
}
writeableBitmap.SetPixel((int)(writeableBitmap.Width / 2), (int)(writeableBitmap.Height / 2), 128,
Colors.Red);
}
break;
case 2:
{
for (int i = 1; i < 10; i++)
{
writeableBitmap.DrawLine(0, (int)((writeableBitmap.Height / 10) * i),
(int)writeableBitmap.Width,
(int)((writeableBitmap.Height / 10) * i), color);
writeableBitmap.DrawLine((int)((writeableBitmap.Width / 10) * i), 0,
(int)((writeableBitmap.Width / 10) * i),
(int)writeableBitmap.Height, color);
}
writeableBitmap.SetPixel((int)(writeableBitmap.Width / 2), (int)(writeableBitmap.Height / 2), 128,
Colors.Red);
}
break;
case 3:
{
writeableBitmap.DrawLineDDA(0, 0, (int)writeableBitmap.Width,
(int)writeableBitmap.Height, color);
writeableBitmap.DrawLineDDA(0, (int)writeableBitmap.Height,
(int)writeableBitmap.Width, 0, color);
writeableBitmap.SetPixel((int)(writeableBitmap.Width / 2), (int)(writeableBitmap.Height / 2), 128,
Colors.Red);
}
break;
case 4:
{
writeableBitmap.DrawLineDDA(0, (int)(writeableBitmap.Height / 2), (int)writeableBitmap.Width,
(int)(writeableBitmap.Height / 2), color);
writeableBitmap.DrawLineDDA((int)(writeableBitmap.Width / 2), 0,
(int)(writeableBitmap.Width / 2), (int)writeableBitmap.Height, color);
writeableBitmap.SetPixel((int)(writeableBitmap.Width / 2), (int)(writeableBitmap.Height / 2), 128,
Colors.Red);
}
//.........这里部分代码省略.........
示例10: DrawGrid
private void DrawGrid(WriteableBitmap bitmap)
{
if (CentralPoint.X == 0 && CentralPoint.Y == 0)
{
CentralPoint = new System.Windows.Point(bitmap.PixelWidth / 2, bitmap.PixelHeight / 2);
}
WriteableBitmap tempbitmap = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight, bitmap.DpiX,
bitmap.DpiY, PixelFormats.Pbgra32, bitmap.Palette);
tempbitmap.DrawLine(0, (int)CentralPoint.Y - (StarWindowSize / 2), bitmap.PixelWidth, (int)CentralPoint.Y - (StarWindowSize / 2), Colors.White);
tempbitmap.DrawLine(0, (int)CentralPoint.Y + (StarWindowSize / 2), bitmap.PixelWidth, (int)CentralPoint.Y + (StarWindowSize / 2), Colors.White);
tempbitmap.DrawLine((int)CentralPoint.X - (StarWindowSize / 2), 0, (int)CentralPoint.X - (StarWindowSize / 2), bitmap.PixelHeight, Colors.White);
tempbitmap.DrawLine((int)CentralPoint.X + (StarWindowSize / 2), 0, (int)CentralPoint.X + (StarWindowSize / 2), bitmap.PixelHeight, Colors.White);
bitmap.Blit(new Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight), tempbitmap,
new Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight));
}
示例11: Init
//.........这里部分代码省略.........
x, y, w, h,
0, 0, mCurrentDrawTarget.PixelWidth, mCurrentDrawTarget.PixelHeight,
out x, out y, out w, out h);
MoSync.GraphicsUtil.ClipRectangle(
x, y, w, h,
(int)mClipRect.X, (int)mClipRect.Y, (int)mClipRect.Width, (int)mClipRect.Height,
out x, out y, out w, out h);
if (w <= 0 || h <= 0)
return;
int index = x + y * mCurrentDrawTarget.PixelWidth;
while(h-- != 0)
{
int width = w;
while(width-- != 0)
{
mCurrentDrawTarget.Pixels[index] = (int)mCurrentColor;
index++;
}
index += -w + mCurrentDrawTarget.PixelWidth;
}
};
syscalls.maLine = delegate(int x1, int y1, int x2, int y2)
{
GraphicsUtil.Point p1 = new GraphicsUtil.Point(x1, y1);
GraphicsUtil.Point p2 = new GraphicsUtil.Point(x2, y2);
if(!GraphicsUtil.ClipLine(p1, p2, (int)mClipRect.X, (int)(mClipRect.X+mClipRect.Width),
(int)mClipRect.Y, (int)(mClipRect.Y+mClipRect.Height)))
return;
mCurrentDrawTarget.DrawLine((int)p1.x, (int)p1.y, (int)p2.x, (int)p2.y, (int)mCurrentColor);
};
textBlock.FontSize = mCurrentFontSize;
syscalls.maDrawText = delegate(int left, int top, int str)
{
String text = core.GetDataMemory().ReadStringAtAddress(str);
if (text.Length == 0) return;
DrawText(text, left, top);
};
syscalls.maGetTextSize = delegate(int str)
{
String text = core.GetDataMemory().ReadStringAtAddress(str);
int textWidth = 0;
int textHeight = 0;
GetTextSize(text, out textWidth, out textHeight);
return MoSync.Util.CreateExtent(textWidth, textHeight);
};
syscalls.maDrawTextW = delegate(int left, int top, int str)
{
String text = core.GetDataMemory().ReadWStringAtAddress(str);
if (text.Length == 0) return;
DrawText(text, left, top);
};
syscalls.maGetTextSizeW = delegate(int str)
{
String text = core.GetDataMemory().ReadWStringAtAddress(str);
int textWidth = 0;
示例12: DrawGrid
private void DrawGrid(WriteableBitmap writeableBitmap)
{
Color color = Colors.White;
color.A = 50;
if (OverlayActivated)
{
if (SelectedOverlay != null && File.Exists(SelectedOverlay))
{
if (_overlayImage == null)
{
BitmapImage bitmapSource = new BitmapImage();
bitmapSource.DecodePixelWidth = writeableBitmap.PixelWidth;
bitmapSource.BeginInit();
bitmapSource.UriSource = new Uri(SelectedOverlay);
bitmapSource.EndInit();
_overlayImage = BitmapFactory.ConvertToPbgra32Format(bitmapSource);
_overlayImage.Freeze();
}
int x = writeableBitmap.PixelWidth * OverlayScale / 100;
int y = writeableBitmap.PixelHeight * OverlayScale / 100;
int xx = writeableBitmap.PixelWidth * OverlayHorizontal / 100;
int yy = writeableBitmap.PixelWidth * OverlayVertical / 100;
writeableBitmap.Blit(
new Rect(0 + (x / 2) + xx, 0 + (y / 2) + yy, writeableBitmap.PixelWidth - x,
writeableBitmap.PixelHeight - y),
_overlayImage,
new Rect(0, 0, _overlayImage.PixelWidth, _overlayImage.PixelHeight));
}
}
switch (GridType)
{
case 1:
{
for (int i = 1; i < 3; i++)
{
writeableBitmap.DrawLine(0, (int) ((writeableBitmap.Height/3)*i),
(int) writeableBitmap.Width,
(int) ((writeableBitmap.Height/3)*i), color);
writeableBitmap.DrawLine((int) ((writeableBitmap.Width/3)*i), 0,
(int) ((writeableBitmap.Width/3)*i),
(int) writeableBitmap.Height, color);
}
writeableBitmap.SetPixel((int) (writeableBitmap.Width/2), (int) (writeableBitmap.Height/2), 128,
Colors.Red);
}
break;
case 2:
{
for (int i = 1; i < 10; i++)
{
writeableBitmap.DrawLine(0, (int) ((writeableBitmap.Height/10)*i),
(int) writeableBitmap.Width,
(int) ((writeableBitmap.Height/10)*i), color);
writeableBitmap.DrawLine((int) ((writeableBitmap.Width/10)*i), 0,
(int) ((writeableBitmap.Width/10)*i),
(int) writeableBitmap.Height, color);
}
writeableBitmap.SetPixel((int) (writeableBitmap.Width/2), (int) (writeableBitmap.Height/2), 128,
Colors.Red);
}
break;
case 3:
{
writeableBitmap.DrawLineDDA(0, 0, (int) writeableBitmap.Width,
(int) writeableBitmap.Height, color);
writeableBitmap.DrawLineDDA(0, (int) writeableBitmap.Height,
(int) writeableBitmap.Width, 0, color);
writeableBitmap.SetPixel((int) (writeableBitmap.Width/2), (int) (writeableBitmap.Height/2), 128,
Colors.Red);
}
break;
case 4:
{
writeableBitmap.DrawLineDDA(0, (int) (writeableBitmap.Height/2), (int) writeableBitmap.Width,
(int) (writeableBitmap.Height/2), color);
writeableBitmap.DrawLineDDA((int) (writeableBitmap.Width/2), 0,
(int) (writeableBitmap.Width/2), (int) writeableBitmap.Height, color);
writeableBitmap.SetPixel((int) (writeableBitmap.Width/2), (int) (writeableBitmap.Height/2), 128,
Colors.Red);
}
break;
default:
break;
}
if (ShowRuler)
{
int x1 = writeableBitmap.PixelWidth*HorizontalMin/100;
int x2 = writeableBitmap.PixelWidth*HorizontalMax/100;
int y2 = writeableBitmap.PixelHeight*(100-VerticalMin)/100;
int y1 = writeableBitmap.PixelHeight*(100-VerticalMax)/100;
FillRectangle2(writeableBitmap, 0, 0, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight, Color.FromArgb(128, 128, 128, 128));
FillRectangleDeBlend(writeableBitmap, x1, y1, x2, y2, Color.FromArgb(128, 128, 128, 128));
writeableBitmap.DrawRectangle( x1, y1, x2, y2, color);
//.........这里部分代码省略.........
示例13: DrawGrid
private void DrawGrid(WriteableBitmap writeableBitmap)
{
Color color = Colors.White;
color.A = 50;
switch (GridType)
{
case 1:
{
for (int i = 1; i < 3; i++)
{
writeableBitmap.DrawLine(0, (int) ((writeableBitmap.Height/3)*i),
(int) writeableBitmap.Width,
(int) ((writeableBitmap.Height/3)*i), color);
writeableBitmap.DrawLine((int) ((writeableBitmap.Width/3)*i), 0,
(int) ((writeableBitmap.Width/3)*i),
(int) writeableBitmap.Height, color);
}
writeableBitmap.SetPixel((int) (writeableBitmap.Width/2), (int) (writeableBitmap.Height/2), 128,
Colors.Red);
}
break;
case 2:
{
for (int i = 1; i < 10; i++)
{
writeableBitmap.DrawLine(0, (int) ((writeableBitmap.Height/10)*i),
(int) writeableBitmap.Width,
(int) ((writeableBitmap.Height/10)*i), color);
writeableBitmap.DrawLine((int) ((writeableBitmap.Width/10)*i), 0,
(int) ((writeableBitmap.Width/10)*i),
(int) writeableBitmap.Height, color);
}
writeableBitmap.SetPixel((int) (writeableBitmap.Width/2), (int) (writeableBitmap.Height/2), 128,
Colors.Red);
}
break;
case 3:
{
writeableBitmap.DrawLineDDA(0, 0, (int) writeableBitmap.Width,
(int) writeableBitmap.Height, color);
writeableBitmap.DrawLineDDA(0, (int) writeableBitmap.Height,
(int) writeableBitmap.Width, 0, color);
writeableBitmap.SetPixel((int) (writeableBitmap.Width/2), (int) (writeableBitmap.Height/2), 128,
Colors.Red);
}
break;
case 4:
{
writeableBitmap.DrawLineDDA(0, (int) (writeableBitmap.Height/2), (int) writeableBitmap.Width,
(int) (writeableBitmap.Height/2), color);
writeableBitmap.DrawLineDDA((int) (writeableBitmap.Width/2), 0,
(int) (writeableBitmap.Width/2), (int) writeableBitmap.Height, color);
writeableBitmap.SetPixel((int) (writeableBitmap.Width/2), (int) (writeableBitmap.Height/2), 128,
Colors.Red);
}
break;
default:
try
{
if (GridType > 4)
{
string filename = Path.Combine(ServiceProvider.Settings.OverlayFolder,
SelectedOverlay + ".png");
if (File.Exists(filename))
{
BitmapImage bitmapSource = new BitmapImage();
bitmapSource.BeginInit();
bitmapSource.UriSource = new Uri(filename);
bitmapSource.EndInit();
WriteableBitmap overlay = BitmapFactory.ConvertToPbgra32Format(bitmapSource);
writeableBitmap.Blit(
new Rect(0, 0, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight),
overlay,
new Rect(0, 0, overlay.PixelWidth, overlay.PixelHeight));
}
}
}
catch (Exception)
{
}
break;
}
}
示例14: updateOverlay
//.........这里部分代码省略.........
}
int rectLeft = (int)((float)unionRect.Left * width / 100.0);
int rectTop = (int)((float)unionRect.Top * height / 100.0);
int rectWidth = (int)((float)unionRect.Width * width / 100.0);
int rectHeight = (int)((float)unionRect.Height * height / 100.0);
int rectRight = (int)((float)unionRect.Right * width / 100.0);
int rectBottom = (int)((float)unionRect.Bottom * height / 100.0);
if (isViewportVisible)
{
viewportLayer.Visibility = System.Windows.Visibility.Visible;
var bitmapviewport = new WriteableBitmap(width, height);
bitmapviewport.FillRectangle(0, 0, width, height, colorFromAlphaAndInt(viewportAlpha, 0));
int lineWidth2 = (int)(viewportLineWidth / 2.0);
bitmapviewport.FillRectangle(rectLeft - lineWidth2, rectTop - lineWidth2, rectRight + lineWidth2, rectBottom + lineWidth2, colorFromAlphaAndInt(viewportLineAlpha, viewportLineColor));
bitmapviewport.FillRectangle(rectLeft, rectTop, rectRight, rectBottom, System.Windows.Media.Color.FromArgb(0, 0, 0, 0));
viewportLayer.Source = bitmapviewport;
}
else
{
viewportLayer.Visibility = System.Windows.Visibility.Collapsed;
}
if (isBlinkingLineVisible)
{
lineLayer.Visibility = System.Windows.Visibility.Visible;
addAnimation();
if (width < height)
{
double pos1f = Math.Log(BarcodeLib.Scanner.MWB_SCANDIRECTION_HORIZONTAL) / Math.Log(2);
double pos2f = Math.Log(BarcodeLib.Scanner.MWB_SCANDIRECTION_VERTICAL) / Math.Log(2);
int pos1 = (int)(pos1f + 0.01);
int pos2 = (int)(pos2f + 0.01);
int bit1 = (orientation >> pos1) & 1;// bit at pos1
int bit2 = (orientation >> pos2) & 1;// bit at pos2
int mask = (bit2 << pos1) | (bit1 << pos2);
orientation = orientation & 0xc;
orientation = orientation | mask;
}
var bitmapLine = new WriteableBitmap(width, height);
int lineWidth2 = (int)(blinkingLineWidth / 2.0);
if (((orientation & BarcodeLib.Scanner.MWB_SCANDIRECTION_HORIZONTAL) > 0) || ((orientation & BarcodeLib.Scanner.MWB_SCANDIRECTION_OMNI) > 0))
{
bitmapLine.FillRectangle(rectLeft, rectTop + rectHeight / 2 - lineWidth2, rectRight, rectTop + rectHeight / 2 + lineWidth2, colorFromAlphaAndInt(blinkingLineAlpha, blinkingLineColor));
}
if (((orientation & BarcodeLib.Scanner.MWB_SCANDIRECTION_VERTICAL) > 0) || ((orientation & BarcodeLib.Scanner.MWB_SCANDIRECTION_OMNI) > 0))
{
bitmapLine.FillRectangle(rectLeft + rectWidth / 2 - lineWidth2, rectTop, rectLeft + rectWidth / 2 + lineWidth2, rectBottom, colorFromAlphaAndInt(blinkingLineAlpha, blinkingLineColor));
}
if ((orientation & BarcodeLib.Scanner.MWB_SCANDIRECTION_OMNI) > 0)
{
bitmapLine.DrawLine(rectLeft, rectTop, rectRight, rectBottom, colorFromAlphaAndInt(blinkingLineAlpha, blinkingLineColor));
bitmapLine.DrawLine(rectLeft, rectBottom, rectRight, rectTop, colorFromAlphaAndInt(blinkingLineAlpha, blinkingLineColor));
}
lineLayer.Source = bitmapLine;
}
else
{
lineLayer.Visibility = System.Windows.Visibility.Collapsed;
removeAnimation();
}
}
示例15: HighlightObject
public override void HighlightObject(bool ifHighlight, WriteableBitmap wb, Color c)
{
Color color = ifHighlight ? c : Color;
wb.DrawLine(StartPoint, EndPoint, color, Width);
}