How to merge two images, keeping alpha channels+++

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, helmut, xnview

haerdalis

How to merge two images, keeping alpha channels+++

Post by haerdalis »

Hello.. I'm quite new to your library, using just the free version for now,
to see if it fits my needs..
I'm using the GFL SDK (not AX).

How can one merge two images, where one is completely opaque (background), and the other is a PNG with alpha channel, where the
degree of transparency varies (pixel transparency)?

I tried using gflBitBltEx, but that one was rather strange.. Where the
alpha of the upper image dictates transparency, it would completely
erase the image below, replacing it with transparent background.
Somewhat strange because the documentation states the function does alpha blending?

And gflMerge isn't quite there either, since both need to be 100% opaque
where the pixels doesn't say otherwise..

Do you, or anyone else have a good example for displaying a image on screen, which does complete alpha blending with whatever background it is on, or similar?
The standard example doesn't show how to manage something like
this, and doesn't support alpha at all.. (something I'm quite new at I might
add)..
haerdalis

A little note..

Post by haerdalis »

I tested the GFLAx, and that one has the function DrawImage, which
does exactly what I want to accomplish.. I.e when drawing one .png (semitransparent/with transparent sections) image on top of another, the lower are visible where the alphatransparency dictates so..

But I use C++ and Delphi, and want to use the gflBitBltEx to do the same.. And that one doesn't..

Instead it copies one image over the other (including alphachannel), but doesn't do any blending, just overwrites..

Is this a bug, or intentionally?
User avatar
xnview
Author of XnView
Posts: 44920
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: A little note..

Post by xnview »

haerdalis wrote:I tested the GFLAx, and that one has the function DrawImage, which
does exactly what I want to accomplish.. I.e when drawing one .png (semitransparent/with transparent sections) image on top of another, the lower are visible where the alphatransparency dictates so..

But I use C++ and Delphi, and want to use the gflBitBltEx to do the same.. And that one doesn't..

Instead it copies one image over the other (including alphachannel), but doesn't do any blending, just overwrites..

Is this a bug, or intentionally?
Strange because DrawImage from GFLAx use gflBitBltEx...
Pierre.
haerdalis
Posts: 6
Joined: Tue Nov 15, 2005 5:08 am

Re: A little note..

Post by haerdalis »

xnview wrote:
haerdalis wrote:I tested the GFLAx, and that one has the function DrawImage, which
does exactly what I want to accomplish.. I.e when drawing one .png (semitransparent/with transparent sections) image on top of another, the lower are visible where the alphatransparency dictates so..

But I use C++ and Delphi, and want to use the gflBitBltEx to do the same.. And that one doesn't..

Instead it copies one image over the other (including alphachannel), but doesn't do any blending, just overwrites..

Is this a bug, or intentionally?
Strange because DrawImage from GFLAx use gflBitBltEx...
I agree.. I've tested it some more, and it seems it copies the area specified
to the destination, replacing the destination area with the new imagepart including its transparency, but ignoring what's below (ie no blend)..

I was rather lucky however, as I had some useful functions for operating directly on RGBA data, and blend that way.. Not the best solution however,
since it expects the data in a certain way, and can't operate on those
other mappings..
User avatar
xnview
Author of XnView
Posts: 44920
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: A little note..

Post by xnview »

haerdalis wrote:
xnview wrote:
haerdalis wrote:I tested the GFLAx, and that one has the function DrawImage, which
does exactly what I want to accomplish.. I.e when drawing one .png (semitransparent/with transparent sections) image on top of another, the lower are visible where the alphatransparency dictates so..

But I use C++ and Delphi, and want to use the gflBitBltEx to do the same.. And that one doesn't..

Instead it copies one image over the other (including alphachannel), but doesn't do any blending, just overwrites..

Is this a bug, or intentionally?
Strange because DrawImage from GFLAx use gflBitBltEx...
I agree.. I've tested it some more, and it seems it copies the area specified
to the destination, replacing the destination area with the new imagepart including its transparency, but ignoring what's below (ie no blend)..

I was rather lucky however, as I had some useful functions for operating directly on RGBA data, and blend that way.. Not the best solution however,
since it expects the data in a certain way, and can't operate on those
other mappings..
Could you send me the pictures used?
Pierre.