Article View: rec.games.programmer
Article #2342Re: Alpha Blending Techniques - PLEASE HELP!
From: gmcbay
Date: Fri, 17 Jul 1998 00:00
Date: Fri, 17 Jul 1998 00:00
72 lines
3325 bytes
3325 bytes
Alpha Blending (in the sense of your card game) is just mixing two color
values in a weighted manner.
I don't know how your card game is implemented, but to accomplish these
shadows, what you want to is read the values of pixels in your target region,
get the R/G/B values, and then darken them up by lowering each component by a
set amount.
Pseudo-code:
DARKEN_VALUE = 30
foreach([x, y] of pixel_in_shadow_region)
{
pix = GetPixelOfUnderlyingRegion(x, y);
red = GetRedComponent(pix);
green = GetGreenComponent(pix);
blue = GetBlueComponent(pix);
red = red - DARKEN_VALUE;
green = green - DARKEN_VALUE;
blue = blue - DARKEN_VALUE;
pix = RGB(red, green, blue);
SetPixelOfUnderlyingRegion(pix, x, y);
}
Of course, how you actually implement it and the functions you use depend on
the game and how it is constructed. If you're using standard GDI, look
at the GetPixel/SetPixel functions and RGB/Get*Value macros. If you're adverse
to the relative slowness of using Get/SetPixel (shouldn't really effect a card
game much), look into memory DIBs.
If you're using DirectX, you could either get the DC of the surface (and
use the above method) or use Lock() to get access to the surface's pixel
information).
Just be sure to draw the shadow for each card as you draw the card to keep the
zorder correct.
In article <6omgsn$kgk$1@nnrp1.dejanews.com>,
eduardo@fnn.net wrote:
> Hello guys.
>
> I'm a newbie programmer... and I need to find some algorithms to
> perform Alpha Blending... I'm making a card game, and I need to
> have the effect of a shadow below the cards (drop shadow a la Photoshop).
>
> A friend of mine told me about Alpha Blending. Do you guys have
> some algorithms, tutorials, or something like to help me?
>
> I'm developing the card game on VC++ and Delphi.
>
> Please, I really need help on this one. I know Delphi and C a lot,
> but I did not find anything about this subject...
>
> Thanks a lot
>
> ________________________________
> Eduardo B. Fonseca
> NetGames Online CEO
> eduardo@fnn.net
> ________________________________
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
Technical Details
Message-ID:
<6oo4cd$gmq$1@nnrp1.dejanews.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<6omgsn$kgk$1@nnrp1.dejanews.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fe306,b4b32c53bf9eb33b X-Google-Attributes: gidfe306,public X-Google-Thread: 108717,b4b32c53bf9eb33b X-Google-Attributes: gid108717,public X-Google-Thread: fdc2a,b4b32c53bf9eb33b X-Google-Attributes: gidfdc2a,public X-Google-Thread: 10a296,b4b32c53bf9eb33b X-Google-Attributes: gid10a296,public From: gmcbay@dc.usweb.com Subject: Re: Alpha Blending Techniques - PLEASE HELP! Date: 1998/07/17 Message-ID: <6oo4cd$gmq$1@nnrp1.dejanews.com> X-Deja-AN: 372349446 References: <6omgsn$kgk$1@nnrp1.dejanews.com> Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Fri Jul 17 18:15:42 1998 GMT Newsgroups: rec.games.programmer,comp.graphics.algorithms,comp.programming,borland.public.delphi.graphics X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)