Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


[java] Alpha blending?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Captain Goatse   Banned   -  Reputation: 100

Like
Likes
Like

Posted 21 April 2000 - 04:01 AM

So... I decided to make transparent/opague dialog screen to my game(rpg) and I found out serveral ways to do it. Firstly there was classic way to draw gif which has every second pixel transparent. As you can quess it''s slow and it isn''t definetly way to do it. Second way is alpa blending, but I have no clue how can I make opaque picture. Let''s say that I want to mask my map with screen so that the map is behind that screen mask and it still show. Right now I can''t remember right words to describe it... Time comes, time goes and I only am.

Sponsor:

#2 Jerry Lynn   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 April 2000 - 05:29 AM

To make your partialy opaque picture I would think you would just set the part of the map ''mask'' that is see-through as transparent color - just the inverse of a typical ''sprite'' where the ''center'' part is visible and sourrounded by a transparent color.

How you would accomplish an alpha blended blt of a graphic with variable levels of transparency to the screen would depend on what API you were programming against (DirectX, some version of OPENGL, Java 2D or 3D).

Assuming you are programming in pure Java with no 3D extensions you would use the AlphaComposite class.

Here is a reference on the topic that I found...

http://www.shenzhenchina.com/9810dnwl/new/jdk1.2/ch20/ch20.htm

A little quote from that reference:

"The AlphaComposite class provides a default implementation of the Composite interface. AlphaComposite supports the blending of new pixel data with existing pixel data using alpha color values in the new and existing pixel data. The alpha color values identify the transparency of a color using a scale of 0.0 to 1.0. If a value of 1.0 is used, the new pixel data completely replaces existing pixel data. If a value of 0.0 is used, any existing pixel data is used instead of new pixel data. If a number between 0.0 and 1.0 is used, the new and existing pixel data are used in proportion to this value. For example, a value of 0.6 causes the color of the new pixel data to contribute 60% of the value of the composite color and the existing pixel data to contribute 40% of the value. In addition to the alpha values of the new and existing pixel data, a separate alpha scale factor may also be specified. This scale factor ranges from 0.0 to 1.0 and is multiplied by the alpha values of the new and existing colors. In addition to this scale factor, the AlphaComposite class provides additional compositing rules. These rules are implemented as class constants and may be used to specify a particular compositing approach."




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS