本文整理汇总了C#中System.Windows.Media.Imaging.WriteableBitmap.DrawLineDDA方法的典型用法代码示例。如果您正苦于以下问题:C# WriteableBitmap.DrawLineDDA方法的具体用法?C# WriteableBitmap.DrawLineDDA怎么用?C# WriteableBitmap.DrawLineDDA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.WriteableBitmap
的用法示例。
在下文中一共展示了WriteableBitmap.DrawLineDDA方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
//.........这里部分代码省略.........
示例2: 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);
}
//.........这里部分代码省略.........
示例3: 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;
}
}