[Fixed] Problem using copyToWithAlpha

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
bridgeco
Posts: 13
Joined: Fri Mar 19, 2004 8:19 pm
Location: London
Contact:

[Fixed] Problem using copyToWithAlpha

Post by bridgeco »

Hi, I'm trying to use IImage::copyToWithAlpha to overlay one image onto another one, but I'm having difficulty getting it to work. Using the nearly equivalent copyTo works fine, and I haven't been able to find any examples to suggest where I'm going wrong.

The following snippet works, and I get the result expected, the idNumberImage overlaid onto radarImageOverlaid.

Code: Select all

idNumberImage->copyTo(radarImageOverlaid,core::position2d<s32>(deltaX-10,deltaY-10),sourceRect,0);
idNumberImage and radarImageOverlaid are both IImage* types, sourceRect is the entire rectangle of radarImageOverlaid.

I've tried to use

Code: Select all

idNumberImage->copyToWithAlpha(radarImageOverlaid,core::position2d<s32>(deltaX-10,deltaY-10),sourceRect,video::SColor(255,255,255,255));
instead, so I don't block out the background image with the areas of idNumberImage that should be transparent (loaded from a png with alpha channel, either 0 or 255). However with this I only see the original image, and the copyToWithAlpha call doesn't seem to have any effect.

Has anyone used copyToWithAlpha successfully, and do you have any suggestions of what might be going wrong?
Last edited by bridgeco on Tue Oct 18, 2016 7:11 am, edited 1 time in total.
-------------------------------------
Bridge Command

a 3d ship simulator for navigation training
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Problem using copyToWithAlpha

Post by CuteAlien »

Not seeing anything wrong on first view. I know it uses a somewhat different blitter algorithm when color is not pure white - so maybe experiment if you get a different result with any other color (in case that specific blitter code is broken). If you can't figure out anything I'll have to check, but have to write an example for that stuff first myself as I've not used it yet.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
bridgeco
Posts: 13
Joined: Fri Mar 19, 2004 8:19 pm
Location: London
Contact:

Re: Problem using copyToWithAlpha

Post by bridgeco »

Apologies, I've found my simple mistake: The images I was copying into were using the color format ECF_R8G8B8, not ECF_A8R8G8B8 (i.e. no alpha channel). Correcting this to ECF_A8R8G8B8 means that it all works as expected.
-------------------------------------
Bridge Command

a 3d ship simulator for navigation training
Post Reply