Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Manipulating the Alpha Raster  (Read 10121 times)
0 Members and 1 Guest are viewing this topic.
Offline ghostsoldier23

Junior Devvie

Medals: 1

« Posted 2012-01-11 20:22:43 »

I'm bit confused on the proper method to manipulating the AlphaRaster directly on a TYPE_INT_ARGB BufferedImage.  Setting the data values individually seems to have no effect.

I believe AlphaComposite can also be used for this purpose... but I don't how to do that either.

If anyone could explain it, it would be greatly appreciated.

NOTE:  Just noticed I accidentally put this in Game Play & Design... that was completely unintentional.  If a mod wants to move it that's fine.
Offline nicephotog

Innocent Bystander

« Reply #1 - Posted 2012-05-19 03:47:23 »

There are two types of ARGB true colour.
One uses a "float" in the raster
the second type of ARGB use 0-255 inclusive to set the opacity.
By completeness that's four(different values of the "static field constant" for BufferedImage type) types of true colour Alpha image.
"Pre" means one byte of  alpha information is there for the whole/complete set of pixels.
pre with "float(one??? 8 bit byte)" or "float
  • [y] as an alpha raster"
pre with "int(one??? 8 bit byte)"  or "int
  • [y]  as an alpha raster
*Huh i'm not sure how the single value for the opacity(alpha value) setting is stored in the header or inside the runtime engine under the common image spec(doesn't actually matter).

An alpha raster you can obtain from a buffered image.
AlphaComposite class is mostly for getting two images and combining the pixels(blending) by a set of rules as stated in the API docs.
Offline matheus23

JGO Kernel

Medals: 138
Projects: 3

You think about my Avatar right now!

« Reply #2 - Posted 2012-05-20 08:58:23 »

AlphaComposite will do everything you want Wink

From an not-so-old LD project (LD #23):

   public void render(Graphics2D g) {
      AlphaComposite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f);

That's how I used it, to create a "night"-Effect. I just rendered a Rectangle over the scene after drawing the scene itself:
      g.setColor(new Color(0f, 0f, 0f, 1f-brightness));
      g.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());

And thats almost everything, how to use it. Just keep sure, you draw everything in the right order Smiley

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Pages: [1]
  ignore  |  Print  

EgonOlsen (74 views)
2018-06-10 19:43:48

EgonOlsen (55 views)
2018-06-10 19:43:44

EgonOlsen (75 views)
2018-06-10 19:43:20

DesertCoockie (255 views)
2018-05-13 18:23:11

nelsongames (154 views)
2018-04-24 18:15:36

nelsongames (154 views)
2018-04-24 18:14:32

ivj94 (895 views)
2018-03-24 14:47:39

ivj94 (156 views)
2018-03-24 14:46:31

ivj94 (808 views)
2018-03-24 14:43:53

Solater (172 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!