Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Extracted color calculation/conversion methods from Color to ColorUti…

…ls. Removed all references to android.graphics.color. Changes around classes that used a ARGB color packed as int (coming from android.graphics.color).
  • Loading branch information...
commit 76992d7184c58ffedf73d7955ef9660c5880a4e0 1 parent 6dbfd36
Nicolas Gramlich authored
View
19 src/org/andengine/entity/scene/background/modifier/ColorBackgroundModifier.java
@@ -1,12 +1,13 @@
package org.andengine.entity.scene.background.modifier;
import org.andengine.entity.scene.background.IBackground;
+import org.andengine.util.color.Color;
import org.andengine.util.modifier.BaseTripleValueSpanModifier;
import org.andengine.util.modifier.ease.EaseLinear;
import org.andengine.util.modifier.ease.IEaseFunction;
/**
- * (c) 2010 Nicolas Gramlich
+ * (c) 2010 Nicolas Gramlich
* (c) 2011 Zynga Inc.
*
* @author Nicolas Gramlich
@@ -25,18 +26,34 @@
// Constructors
// ===========================================================
+ public ColorBackgroundModifier(final float pDuration, final Color pFromColor, final Color pToColor) {
+ this(pDuration, pFromColor.getRed(), pToColor.getRed(), pFromColor.getGreen(), pToColor.getGreen(), pFromColor.getBlue(), pToColor.getBlue(), null, EaseLinear.getInstance());
+ }
+
public ColorBackgroundModifier(final float pDuration, final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue) {
this(pDuration, pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, null, EaseLinear.getInstance());
}
+ public ColorBackgroundModifier(final float pDuration, final Color pFromColor, final Color pToColor, final IEaseFunction pEaseFunction) {
+ this(pDuration, pFromColor.getRed(), pToColor.getRed(), pFromColor.getGreen(), pToColor.getGreen(), pFromColor.getBlue(), pToColor.getBlue(), null, pEaseFunction);
+ }
+
public ColorBackgroundModifier(final float pDuration, final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue, final IEaseFunction pEaseFunction) {
this(pDuration, pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, null, pEaseFunction);
}
+ public ColorBackgroundModifier(final float pDuration, final Color pFromColor, final Color pToColor, final IBackgroundModifierListener pBackgroundModifierListener) {
+ super(pDuration, pFromColor.getRed(), pToColor.getRed(), pFromColor.getGreen(), pToColor.getGreen(), pFromColor.getBlue(), pToColor.getBlue(), pBackgroundModifierListener, EaseLinear.getInstance());
+ }
+
public ColorBackgroundModifier(final float pDuration, final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue, final IBackgroundModifierListener pBackgroundModifierListener) {
super(pDuration, pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, pBackgroundModifierListener, EaseLinear.getInstance());
}
+ public ColorBackgroundModifier(final float pDuration, final Color pFromColor, final Color pToColor, final IBackgroundModifierListener pBackgroundModifierListener, final IEaseFunction pEaseFunction) {
+ super(pDuration, pFromColor.getRed(), pToColor.getRed(), pFromColor.getGreen(), pToColor.getGreen(), pFromColor.getBlue(), pToColor.getBlue(), pBackgroundModifierListener, pEaseFunction);
+ }
+
public ColorBackgroundModifier(final float pDuration, final float pFromRed, final float pToRed, final float pFromGreen, final float pToGreen, final float pFromBlue, final float pToBlue, final IBackgroundModifierListener pBackgroundModifierListener, final IEaseFunction pEaseFunction) {
super(pDuration, pFromRed, pToRed, pFromGreen, pToGreen, pFromBlue, pToBlue, pBackgroundModifierListener, pEaseFunction);
}
View
2  src/org/andengine/entity/shape/Shape.java
@@ -146,7 +146,7 @@ protected void initBlendFunction(final ITexture pTexture) {
}
protected void initBlendFunction(final TextureOptions pTextureOptions) {
- if(pTextureOptions.mPreMultipyAlpha) {
+ if(pTextureOptions.mPreMultiplyAlpha) {
this.setBlendFunction(IShape.BLENDFUNCTION_SOURCE_PREMULTIPLYALPHA_DEFAULT, IShape.BLENDFUNCTION_DESTINATION_PREMULTIPLYALPHA_DEFAULT);
}
}
View
8 src/org/andengine/entity/sprite/batch/SpriteBatch.java
@@ -15,12 +15,12 @@
import org.andengine.opengl.vbo.HighPerformanceVertexBufferObject;
import org.andengine.opengl.vbo.IVertexBufferObject;
import org.andengine.opengl.vbo.LowMemoryVertexBufferObject;
-import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.opengl.vbo.VertexBufferObject.DrawType;
+import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.opengl.vbo.attribute.VertexBufferObjectAttributes;
import org.andengine.opengl.vbo.attribute.VertexBufferObjectAttributesBuilder;
import org.andengine.util.adt.transformation.Transformation;
-import org.andengine.util.color.Color;
+import org.andengine.util.color.ColorUtils;
import android.opengl.GLES20;
@@ -717,7 +717,7 @@ protected void addWithPackedColor(final ITextureRegion pTextureRegion, final flo
* +-2
*/
private void addInner(final ITextureRegion pTextureRegion, final float pX1, final float pY1, final float pX2, final float pY2, final float pRed, final float pGreen, final float pBlue, final float pAlpha) {
- this.mSpriteBatchVertexBufferObject.addWithPackedColor(pTextureRegion, pX1, pY1, pX2, pY2, Color.packABGRFloat(pRed, pGreen, pBlue, pAlpha));
+ this.mSpriteBatchVertexBufferObject.addWithPackedColor(pTextureRegion, pX1, pY1, pX2, pY2, ColorUtils.convertRGBAToABGRPackedFloat(pRed, pGreen, pBlue, pAlpha));
}
/**
@@ -726,7 +726,7 @@ private void addInner(final ITextureRegion pTextureRegion, final float pX1, fina
* 2-4
*/
private void addInner(final ITextureRegion pTextureRegion, final float pX1, final float pY1, final float pX2, final float pY2, final float pX3, final float pY3, final float pX4, final float pY4, final float pRed, final float pGreen, final float pBlue, final float pAlpha) {
- this.mSpriteBatchVertexBufferObject.addWithPackedColor(pTextureRegion, pX1, pY1, pX2, pY2, pX3, pY3, pX4, pY4, Color.packABGRFloat(pRed, pGreen, pBlue, pAlpha));
+ this.mSpriteBatchVertexBufferObject.addWithPackedColor(pTextureRegion, pX1, pY1, pX2, pY2, pX3, pY3, pX4, pY4, ColorUtils.convertRGBAToABGRPackedFloat(pRed, pGreen, pBlue, pAlpha));
}
// ===========================================================
View
10 src/org/andengine/opengl/font/Font.java
@@ -65,18 +65,22 @@
// ===========================================================
public Font(final FontManager pFontManager, final ITexture pTexture, final Typeface pTypeface, final float pSize, final boolean pAntiAlias, final Color pColor) {
+ this(pFontManager, pTexture, pTypeface, pSize, pAntiAlias, pColor.getARGBPackedInt());
+ }
+
+ public Font(final FontManager pFontManager, final ITexture pTexture, final Typeface pTypeface, final float pSize, final boolean pAntiAlias, final int pColorARGBPackedInt) {
this.mFontManager = pFontManager;
this.mTexture = pTexture;
this.mTextureWidth = pTexture.getWidth();
this.mTextureHeight = pTexture.getHeight();
this.mBackgroundPaint = new Paint();
- this.mBackgroundPaint.setColor(Color.TRANSPARENT);
+ this.mBackgroundPaint.setColor(Color.TRANSPARENT_ARGB_PACKED_INT);
this.mBackgroundPaint.setStyle(Style.FILL);
this.mPaint = new Paint();
this.mPaint.setTypeface(pTypeface);
- this.mPaint.setColor(pColor);
+ this.mPaint.setColor(pColorARGBPackedInt);
this.mPaint.setTextSize(pSize);
this.mPaint.setAntiAlias(pAntiAlias);
@@ -254,7 +258,7 @@ public synchronized void update(final GLState pGLState) {
this.mTexture.bind(pGLState);
final PixelFormat pixelFormat = this.mTexture.getPixelFormat();
- final boolean preMultipyAlpha = this.mTexture.getTextureOptions().mPreMultipyAlpha;
+ final boolean preMultipyAlpha = this.mTexture.getTextureOptions().mPreMultiplyAlpha;
for(int i = lettersPendingToBeDrawnToTexture.size() - 1; i >= 0; i--) {
final Letter letter = lettersPendingToBeDrawnToTexture.get(i);
if(!letter.isWhitespace()) {
View
4 src/org/andengine/opengl/font/FontFactory.java
@@ -5,9 +5,9 @@
import org.andengine.opengl.texture.TextureOptions;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.bitmap.BitmapTexture.BitmapTextureFormat;
+import org.andengine.util.color.Color;
import android.content.res.AssetManager;
-import android.graphics.Color;
import android.graphics.Typeface;
/**
@@ -23,7 +23,7 @@
// ===========================================================
private static final boolean ANTIALIAS_DEFAULT = true;
- private static final int COLOR_DEFAULT = Color.BLACK;
+ private static final int COLOR_DEFAULT = Color.BLACK_ARGB_PACKED_INT;
// ===========================================================
// Fields
View
19 src/org/andengine/opengl/font/StrokeFont.java
@@ -1,6 +1,7 @@
package org.andengine.opengl.font;
import org.andengine.opengl.texture.ITexture;
+import org.andengine.util.color.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
@@ -31,13 +32,21 @@
// ===========================================================
// Constructors
// ===========================================================
+
+ public StrokeFont(final FontManager pFontManager, final ITexture pTexture, final Typeface pTypeface, final float pSize, final boolean pAntiAlias, final Color pColor, final float pStrokeWidth, final Color pStrokeColor) {
+ this(pFontManager, pTexture, pTypeface, pSize, pAntiAlias, pColor.getARGBPackedInt(), pStrokeWidth, pStrokeColor.getARGBPackedInt());
+ }
+
+ public StrokeFont(final FontManager pFontManager, final ITexture pTexture, final Typeface pTypeface, final float pSize, final boolean pAntiAlias, final int pColorARGBPackedInt, final float pStrokeWidth, final int pStrokeColorARGBPackedInt) {
+ this(pFontManager, pTexture, pTypeface, pSize, pAntiAlias, pColorARGBPackedInt, pStrokeWidth, pStrokeColorARGBPackedInt, false);
+ }
- public StrokeFont(final FontManager pFontManager, final ITexture pTexture, final Typeface pTypeface, final float pSize, final boolean pAntiAlias, final int pColor, final float pStrokeWidth, final int pStrokeColor) {
- this(pFontManager, pTexture, pTypeface, pSize, pAntiAlias, pColor, pStrokeWidth, pStrokeColor, false);
+ public StrokeFont(final FontManager pFontManager, final ITexture pTexture, final Typeface pTypeface, final float pSize, final boolean pAntiAlias, final Color pColor, final float pStrokeWidth, final Color pStrokeColor, final boolean pStrokeOnly) {
+ this(pFontManager, pTexture, pTypeface, pSize, pAntiAlias, pColor.getARGBPackedInt(), pStrokeWidth, pStrokeColor.getARGBPackedInt(), pStrokeOnly);
}
- public StrokeFont(final FontManager pFontManager, final ITexture pTexture, final Typeface pTypeface, final float pSize, final boolean pAntiAlias, final int pColor, final float pStrokeWidth, final int pStrokeColor, final boolean pStrokeOnly) {
- super(pFontManager, pTexture, pTypeface, pSize, pAntiAlias, pColor);
+ public StrokeFont(final FontManager pFontManager, final ITexture pTexture, final Typeface pTypeface, final float pSize, final boolean pAntiAlias, final int pColorARGBPackedInt, final float pStrokeWidth, final int pStrokeColorARGBPackedInt, final boolean pStrokeOnly) {
+ super(pFontManager, pTexture, pTypeface, pSize, pAntiAlias, pColorARGBPackedInt);
this.mStrokeWidth = pStrokeWidth;
@@ -45,7 +54,7 @@ public StrokeFont(final FontManager pFontManager, final ITexture pTexture, final
this.mStrokePaint.setTypeface(pTypeface);
this.mStrokePaint.setStyle(Style.STROKE);
this.mStrokePaint.setStrokeWidth(pStrokeWidth);
- this.mStrokePaint.setColor(pStrokeColor);
+ this.mStrokePaint.setColor(pStrokeColorARGBPackedInt);
this.mStrokePaint.setTextSize(pSize);
this.mStrokePaint.setAntiAlias(pAntiAlias);
View
4 src/org/andengine/opengl/texture/TextureOptions.java
@@ -40,7 +40,7 @@
public final int mMinFilter;
public final float mWrapT;
public final float mWrapS;
- public final boolean mPreMultipyAlpha;
+ public final boolean mPreMultiplyAlpha;
// ===========================================================
// Constructors
@@ -51,7 +51,7 @@ public TextureOptions(final int pMinFilter, final int pMagFilter, final int pWra
this.mMagFilter = pMagFilter;
this.mWrapT = pWrapT;
this.mWrapS = pWrapS;
- this.mPreMultipyAlpha = pPreMultiplyAlpha;
+ this.mPreMultiplyAlpha = pPreMultiplyAlpha;
}
// ===========================================================
View
2  src/org/andengine/opengl/texture/atlas/bitmap/BitmapTextureAtlas.java
@@ -140,7 +140,7 @@ protected void writeTextureToHardware(final GLState pGLState) {
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, glInternalFormat, this.mWidth, this.mHeight, 0, glFormat, glType, null);
- final boolean preMultipyAlpha = this.mTextureOptions.mPreMultipyAlpha;
+ final boolean preMultipyAlpha = this.mTextureOptions.mPreMultiplyAlpha;
/* Non alpha premultiplied bitmaps are loaded with ARGB_8888 and converted down manually. */
final Config bitmapConfig = (preMultipyAlpha) ? this.mBitmapTextureFormat.getBitmapConfig() : Config.ARGB_8888;
View
29 ...rg/andengine/opengl/texture/atlas/bitmap/source/decorator/ColorKeyBitmapTextureAtlasSourceDecorator.java
@@ -2,8 +2,7 @@
import org.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource;
import org.andengine.opengl.texture.atlas.bitmap.source.decorator.shape.IBitmapTextureAtlasSourceDecoratorShape;
-
-import android.graphics.Color;
+import org.andengine.util.color.Color;
/**
* (c) 2010 Nicolas Gramlich
@@ -25,25 +24,41 @@
// Constructors
// ===========================================================
- public ColorKeyBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColor) {
+ public ColorKeyBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final Color pColorKeyColor) {
super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor, Color.TRANSPARENT);
}
- public ColorKeyBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColor, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
+ public ColorKeyBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColor) {
+ super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor, Color.TRANSPARENT_ARGB_PACKED_INT);
+ }
+
+ public ColorKeyBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final Color pColorKeyColor, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor, Color.TRANSPARENT, pTextureAtlasSourceDecoratorOptions);
}
+
+ public ColorKeyBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColor, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
+ super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor, Color.TRANSPARENT_ARGB_PACKED_INT, pTextureAtlasSourceDecoratorOptions);
+ }
+ public ColorKeyBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final Color pColorKeyColor, final int pTolerance) {
+ super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor, pTolerance, Color.TRANSPARENT);
+ }
+
public ColorKeyBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColor, final int pTolerance) {
- super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor, Color.TRANSPARENT, pTolerance);
+ super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor, pTolerance, Color.TRANSPARENT_ARGB_PACKED_INT);
}
- public ColorKeyBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColor, final int pTolerance, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
+ public ColorKeyBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final Color pColorKeyColor, final int pTolerance, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor, pTolerance, Color.TRANSPARENT, pTextureAtlasSourceDecoratorOptions);
}
+
+ public ColorKeyBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColor, final int pTolerance, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
+ super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor, pTolerance, Color.TRANSPARENT_ARGB_PACKED_INT, pTextureAtlasSourceDecoratorOptions);
+ }
@Override
public ColorKeyBitmapTextureAtlasSourceDecorator deepCopy() {
- return new ColorKeyBitmapTextureAtlasSourceDecorator(this.mBitmapTextureAtlasSource, this.mBitmapTextureAtlasSourceDecoratorShape, this.mColorKeyColor, this.mTolerance, this.mTextureAtlasSourceDecoratorOptions);
+ return new ColorKeyBitmapTextureAtlasSourceDecorator(this.mBitmapTextureAtlasSource, this.mBitmapTextureAtlasSourceDecoratorShape, this.mColorKeyColorARGBPackedInt, this.mTolerance, this.mTextureAtlasSourceDecoratorOptions);
}
// ===========================================================
View
46 ...g/andengine/opengl/texture/atlas/bitmap/source/decorator/ColorSwapBitmapTextureAtlasSourceDecorator.java
@@ -2,6 +2,7 @@
import org.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource;
import org.andengine.opengl.texture.atlas.bitmap.source.decorator.shape.IBitmapTextureAtlasSourceDecoratorShape;
+import org.andengine.util.color.Color;
import android.graphics.AvoidXfermode;
import android.graphics.AvoidXfermode.Mode;
@@ -24,38 +25,55 @@
// Fields
// ===========================================================
- protected final int mColorKeyColor;
+ protected final int mColorKeyColorARGBPackedInt;
protected final int mTolerance;
- protected final int mColorSwapColor;
+ protected final int mColorSwapColorARGBPackedInt;
// ===========================================================
// Constructors
// ===========================================================
- public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColor, final int pColorSwapColor) {
- this(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor, TOLERANCE_DEFAULT, pColorSwapColor, null);
+ public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final Color pColorKeyColor, final Color pColorSwapColor) {
+ this(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor.getARGBPackedInt(), pColorSwapColor.getARGBPackedInt());
}
- public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColor, final int pColorSwapColor, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
- this(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor, TOLERANCE_DEFAULT, pColorSwapColor, pTextureAtlasSourceDecoratorOptions);
+ public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColorARGBPackedInt, final int pColorSwapColorARGBPackedInt) {
+ this(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColorARGBPackedInt, TOLERANCE_DEFAULT, pColorSwapColorARGBPackedInt, null);
}
- public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColor, final int pTolerance, final int pColorSwapColor) {
- this(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor, pTolerance, pColorSwapColor, null);
+ public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final Color pColorKeyColor, final Color pColorSwapColor, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
+ this(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor.getARGBPackedInt(), pColorSwapColor.getARGBPackedInt(), pTextureAtlasSourceDecoratorOptions);
}
- public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColor, final int pTolerance, final int pColorSwapColor, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
+ public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColorARGBPackedInt, final int pColorSwapColorARGBPackedInt, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
+ this(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColorARGBPackedInt, TOLERANCE_DEFAULT, pColorSwapColorARGBPackedInt, pTextureAtlasSourceDecoratorOptions);
+ }
+
+ public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final Color pColorKeyColor, final int pTolerance, final Color pColorSwapColor) {
+ this(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor.getARGBPackedInt(), pTolerance, pColorSwapColor.getARGBPackedInt());
+ }
+
+ public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColorARGBPackedInt, final int pTolerance, final int pColorSwapColorARGBPackedInt) {
+ this(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColorARGBPackedInt, pTolerance, pColorSwapColorARGBPackedInt, null);
+ }
+
+ public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final Color pColorKeyColor, final int pTolerance, final Color pColorSwapColor, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
+ this(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pColorKeyColor.getARGBPackedInt(), pTolerance, pColorSwapColor.getARGBPackedInt(), pTextureAtlasSourceDecoratorOptions);
+ }
+
+ public ColorSwapBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int pColorKeyColorARGBPackedInt, final int pTolerance, final int pColorSwapColorARGBPackedInt, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pTextureAtlasSourceDecoratorOptions);
- this.mColorKeyColor = pColorKeyColor;
+
+ this.mColorKeyColorARGBPackedInt = pColorKeyColorARGBPackedInt;
this.mTolerance = pTolerance;
- this.mColorSwapColor = pColorSwapColor;
- this.mPaint.setXfermode(new AvoidXfermode(pColorKeyColor, pTolerance, Mode.TARGET));
- this.mPaint.setColor(pColorSwapColor);
+ this.mColorSwapColorARGBPackedInt = pColorSwapColorARGBPackedInt;
+ this.mPaint.setXfermode(new AvoidXfermode(pColorKeyColorARGBPackedInt, pTolerance, Mode.TARGET));
+ this.mPaint.setColor(pColorSwapColorARGBPackedInt);
}
@Override
public ColorSwapBitmapTextureAtlasSourceDecorator deepCopy() {
- return new ColorSwapBitmapTextureAtlasSourceDecorator(this.mBitmapTextureAtlasSource, this.mBitmapTextureAtlasSourceDecoratorShape, this.mColorKeyColor, this.mTolerance, this.mColorSwapColor, this.mTextureAtlasSourceDecoratorOptions);
+ return new ColorSwapBitmapTextureAtlasSourceDecorator(this.mBitmapTextureAtlasSource, this.mBitmapTextureAtlasSourceDecoratorShape, this.mColorKeyColorARGBPackedInt, this.mTolerance, this.mColorSwapColorARGBPackedInt, this.mTextureAtlasSourceDecoratorOptions);
}
// ===========================================================
View
2  src/org/andengine/opengl/texture/bitmap/BitmapTexture.java
@@ -111,7 +111,7 @@ protected void writeTextureToHardware(final GLState pGLState) throws IOException
GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1);
}
- final boolean preMultipyAlpha = this.mTextureOptions.mPreMultipyAlpha;
+ final boolean preMultipyAlpha = this.mTextureOptions.mPreMultiplyAlpha;
if(preMultipyAlpha) {
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
} else {
View
94 src/org/andengine/util/color/Color.java
@@ -41,25 +41,35 @@
public static final Color PINK = new Color(1, 0, 1, 1);
public static final Color TRANSPARENT = new Color(0, 0, 0, 0);
- public static final float WHITE_PACKED = Color.WHITE.getABGRPackedFloat();
- public static final float BLACK_PACKED = Color.BLACK.getABGRPackedFloat();
- public static final float RED_PACKED = Color.RED.getABGRPackedFloat();
- public static final float YELLOW_PACKED = Color.YELLOW.getABGRPackedFloat();
- public static final float GREEN_PACKED = Color.GREEN.getABGRPackedFloat();
- public static final float CYAN_PACKED = Color.CYAN.getABGRPackedFloat();
- public static final float BLUE_PACKED = Color.BLUE.getABGRPackedFloat();
- public static final float PINK_PACKED = Color.PINK.getABGRPackedFloat();
- public static final float TRANSPARENT_PACKED = Color.TRANSPARENT.getABGRPackedFloat();
+ public static final int WHITE_ABGR_PACKED_INT = Color.WHITE.getABGRPackedInt();
+ public static final int BLACK_ABGR_PACKED_INT = Color.BLACK.getABGRPackedInt();
+ public static final int RED_ABGR_PACKED_INT = Color.RED.getABGRPackedInt();
+ public static final int YELLOW_ABGR_PACKED_INT = Color.YELLOW.getABGRPackedInt();
+ public static final int GREEN_ABGR_PACKED_INT = Color.GREEN.getABGRPackedInt();
+ public static final int CYAN_ABGR_PACKED_INT = Color.CYAN.getABGRPackedInt();
+ public static final int BLUE_ABGR_PACKED_INT = Color.BLUE.getABGRPackedInt();
+ public static final int PINK_ABGR_PACKED_INT = Color.PINK.getABGRPackedInt();
+ public static final int TRANSPARENT_ABGR_PACKED_INT = Color.TRANSPARENT.getABGRPackedInt();
+
+ public static final float WHITE_ABGR_PACKED_FLOAT = Color.WHITE.getABGRPackedFloat();
+ public static final float BLACK_ABGR_PACKED_FLOAT = Color.BLACK.getABGRPackedFloat();
+ public static final float RED_ABGR_PACKED_FLOAT = Color.RED.getABGRPackedFloat();
+ public static final float YELLOW_ABGR_PACKED_FLOAT = Color.YELLOW.getABGRPackedFloat();
+ public static final float GREEN_ABGR_PACKED_FLOAT = Color.GREEN.getABGRPackedFloat();
+ public static final float CYAN_ABGR_PACKED_FLOAT = Color.CYAN.getABGRPackedFloat();
+ public static final float BLUE_ABGR_PACKED_FLOAT = Color.BLUE.getABGRPackedFloat();
+ public static final float PINK_ABGR_PACKED_FLOAT = Color.PINK.getABGRPackedFloat();
+ public static final float TRANSPARENT_ABGR_PACKED_FLOAT = Color.TRANSPARENT.getABGRPackedFloat();
- public static final int WHITE_PACKED_INT = Color.WHITE.getABGRPacked();
- public static final int BLACK_PACKED_INT = Color.BLACK.getABGRPacked();
- public static final int RED_PACKED_INT = Color.RED.getABGRPacked();
- public static final int YELLOW_PACKED_INT = Color.YELLOW.getABGRPacked();
- public static final int GREEN_PACKED_INT = Color.GREEN.getABGRPacked();
- public static final int CYAN_PACKED_INT = Color.CYAN.getABGRPacked();
- public static final int BLUE_PACKED_INT = Color.BLUE.getABGRPacked();
- public static final int PINK_PACKED_INT = Color.PINK.getABGRPacked();
- public static final int TRANSPARENT_PACKED_INT = Color.TRANSPARENT.getABGRPacked();
+ public static final int WHITE_ARGB_PACKED_INT = Color.WHITE.getARGBPackedInt();
+ public static final int BLACK_ARGB_PACKED_INT = Color.BLACK.getARGBPackedInt();
+ public static final int RED_ARGB_PACKED_INT = Color.RED.getARGBPackedInt();
+ public static final int YELLOW_ARGB_PACKED_INT = Color.YELLOW.getARGBPackedInt();
+ public static final int GREEN_ARGB_PACKED_INT = Color.GREEN.getARGBPackedInt();
+ public static final int CYAN_ARGB_PACKED_INT = Color.CYAN.getARGBPackedInt();
+ public static final int BLUE_ARGB_PACKED_INT = Color.BLUE.getARGBPackedInt();
+ public static final int PINK_ARGB_PACKED_INT = Color.PINK.getARGBPackedInt();
+ public static final int TRANSPARENT_ARGB_PACKED_INT = Color.TRANSPARENT.getARGBPackedInt();
// ===========================================================
// Fields
@@ -70,7 +80,7 @@
private float mBlue;
private float mAlpha;
- private int mABGRPacked;
+ private int mABGRPackedInt;
private float mABGRPackedFloat;
// ===========================================================
@@ -221,26 +231,26 @@ public final void set(final Color pColor) {
this.mBlue = pColor.mBlue;
this.mAlpha = pColor.mAlpha;
- this.mABGRPacked = pColor.mABGRPacked;
+ this.mABGRPackedInt = pColor.mABGRPackedInt;
this.mABGRPackedFloat = pColor.mABGRPackedFloat;
}
public final boolean setChecking(final Color pColor) {
- if(this.mABGRPackedFloat != pColor.mABGRPackedFloat) {
+ if(this.mABGRPackedInt != pColor.mABGRPackedInt) {
this.mRed = pColor.mRed;
this.mGreen = pColor.mGreen;
this.mBlue = pColor.mBlue;
this.mAlpha = pColor.mAlpha;
- this.mABGRPacked = pColor.mABGRPacked;
+ this.mABGRPackedInt = pColor.mABGRPackedInt;
this.mABGRPackedFloat = pColor.mABGRPackedFloat;
return true;
}
return false;
}
- public final int getABGRPacked() {
- return this.mABGRPacked;
+ public final int getABGRPackedInt() {
+ return this.mABGRPackedInt;
}
public final float getABGRPackedFloat() {
@@ -250,8 +260,8 @@ public final float getABGRPackedFloat() {
/**
* @return the same format as {@link android.graphics.Color}.
*/
- public final int getARGBPacked() {
- return ((int)(255 * this.mAlpha) << Color.ARGB_PACKED_ALPHA_SHIFT) | ((int)(255 * this.mRed) << Color.ARGB_PACKED_RED_SHIFT) | ((int)(255 * this.mGreen) << Color.ARGB_PACKED_GREEN_SHIFT) | ((int)(255 * this.mBlue) << Color.ARGB_PACKED_BLUE_SHIFT);
+ public final int getARGBPackedInt() {
+ return ColorUtils.convertRGBAToARGBPackedInt(this.mRed, this.mGreen, this.mBlue, this.mAlpha);
}
public final void reset() {
@@ -264,7 +274,7 @@ public final void reset() {
@Override
public int hashCode() {
- return this.mABGRPacked;
+ return this.mABGRPackedInt;
}
@Override
@@ -300,40 +310,32 @@ public String toString() {
// ===========================================================
public boolean equals(final Color pColor) {
- return this.mABGRPacked == pColor.mABGRPacked;
+ return this.mABGRPackedInt == pColor.mABGRPackedInt;
}
private final void packABGRRed() {
- this.mABGRPacked = (this.mABGRPacked & Color.ABGR_PACKED_RED_CLEAR) | ((int)(255 * this.mRed) << Color.ABGR_PACKED_RED_CLEAR);
- this.mABGRPackedFloat = Float.intBitsToFloat(this.mABGRPacked & 0XFEFFFFFF);
+ this.mABGRPackedInt = (this.mABGRPackedInt & Color.ABGR_PACKED_RED_CLEAR) | ((int)(255 * this.mRed) << Color.ABGR_PACKED_RED_CLEAR);
+ this.mABGRPackedFloat = ColorUtils.convertPackedIntToPackedFloat(this.mABGRPackedInt);
}
private final void packABGRGreen() {
- this.mABGRPacked = (this.mABGRPacked & Color.ABGR_PACKED_GREEN_CLEAR) | ((int)(255 * this.mGreen) << Color.ABGR_PACKED_GREEN_CLEAR);
- this.mABGRPackedFloat = Float.intBitsToFloat(this.mABGRPacked & 0XFEFFFFFF);
+ this.mABGRPackedInt = (this.mABGRPackedInt & Color.ABGR_PACKED_GREEN_CLEAR) | ((int)(255 * this.mGreen) << Color.ABGR_PACKED_GREEN_CLEAR);
+ this.mABGRPackedFloat = ColorUtils.convertPackedIntToPackedFloat(this.mABGRPackedInt);
}
private final void packABGRBlue() {
- this.mABGRPacked = (this.mABGRPacked & Color.ABGR_PACKED_BLUE_CLEAR) | ((int)(255 * this.mBlue) << Color.ABGR_PACKED_BLUE_CLEAR);
- this.mABGRPackedFloat = Float.intBitsToFloat(this.mABGRPacked & 0XFEFFFFFF);
+ this.mABGRPackedInt = (this.mABGRPackedInt & Color.ABGR_PACKED_BLUE_CLEAR) | ((int)(255 * this.mBlue) << Color.ABGR_PACKED_BLUE_CLEAR);
+ this.mABGRPackedFloat = ColorUtils.convertPackedIntToPackedFloat(this.mABGRPackedInt);
}
private final void packABGRAlpha() {
- this.mABGRPacked = (this.mABGRPacked & Color.ABGR_PACKED_ALPHA_CLEAR) | ((int)(255 * this.mAlpha) << Color.ABGR_PACKED_ALPHA_SHIFT);
- this.mABGRPackedFloat = Float.intBitsToFloat(this.mABGRPacked & 0XFEFFFFFF);
+ this.mABGRPackedInt = (this.mABGRPackedInt & Color.ABGR_PACKED_ALPHA_CLEAR) | ((int)(255 * this.mAlpha) << Color.ABGR_PACKED_ALPHA_SHIFT);
+ this.mABGRPackedFloat = ColorUtils.convertPackedIntToPackedFloat(this.mABGRPackedInt);
}
private final void packABGR() {
- this.mABGRPacked = ((int)(255 * this.mAlpha) << Color.ABGR_PACKED_ALPHA_SHIFT) | ((int)(255 * this.mBlue) << Color.ABGR_PACKED_BLUE_SHIFT) | ((int)(255 * this.mGreen) << Color.ABGR_PACKED_GREEN_SHIFT) | ((int)(255 * this.mRed) << Color.ABGR_PACKED_RED_SHIFT);
- this.mABGRPackedFloat = Float.intBitsToFloat(this.mABGRPacked & 0XFEFFFFFF);
- }
-
- public static final int packABGR(final float pRed, final float pGreen, final float pBlue, final float pAlpha) {
- return ((int)(255 * pAlpha) << Color.ABGR_PACKED_ALPHA_SHIFT) | ((int)(255 * pBlue) << Color.ABGR_PACKED_BLUE_SHIFT) | ((int)(255 * pGreen) << Color.ABGR_PACKED_GREEN_SHIFT) | ((int)(255 * pRed) << Color.ABGR_PACKED_RED_SHIFT);
- }
-
- public static final float packABGRFloat(final float pRed, final float pGreen, final float pBlue, final float pAlpha) {
- return Float.intBitsToFloat(Color.packABGR(pRed, pGreen, pBlue, pAlpha) & 0XFEFFFFFF);
+ this.mABGRPackedInt = ColorUtils.convertRGBAToABGRPackedInt(this.mRed, this.mGreen, this.mBlue, this.mAlpha);
+ this.mABGRPackedFloat = ColorUtils.convertPackedIntToPackedFloat(this.mABGRPackedInt);
}
public final void mix(final Color pColorA, final float pPercentageA, final Color pColorB, final float pPercentageB) {
View
117 src/org/andengine/util/color/ColorUtils.java
@@ -1,9 +1,7 @@
package org.andengine.util.color;
-import android.graphics.Color;
-
/**
- * (c) 2010 Nicolas Gramlich
+ * (c) 2010 Nicolas Gramlich
* (c) 2011 Zynga Inc.
*
* @author Nicolas Gramlich
@@ -14,12 +12,10 @@
// Constants
// ===========================================================
- private static final float[] HSV_TO_COLOR = new float[3];
- private static final int HSV_TO_COLOR_HUE_INDEX = 0;
- private static final int HSV_TO_COLOR_SATURATION_INDEX = 1;
- private static final int HSV_TO_COLOR_VALUE_INDEX = 2;
-
- private static final int COLOR_FLOAT_TO_INT_FACTOR = 255;
+ public static final float[] HSV_TO_COLOR = new float[3];
+ public static final int HSV_TO_COLOR_HUE_INDEX = 0;
+ public static final int HSV_TO_COLOR_SATURATION_INDEX = 1;
+ public static final int HSV_TO_COLOR_VALUE_INDEX = 2;
// ===========================================================
// Fields
@@ -37,25 +33,106 @@
// Methods for/from SuperClass/Interfaces
// ===========================================================
+ // ===========================================================
+ // Methods
+ // ===========================================================
+
/**
* @param pHue [0 .. 360)
* @param pSaturation [0...1]
* @param pValue [0...1]
*/
- public static int HSVToColor(final float pHue, final float pSaturation, final float pValue) {
- HSV_TO_COLOR[HSV_TO_COLOR_HUE_INDEX] = pHue;
- HSV_TO_COLOR[HSV_TO_COLOR_SATURATION_INDEX] = pSaturation;
- HSV_TO_COLOR[HSV_TO_COLOR_VALUE_INDEX] = pValue;
- return Color.HSVToColor(HSV_TO_COLOR);
+ public static final int convertHSVToARGBPackedInt(final float pHue, final float pSaturation, final float pValue) {
+ ColorUtils.HSV_TO_COLOR[ColorUtils.HSV_TO_COLOR_HUE_INDEX] = pHue;
+ ColorUtils.HSV_TO_COLOR[ColorUtils.HSV_TO_COLOR_SATURATION_INDEX] = pSaturation;
+ ColorUtils.HSV_TO_COLOR[ColorUtils.HSV_TO_COLOR_VALUE_INDEX] = pValue;
+
+ return android.graphics.Color.HSVToColor(ColorUtils.HSV_TO_COLOR);
}
- public static int RGBToColor(final float pRed, final float pGreen, final float pBlue) {
- return Color.rgb((int)(pRed * COLOR_FLOAT_TO_INT_FACTOR), (int)(pGreen * COLOR_FLOAT_TO_INT_FACTOR), (int)(pBlue * COLOR_FLOAT_TO_INT_FACTOR));
+ /**
+ * @param pHue [0 .. 360)
+ * @param pSaturation [0...1]
+ * @param pValue [0...1]
+ */
+ public static final Color convertHSVToColor(final float pHue, final float pSaturation, final float pValue) {
+ return ColorUtils.convertARGBPackedIntToColor(ColorUtils.convertHSVToARGBPackedInt(pHue, pSaturation, pValue));
+ }
+
+
+ public static Color convertARGBPackedIntToColor(final int pARGBPackedInt) {
+ final float alpha = ColorUtils.extractAlphaFromARGBPackedInt(pARGBPackedInt);
+ final float red = ColorUtils.extractRedFromARGBPackedInt(pARGBPackedInt);
+ final float green = ColorUtils.extractGreenFromARGBPackedInt(pARGBPackedInt);
+ final float blue = ColorUtils.extractBlueFromARGBPackedInt(pARGBPackedInt);
+
+ return new Color(red, green, blue, alpha);
+ }
+
+ public static Color convertABGRPackedIntToColor(final int pABGRPackedInt) {
+ final float alpha = ColorUtils.extractAlphaFromABGRPackedInt(pABGRPackedInt);
+ final float blue = ColorUtils.extractBlueFromABGRPackedInt(pABGRPackedInt);
+ final float green = ColorUtils.extractGreenFromABGRPackedInt(pABGRPackedInt);
+ final float red = ColorUtils.extractRedFromABGRPackedInt(pABGRPackedInt);
+
+ return new Color(red, green, blue, alpha);
+ }
+
+
+ public static final int convertRGBAToARGBPackedInt(final float pRed, final float pGreen, final float pBlue, final float pAlpha) {
+ return ((int)(255 * pAlpha) << Color.ARGB_PACKED_ALPHA_SHIFT) | ((int)(255 * pRed) << Color.ARGB_PACKED_RED_SHIFT) | ((int)(255 * pGreen) << Color.ARGB_PACKED_GREEN_SHIFT) | ((int)(255 * pBlue) << Color.ARGB_PACKED_BLUE_SHIFT);
+ }
+
+ public static final float convertRGBAToARGBPackedFloat(final float pRed, final float pGreen, final float pBlue, final float pAlpha) {
+ return ColorUtils.convertPackedIntToPackedFloat(ColorUtils.convertRGBAToARGBPackedInt(pRed, pGreen, pBlue, pAlpha));
+ }
+
+ public static final int convertRGBAToABGRPackedInt(final float pRed, final float pGreen, final float pBlue, final float pAlpha) {
+ return ((int)(255 * pAlpha) << Color.ABGR_PACKED_ALPHA_SHIFT) | ((int)(255 * pBlue) << Color.ABGR_PACKED_BLUE_SHIFT) | ((int)(255 * pGreen) << Color.ABGR_PACKED_GREEN_SHIFT) | ((int)(255 * pRed) << Color.ABGR_PACKED_RED_SHIFT);
+ }
+
+ public static final float convertRGBAToABGRPackedFloat(final float pRed, final float pGreen, final float pBlue, final float pAlpha) {
+ return ColorUtils.convertPackedIntToPackedFloat(ColorUtils.convertRGBAToABGRPackedInt(pRed, pGreen, pBlue, pAlpha));
+ }
+
+
+ public static final float convertPackedIntToPackedFloat(final int pPackedInt) {
+ return Float.intBitsToFloat(pPackedInt & 0xFEFFFFFF);
+ }
+
+
+ public static float extractRedFromABGRPackedInt(final int pABGRPackedInt) {
+ return ((pABGRPackedInt >> Color.ABGR_PACKED_RED_SHIFT) & 0xFF) / 255.0f;
+ }
+
+ public static float extractGreenFromABGRPackedInt(final int pABGRPackedInt) {
+ return ((pABGRPackedInt >> Color.ABGR_PACKED_GREEN_SHIFT) & 0xFF) / 255.0f;
+ }
+
+ public static float extractBlueFromABGRPackedInt(final int pABGRPackedInt) {
+ return ((pABGRPackedInt >> Color.ABGR_PACKED_BLUE_SHIFT) & 0xFF) / 255.0f;
+ }
+
+ public static float extractAlphaFromABGRPackedInt(final int pABGRPackedInt) {
+ return ((pABGRPackedInt >> Color.ABGR_PACKED_ALPHA_SHIFT) & 0xFF) / 255.0f;
+ }
+
+
+ public static float extractBlueFromARGBPackedInt(final int pARGBPackedInt) {
+ return ((pARGBPackedInt >> Color.ARGB_PACKED_BLUE_SHIFT) & 0xFF) / 255.0f;
+ }
+
+ public static float extractGreenFromARGBPackedInt(final int pARGBPackedInt) {
+ return ((pARGBPackedInt >> Color.ARGB_PACKED_GREEN_SHIFT) & 0xFF) / 255.0f;
+ }
+
+ public static float extractRedFromARGBPackedInt(final int pARGBPackedInt) {
+ return ((pARGBPackedInt >> Color.ARGB_PACKED_RED_SHIFT) & 0xFF) / 255.0f;
+ }
+
+ public static float extractAlphaFromARGBPackedInt(final int pARGBPackedInt) {
+ return ((pARGBPackedInt >> Color.ARGB_PACKED_ALPHA_SHIFT) & 0xFF) / 255.0f;
}
-
- // ===========================================================
- // Methods
- // ===========================================================
// ===========================================================
// Inner and Anonymous Classes
Please sign in to comment.
Something went wrong with that request. Please try again.