Transparent "Stamp"

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

Moderators: XnTriq, helmut, xnview

Post Reply
tailormade
Posts: 15
Joined: Fri Jun 24, 2005 6:08 pm

Transparent "Stamp"

Post by tailormade »

I am trying to "stamp" an image with another, smaller image. I can do the basic "image on image" but I need the stamp to be either semi-transparent (modify the alpha channel) or with a transparent background. Neither has worked.

I am using the following code:

Code: Select all

for (int j= 0; j < stamp->Width; j++)
   for (int k=0; k < stamp->Height; k++)
      {
      GFL_COLOR acolor;
      gflGetColorAt(stamp, j, k, &acolor);
      acolor.Alpha = 200;
      gflSetColorAt(stamp, j, k, &acolor);
      }
int newW = (Width-stamp->Width)*((double)StampX/100.);
int newH = (Height-stamp->Height)*((100.-(double)StampY)/100.);
error = gflBitbltEx(stamp, &rect, &mainbitmap, newW, newH );
This should alter the "stamp" to make it semi-transparent, but I get a solid stamp with a solid white background.

Any ideas?
User avatar
xnview
Author of XnView
Posts: 43601
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Transparent "Stamp"

Post by xnview »

tailormade wrote:I am trying to "stamp" an image with another, smaller image. I can do the basic "image on image" but I need the stamp to be either semi-transparent (modify the alpha channel) or with a transparent background. Neither has worked.

I am using the following code:

Code: Select all

for (int j= 0; j < stamp->Width; j++)
   for (int k=0; k < stamp->Height; k++)
      {
      GFL_COLOR acolor;
      gflGetColorAt(stamp, j, k, &acolor);
      acolor.Alpha = 200;
      gflSetColorAt(stamp, j, k, &acolor);
      }
int newW = (Width-stamp->Width)*((double)StampX/100.);
int newH = (Height-stamp->Height)*((100.-(double)StampY)/100.);
error = gflBitbltEx(stamp, &rect, &mainbitmap, newW, newH );
This should alter the "stamp" to make it semi-transparent, but I get a solid stamp with a solid white background.

Any ideas?
Could you send me orignal picture?
Pierre.
Green_OPS
Posts: 1
Joined: Fri Sep 02, 2005 11:47 am

Same sort of question...

Post by Green_OPS »

I got the same sort of question.

Say the original image is 320x240 and the "stamp" is 88x31, both are jpg's.
(In fact the original image opacity shouldn't be altered in my case, but then the stamp doesn't show up at all...) When merging - at let's say 50% opacity for - both layers, it seems that the layer containing the smaller picture is the same size as the original, which I think causes the "problem".

Can't the second layer keep the size of it's own image?

Or

Can't the "stamp" be pasted as a new selection (like .drawImage) at position X,Y with Z opacity or something like that ?


Regards,

Green.
User avatar
xnview
Author of XnView
Posts: 43601
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Same sort of question...

Post by xnview »

Green_OPS wrote:I got the same sort of question.

Say the original image is 320x240 and the "stamp" is 88x31, both are jpg's.
(In fact the original image opacity shouldn't be altered in my case, but then the stamp doesn't show up at all...) When merging - at let's say 50% opacity for - both layers, it seems that the layer containing the smaller picture is the same size as the original, which I think causes the "problem".

Can't the second layer keep the size of it's own image?

Or

Can't the "stamp" be pasted as a new selection (like .drawImage) at position X,Y with Z opacity or something like that ?
Could you post your code, and pictures used?
Pierre.
Post Reply