Page 1 of 1
Transparent "Stamp"
Posted: Thu Aug 18, 2005 5:17 am
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?
Re: Transparent "Stamp"
Posted: Thu Aug 18, 2005 10:07 am
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?
Same sort of question...
Posted: Fri Sep 02, 2005 12:28 pm
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.
Re: Same sort of question...
Posted: Sun Sep 18, 2005 2:06 pm
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?