M
M
mith2015-08-09 09:43:12
.NET
mith, 2015-08-09 09:43:12

How to implement layered canvas with support for layer transparency?

There was a need to implement a graphics editor with support for layers and the ability to change their transparency.
There are many examples of raster editors on the net www.codeproject.com/Articles/22776/WPF-DrawTools , but no one has the necessary functionality.
After studying the materials on the topic, it turned out that, according to WinFroms,
- transparency is available only to the parent form
- when changing the backgrond color from from argb, the transparency does not change if a background Image was attached to the panel
- the panels do not have a z index to arrange them in a given
order I missed something, or perhaps the WPF implementation is simpler. Please advise knowledgeable people.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem Voronov, 2015-08-09
@mith

If we talk about WinForms, then GDI + is used there, on which working with transparency is a hell of a hassle.
WPF has it easier with this, but how many resources will it eat? All the same, it is not advisable to use WPF as an editor - it will be hellishly slow on large projects.
The best option is DirectX or OpenGL.

S
Stanislav Makarov, 2015-08-09
@Nipheris

You need to decide on the amount of resources that are available to you. Of course, an editor with an opengl core will be very fast (now Photoshop is actively using hardware acceleration), but it’s not a fact that you have enough time and ability to use it directly.
On the other hand, you can try to write the processing you need yourself, in the form of ordinary CPU code, but without using WinForms for anything other than displaying an image. You apparently tried to use panels to work with layers, this of course will be extremely inconvenient, and a lot of things will not work. I advise you to try to work with these tasks (blending layers, working with transparency, etc.) yourself, i.e. will use only one picturebox to display the finished picture.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question