• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Little help with StretchDrawBlend

Started by PAEz, 5 January 2011, 20:34:49

Previous topic - Next topic

PAEz

5 January 2011, 20:34:49 Last Edit: 7 January 2011, 09:55:11 by PAEz
Im trying to use StretchDrawBlend and its prolly just me but I cant figure how to use it.
I want to mix an image with another image so that the alpha of the second image is preserved and the first image is mixed with it according to its alpha, I thought it would be this....
MaskCanvas:StretchDrawBlend( 0,0,Mask.Width-1,Mask.Height-1,
                   ToolbarCanvas,0,0,Toolbar.Width,Toolbar.Height,
                   bfSrcAlpha,bfDstAlpha,rfBicubic )
Sorry bout the strange notation, Im using it in Lua.
Heres the image Im using as the mask...
http://img205.imageshack.us/img205/6765/toolbarmask.png
...If I fill the red channel ( MaskCanvas:FillChannel(ChannelRed,255) ) I seem to get what Id expect but not if its black?


Also while Im here Ellipse doesnt honour penMode clear.

Galfar

Using StretchDrawAlpha doesn't do what you need?
To get regular alpha blending with DrawBlend
try using SrcFactor: bfSrcAlpha and DestFactor: bfOneMinusSrcAlpha.

I'm going away now for a week or two so I can have a closer look after that.

BTW: How are you using Imaging in Lua?

PAEz

Thanks for your time....

Quotetry using SrcFactor: bfSrcAlpha and DestFactor: bfOneMinusSrcAlpha.

Thats what I ended up using but if I understand right (still trying to get it right in my head, I dont learn things easy) that will allways make all the alpha in the dest bitmap 255?...right?...when what I wanted was the same sort of blend but retain the alpha of the dest....so I guess Ill have to make my own blend mode or a clone channel command to back it up and put it back (plus a clone channel command could come in handy later).

QuoteBTW: How are you using Imaging in Lua?

Really easily thanks to this....
http://www.eonclash.com/ViewProduct.php?ProductID=21
....I dont get half of what Im doing ;) but Ive got a GREAT little scripting thingy now that uses your library...pretty slow if you getpixel for a 1280x1024 pic but you hardly ever have to do that and if i do I just make a bit of Lazarus for it.  Its been alot of fun, Im using it to make some scripts for making Chrome themes.
What Id really like tho is to see your library in something like this....
http://luaforge.net/projects/vclua/
..so it would be an actual Lua library, I didnt like any of the ones available and thats why I ended up going down this road (glad I did tho)...Ive got it to compile so now Ive just got to learn how it works a little better and Ill slip your stuff in (I hope, still have no idea how to handle multidimensional arrays).

QuoteI'm going away now for a week or two so I can have a closer look after that.

Have Fun :P

Galfar

10 January 2011, 15:24:26 #3 Last Edit: 10 January 2011, 15:30:16 by Galfar
Try messing up with PixelBlendProc procedure in ImagingCanvases.pas. To preserve original alpha in dest image try if commenting out line
DestPix.A := SrcPix.A * FSrc.A + DestPix.A * FDst.A;
will do what you want to do.

Quote
Quotetry using SrcFactor: bfSrcAlpha and DestFactor: bfOneMinusSrcAlpha.

that will allways make all the alpha in the dest bitmap 255?...right?

Not always, but it changes dest alpha so it's not what you want.

Quoteso I guess Ill have to make my own blend mode

Something that uses the same factors as bfSrcAlpha+bfOneMinusSrcAlpha for
color channels only and bfZero+bfOne for alpha might work as you expect.

Quote
QuoteI'm going away now for a week or two so I can have a closer look after that.

Have Fun

It's a work trip, not so much fun :(

EDIT: Maybe some bool for canvas that says "don't touch alpha during blending"
might be useful, I guess preserving alphas is expected behavior here.

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk