ColorKeying Textures

  ... information about changes and new features of AndEngine,

ColorKeying Textures

Postby Nicolas Gramlich » Sun Aug 08, 2010 8:42 pm

Hello Community,

since a recent version of AndEngine, you can now use ColorKeying (remove a specific color or even color-range from a TextureSource) with the ColorKeyTextureSourceDecorator.

This is how it looks like:
colorkeying.png
ColorKeying a Texture.
colorkeying.png (8.82 KiB) Viewed 1561 times


For the above screenshot, these are the lines of code that make the difference.
Left, original version:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. this.mChromaticCircleTextureRegion = TextureRegionFactory.createFromSource(this.mTexture, baseTextureSource, 0, 0);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

Right, colorkeyed version (here only the red segment is removed):
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. /* We will remove the red segment from the chromatic circle. */
  2. final int colorKeyRed = Color.rgb(255, 0, 51); // Color of the red segment.
  3. final ColorKeyTextureSourceDecorator colorKeyedTextureSource = new ColorKeyTextureSourceDecorator(baseTextureSource, colorKeyRed);
  4.  
  5. this.mChromaticCircleColorKeyedTextureRegion = TextureRegionFactory.createFromSource(this.mTexture, colorKeyedTextureSource, 128, 0);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Hope this helps some of you :)

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: ColorKeying Textures

Postby drjava72 » Thu Aug 04, 2011 6:59 am

Nicolas we love you :D
Best Regards,
drJava72
drjava72
 
Posts: 287
Joined: Fri Apr 29, 2011 8:03 am


Return to Updates

Who is online

Users browsing this forum: No registered users and 4 guests