Idea: Highlighting new parts in a step


Re: Idea: Highlighting new parts in a step
#13
I think you do not need an external SW package. The routine should be fairly simple in my view.

How I would do it (not knowing how the Alpha Channel is represented in a PNG)
- Go through the file pixel by pixel
- if the pixel of the highlight is transparent -> use the original image pixel
- if the pixel is colored -> use this pixel (or do an ADD/Multiply or use opacity that may be makes the color below shine through a bit)
- Save the modified pixel.

For sure there must be a ready-made function somewhere out there. QT should have something on board.


Just found this code here including an example:

Code:
QImage createImageWithOverlay(const QImage& baseImage, const QImage& overlayImage)
{
    QImage imageWithOverlay = QImage(baseImage.size(), QImage::Format_ARGB32_Premultiplied);
    QPainter painter(&imageWithOverlay);

    painter.setCompositionMode(QPainter::CompositionMode_Source);
    painter.fillRect(imageWithOverlay.rect(), Qt::transparent);

    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    painter.drawImage(0, 0, baseImage);

    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    painter.drawImage(0, 0, overlayImage);

    painter.end();

    return imageWithOverlay;
}

Some php code looks amazingly simple...
Code:
$image1 = imagecreatefrompng('a.png'); //300 x 300
$image2 = imagecreatefrompng('b.png'); //150 x 150
imagecopymerge($image1, $image2, 0, 0, 75, 75, 150, 150, 50);

EDIT:

The original code uses "QPixMap" to e.g. find the pointer location for the call out (see line 2316 in metaitem.cpp) or searcch form "blue" in the code.

This digs quite deep into the actual image, which is not necessary to achieve the quick solution with the edge lines.

Here is something on the QT pages.
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Re: Idea: Highlighting new parts in a step - by Gerald Lasser - 2016-01-15, 9:53

Forum Jump:


Users browsing this thread: 1 Guest(s)