[Gimp-developer] hi color pixel blending

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello ,

I am struck with a problem which I feel only someone from the gimp
community may be able to solve, allow me to explain

I am writing a 2D 16 bit color arcade game.
I have certain sprites (explosions, glows) which are drawn against a
black background, when I draw these against a different background the
sprite's edges do not blend with the background and the sprite
looks bad, I am not talking about anti-aliasing here, I am talking
about reading rgb of source pixel and combining it with rgb of destination
pixel to make it look natural (the way it has been drawn against black
background).

The gimp does this automatically using layers if I create sprites on a different layer
then I can manipulate the background layer as I wish and gimp blends the layers very well.
But due to lack of vision, all the graphics have been drawn already against
black and saved in bitmap format, so I do not have a alpha channel and I have only one layer
in the images.
Now I cant seem to blend them right with the backgrounds.


the problem is if I additively blend my sprite with background it looks fine
against dark backgrounds but looks totally bright against bright backgrounds.
the problem with alpha blending is that it completely kills intensity of colors.


equation for alpha blending is
alpha=(2*r1+3*g1+b1)/6;
r3=((r1*alpha)+(r2*(255-alpha)))/256;

where r1 is sprite color, r2 is background color, r3 is result (blended) color.
I have found screen mode better than the rest here but am looking for a better solution.
Please download my test program, it will make my problem very practically clear.
http://www.geocities.com/lazy_coder/code/all.zip (350k)
the page is http://www.geocities.com/lazy_coder/index.htm


Please try to mail me directly as I am not subscribed to the mailing list.
Thanks, if you can help me I will be most obliged and will give full credit.

Deepak T (coolbool@xxxxxxx)



[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux