标签: drawing

在.NET 2.0中将位图转换为一个多页TIFF图像

如何将一组位图转换为TIFF格式的全新图像,在这个新的tiff图像中添加所有位图作为帧?

使用.NET 2.0.

.net c# drawing tiff .net-2.0

42
推荐指数
3
解决办法
6万
查看次数

WPF中的快速2D图形

我需要在WPF中绘制大量的2D元素,例如线条和多边形.他们的立场也需要不断更新.

我在这里看了很多答案,主要建议使用DrawingVisual或覆盖OnRender函数.为了测试这些方法,我实现了一个渲染10000个椭圆的简单粒子系统,我发现使用这两种方法绘制性能仍然非常糟糕.在我的电脑上,我每秒钟不能超过5-10帧.当你考虑我使用其他技术可以轻松地平滑地抽取50万个粒子时,这是完全不可接受的.

所以我的问题是,我是否违反了WPF的技术限制,或者我错过了什么?还有其他我可以使用的东西吗?欢迎任何建议.

这里是我试过的代码

MainWindow.xaml的内容:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="500" Width="500" Loaded="Window_Loaded">
    <Grid Name="xamlGrid">

    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

MainWindow.xaml.cs的内容:

using System.Windows.Threading;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }


        EllipseBounce[]     _particles;
        DispatcherTimer     _timer = new DispatcherTimer();

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

            //particles with Ellipse Geometry
            _particles = new EllipseBounce[10000];

            //define area particles can bounce around in
            Rect stage = new Rect(0, 0, 500, …
Run Code Online (Sandbox Code Playgroud)

c# wpf performance drawing drawingvisual

37
推荐指数
2
解决办法
2万
查看次数

C# - 用于Windows窗体应用程序的BitPps的SetPixel和GetPixel的更快替代品

我正在尝试自学C#,并从各种来源听说函数get和setpixel可能非常慢.有哪些替代方案,性能改进真的那么重要吗?提前致谢!

我的一大块代码供参考:

public static Bitmap Paint(Bitmap _b, Color f)
{
  Bitmap b = new Bitmap(_b);
  for (int x = 0; x < b.Width; x++) 
  {
    for (int y = 0; y < b.Height; y++) 
    {
      Color c = b.GetPixel(x, y);
      b.SetPixel(x, y, Color.FromArgb(c.A, f.R, f.G, f.B));
    }
  }
  return b;
}
Run Code Online (Sandbox Code Playgroud)

c# drawing gdi+ getpixel

37
推荐指数
3
解决办法
5万
查看次数

什么实际处理Windows壁纸的绘图?

我正在尝试一个项目,我可以使用opengl/directx或GDI为windows 7壁纸设置动画.我调查了Windows桌面窗口是如何布局的,我想出了整体

"Progman" - >"SHELLDLL_DefView" - >"SysListView32"

层次结构.我尝试连接SysListView32的WndProc,并尝试使用注入的c#dll搞乱消息,这样当我使用控制面板 - >个性化菜单强制更改时,我可以阻止桌面绘制壁纸.这些都没有实际阻止壁纸更新,所以我认为explorer.exe实际上并不处理绘制壁纸.

为了确认这一点,我杀死了explorer.exe并设置了一个小的c#程序,它将10秒计时器上的壁纸改为随机的.正如我所料,壁纸不断变化,让我相信explorer.exe实际上并没有处理壁纸的绘制!

不幸的是,这是我完全迷失的地方.我不知道还有什么负责绘制壁纸,以及我如何能够接管它的绘图以便我可以处理绘图.我已经尝试谷歌这几天了,几乎没有进展.我希望有人能指引我朝着正确的方向前进.

c# windows opengl drawing windows-7

36
推荐指数
1
解决办法
1565
查看次数

在View上启用HW加速,在矩形覆盖中打孔

我有一个视图,它做了一些基本的绘图.在此之后,我想绘制一个打孔的矩形,这样只能看到上一个图形的一个区域.我想为我的视图启用硬件加速以获得最佳性能.

目前我有两种方法可以工作,但只有在禁用硬件加速时才有效,而另一种方法太慢.

方法1:SW加速(慢)

final int saveCount = canvas.save();

// Clip out a circle.
circle.reset();
circle.addCircle(cx, cy, radius, Path.Direction.CW);
circle.close();
canvas.clipPath(circle, Region.Op.DIFFERENCE);

// Draw the rectangle color.
canvas.drawColor(backColor);

canvas.restoreToCount(saveCount);
Run Code Online (Sandbox Code Playgroud)

这不适用于为视图启用的硬件加速,因为在此模式下不支持'canvas.clipPath'(我知道我可以强制SW渲染,但我想避免这种情况).

方法2:硬件加速(V.慢速)

// Create a new canvas.
final Bitmap b = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
final Canvas c = new Canvas(b);

// Draw the rectangle colour.
c.drawColor(backColor);

// Erase a circle.
c.drawCircle(cx, cy, radius, eraser);

// Draw the bitmap on our views  canvas.
canvas.drawBitmap(b, 0, 0, null);
Run Code Online (Sandbox Code Playgroud)

橡皮擦创建的地方

eraser = new Paint()
eraser.setColor(0xFFFFFFFF); …
Run Code Online (Sandbox Code Playgroud)

graphics android drawing hardware-acceleration porter-duff

35
推荐指数
1
解决办法
9906
查看次数

在LaTeX中绘制条形图的最佳方法是什么?

我在Stack Overflow中寻找它,就像谷歌一样,我发现了很多要绘制的包,但这似乎是一个复杂的任务,所以我想知道哪个是最合适的绘制条形图,并将数据关联到它.我也在寻找一个代码示例,但我没有运气.

charts drawing latex

34
推荐指数
3
解决办法
7万
查看次数

将System.Windows.Media.Color转换为System.Drawing.Color

private void DialogFont_Load(object sender, EventArgs e)
{
    LoadInstalledFonts();
    SetupInitialDialogSelections();
    lblPreview.ForeColor = colorPicker1.colorPickerControlView1.CurrentColor.Color;
}
Run Code Online (Sandbox Code Playgroud)

我想将值转换为System.Drawing.Color.

有任何想法吗?

c# drawing colors

30
推荐指数
2
解决办法
2万
查看次数

Opengl像素完美2D绘图

我正在研究2d引擎.它已经工作得很好,但我不断得到像素错误.

例如,我的窗口是960x540像素,我从(0,0)到(959,0)画一条线.我希望扫描线0上的每个像素都会被设置为一种颜色,但是没有:最右边的像素没有被绘制.当我垂直绘制到像素539时,同样的问题.我真的需要绘制到(960,0)或(0,540)来绘制它.

由于我出生在像素时代,我确信这不是正确的结果.当我的屏幕大于320x200像素时,我可以从0到319以及从0到199进行绘制,我的屏幕将会满.现在我最终得到一个没有绘制右/底像素的屏幕.

这可能是由于不同的原因:我期望将opengl线基元从像素绘制到包含像素,最后一个像素实际上是独占的?是吗?我的投影矩阵不正确?我有一个错误的假设,当我有一个960x540的后备缓冲区时,实际上有一个像素更多?别的什么?

有人可以帮帮我吗?我一直在研究这个问题很长一段时间,每当我认为它没问题的时候,我看了一会儿它实际上没有.

这是我的一些代码,我试图尽可能地删除它.当我调用我的线函数时,每个坐标都加上0.375,0.375,以使它在ATI和nvidia适配器上都正确.

int width = resX();
int height = resY();

for (int i = 0; i < height; i += 2)
    rm->line(0, i, width - 1, i, vec4f(1, 0, 0, 1));
for (int i = 1; i < height; i += 2)
    rm->line(0, i, width - 1, i, vec4f(0, 1, 0, 1));

// when I do this, one pixel to the right remains undrawn

void rendermachine::line(int x1, int y1, int x2, int y2, const vec4f &color) …
Run Code Online (Sandbox Code Playgroud)

opengl drawing pixel-perfect

30
推荐指数
2
解决办法
2万
查看次数

在<canvas>元素上实现平滑的草图绘制和绘图

我正在尝试使用画布创建绘图区域.我在绘制曲线时让线条看起来很光滑时遇到了麻烦,而且我的算法中的线条粗细也有变化,看起来很糟糕,因为尺寸跳跃也很多,你可以看到尺寸变化的地方.我确实在stackoverflow上找到了这个链接,但这是一个原生的iPhone应用程序,我无法搞清楚.

这是我目前的JS代码.这是在jsFiddle上运行的

var xStart,
xEnd,
yStart,
yEnd,
paint,
ctx;
$(document).ready(function (){

   ctx = $('canvas')[0].getContext("2d");
   ctx.strokeStyle = '#000';
   ctx.lineJoin="round";
   ctx.lineCap="round";
   ctx.lineWidth = 1;


   $('canvas').bind('mousedown mousemove mouseup mouseleave touchstart touchmove touchend', function(e){
        var orig = e.originalEvent;

        if(e.type == 'mousedown'){
            e.preventDefault(); e.stopPropagation();

            xStart = e.clientX - $(this).offset().left;
            yStart = e.clientY - $(this).offset().top;
            xEnd = xStart;
            yEnd = yStart;

            paint = true;
            draw(e.type);

        }else if(e.type == 'mousemove'){
            if(paint==true){
                xEnd = e.clientX - $(this).offset().left;
                yEnd = e.clientY - $(this).offset().top; …
Run Code Online (Sandbox Code Playgroud)

javascript html5 drawing canvas paint

29
推荐指数
3
解决办法
2万
查看次数

Android Paint描边宽度定位

鉴于此代码绘制一条线:

Paint p;

p = new Paint(Paint.ANTI_ALIAS_FLAG);
p.setColor(android.graphics.Color.WHITE);
p.setStyle(Paint.Style.FILL);
p.setStrokeWidth(21);

canvas.drawLine(0,50,100,50,p);
Run Code Online (Sandbox Code Playgroud)

有3种可能的描笔策略:

  • 内部:线条画在矩形(0,50,100,70)
  • 中心:该线条绘制在矩形(0,40,100,60)
  • 外面:线条画在矩形(0,30,100,50)

在实践中,似乎默认行为遵循中心策略.是否可以修改油漆以产生与其他策略相对应的结果?

android drawing paint stroke

29
推荐指数
1
解决办法
2万
查看次数