0

I'm writing an app that has to combine various images. I have a base image, a mask, and a texture. A person can prepare the texture with some transparency and colour it up, but it's a tedious work, especially for me, I've never been good with that kind of stuff.

So I'm looking for a way to mimic the Overlay function Photoshop has. Is it possible? The user would be able to upload a base image, a mask, and an untouched texture, instead of preparing the texture to keep it's colour despite having enough transparency for the details of the object to be visible. Are there any free tools I could use and implement?

Petersaber
  • 851
  • 1
  • 12
  • 29
  • Not with QT. You need an image processing library, such as OpenGL etc. See: http://stackoverflow.com/a/5098999/2385309 – 72DFBF5B A0DF5BE9 Oct 09 '15 at 13:54
  • But how can I mimic Photoshop's overlay? That example is about masks, Qt can do that, and Google only throws UI overlays at me, not textures – Petersaber Oct 09 '15 at 14:02
  • @72DFBF5BA0DF5BE9 .... I stumbled across the answer. Qt indeed can do this. As it turns out, `QPainter` has a `QPainter::CompositionMode_Overlay parameter`. Which does exactly that.... – Petersaber Oct 09 '15 at 14:23

1 Answers1

1

The curse strikes once again. After posting a question, I immediatly find the answer myself.

And the answer is simple: QPainter. It has a parameter called compositionMode, which you can set, among other things, to various blend modes, much like in Photoshop.

QPixmap background(backgroundUrl);
QPixmap overlayTexture(overlayUrl);

QPainter painter(&background);
painter.setCompositionMode(QPainter::CompositionMode_Overlay);
painter.drawPixmap(0, 0, overlayTexture);
painter.end();

And that's it.

Petersaber
  • 851
  • 1
  • 12
  • 29
  • Maybe do a little more research instead of immediately posting a question ;) – dtech Oct 09 '15 at 15:04
  • @ddriver I tried, trust me. I simply missed that part when reading the docs and scrolling through properities. I didn't notice it this time around either, I noticed "HardLight" and it clicked - "Hey. Photoshop has this." Also, it didn't help me that I had more than one person telling me I had to use some external library because Qt can't do it - as it turns out, it can, and the results, while not perfect, are pretty nice. – Petersaber Oct 09 '15 at 16:08