DIGIT-ARC read-only archive · snapshot: July 23, 2026

how to simulate the image layer , like the one in Photoshop

2 posts · originally from https://geek.digit.in/community/threads/how-to-simulate-the-image-layer-like-the-one-in-photoshop.101537/

pavilion
pavilion Original post #1
Nov 7, 2008 at 8:49 PM
I try to write my own Paint program , and I wonder how to create the "layer system" , like Photoshop , Paint.NET 's features , I try to draw multiple stacked images on form , but it just works terribly .
Anyone got an idea of how to do it ? Just an idea , don't give me the source code ,ok . Thanks ^^
QwertyManiac
Nov 7, 2008 at 9:33 PM
What graphics library are you using? If it supports alpha channels why not just draw the layers one over another using it? Layers are much like an undo stack otherwise. Each new action needs to be drawn and every change in the stack prompts a redraw.

There are things known (in Qt) as Composition modes. Based on how the layers are to be ordered, you set the composition modes appropriately and draw the stack over the destination image area. The QPainter class does this very well.

You can see an example here: *doc.trolltech.com/qq/qq17-compositionmodes.html

I don't know the low level implementation of this, if thats what you are asking.