I have to write a faster canvas in wpf for my upcoming project. The canvas will be similar to adobe photoshop canvas. It should have layers and objects and also direct drawing methods.
I am thinking to write the canvas in vc++ or in c# and use it into wpf. Is it a good idea to write the canvas in any other language and use it with wpf? Or should I extend the existing canvas of wpf? If using other language, then vc++ will be better or c#?
Thanks
You are looking for the writeable bitmap - see http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx
This allows direct pixel level manipulation of graphical data, basically designed for what you want to do.
I suggest you use QT. :)
Related
I want to programatically draw a few simple 2D shapes in a WPF application. Which control should I use for that? I've heard that Canvas can do that but that it's mostly designed to be a container for other controls and not a "drawing" canvas.
Those other controls could be shapes like rectangles, lines, etc., so Canvas may be a good start. If you want to render directly through a function, you could basically use any (user)control as base class, though.
Canvas is meant for drawing, obviously. What is your concern ? if it is Speed, you should have a look on Windows XNA.
Maybe Direct X, Open GL or any library providing access to them could be of some use. Give more details on your needs for an answer.
I want a simple component to crop a picture with Rectangle box in c#.net windows application.what component can i use?(free or purchase)
Here's some code I wrote to resize an image. The code will also trim the image if needed.
It provides an example of cropping and could easily be modified to be a more general "cropper" class.
I used ClearImage for image manipulation at a previous job. I found it very easy to use, with good performance and it would serve your purpose perfectly.
There is also AForge, a open source image manipulation library. A little more powerfull, with a lot of features, but also a little more complicated.
Or you could design your own using the PictureBox and the Bitmap class. A lot of work, and probably not very performant if you don't know what you're doing...
I have an Image object in my application which the user can drag around. The object displays an image which is partly transparent, so the window background (which is itself a bitmap) can be seen through it.
I want to add a graphics effect to this object. Assume that I already have an algorithm for this effect — that’s not the issue. The issue is how to get this algorithm into WPF.
So I tried to look at how DropShadowEffect works, but the implementation displayed in Reflector is empty. I also tried to look at what methods from the abstract classes Effect and ShaderEffect I should override and there doesn’t seem to be anything related to actually rendering an effect.
So how do I create my own effect?
The best and fastest way is to use pixel shaders (supported starting with WPF 3.5 SP1 I think) . It will require some shader language (HLSL) knowledge, though :-)
Here is a tutorial: How Do I: Create Custom Pixel Shader Effects for WPF
a library on codeplex: Windows Presentation Foundation Pixel Shader Effects Library
an article with .NET 4 information (including Sliverlight support which has it too): SilverShader – Introduction to Silverlight and WPF Pixel Shaders
A very cool tool (and resource) is Shazzam it will help you to create the effects and it contains a nice tutorial.
I noticed that WPF has the System.Windows.Media(.Imaging) namespaces that contain a lot of the same functionality as System.Drawing(.Imagine), but I don't see an equivalent to the ColorMatrix in GDI+. I actually don't see a way of doing color transformations in general. Does one exist? I'm happy using GDI+ but was just curious.
WPF allows you to write custom pixel shaders. These are more versatile than a ColorMatrix which you could replicate as a pixel shader, plus they are executed on the GPU. Shazzam ships with some samples and simplifies the process of writing them.
Just to note: WPF is more suited for creating user interfaces than image editing, there's not much more than the members of System.Windows.Media.Imaging like WriteableBitmap and RenderTargetBitmap. If you are after bitmap image editing features gdi+ and Direct2D might be more appropriate.
Maybe http://msdn2.microsoft.com/en-us/library/system.windows.media.imaging.formatconvertedbitmap.aspx?
Edit: http://msdn.microsoft.com/en-us/library/system.windows.media.effects.pixelshader.aspx, but i think it is not best answer because you must know about HLSL.
I’m looking for an advanced noncommercial drawing library for C# with WPF.
My goal is to create a drawing application. Not vector graphic support is needed, only bitmap.
The most advanced non-commercial API's for drawing are going to be DirectX and OpenGL. They are both complex, but you will be able to make them do almost anything you would want. You could also roll your own design that uses an Image and just changes the various pixels manually. You can then draw the image to your window when changes occur. Here is a code example below.
http://msdn.microsoft.com/en-us/library/0t3sakh9.aspx
Is there a specific reason why you can't utilize GDI+? GDI+ is an object-oriented vector-based graphics library built into the .NET Framework. It can perform most trivial drawing tasks, including loading, drawing, and saving bitmaps (BMP, PNG, GIF, JPEG, and others), transforms, color matrix manipulation, and blending. It can also render primitives such as lines, rectangles, circles, and n-sided polygons.
It also has support for render operations, and alpha transparency. You can also draw primitives and other graphical constructs using brushes and patterns, like with GDI.
You can find more information about the classes available to you by looking at the System.Drawing namespace, where most of the GDI+ classes are contained:
http://msdn.microsoft.com/en-us/library/system.drawing.aspx
Your question is not specific, however Graphic Classes in C# has many methods and features to accomplish any Trivial and some non trivial task.. if you need any thing more than that then you have DirectX.