private void _process(TextureBuffer image, COMBINE_METHOD method) { int w = (int)mBuffer.getWidth(); int h = (int)mBuffer.getHeight(); uint rcolPercent = (uint)(mColour.r * 255.0f); uint gcolPercent = (uint)(mColour.g * 255.0f); uint bcolPercent = (uint)(mColour.b * 255.0f); switch (method) { case COMBINE_METHOD.METHOD_ADD_CLAMP: for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { ColourValue pxSrc = image.getPixel(x, y); ColourValue pxDst = mBuffer.getPixel(x, y); uint r = (uint)(pxDst.r * 255.0f) + (((uint)(pxSrc.r * 255.0f) * rcolPercent) >> 8); uint g = (uint)(pxDst.g * 255.0f) + (((uint)(pxSrc.g * 255.0f) * gcolPercent) >> 8); uint b = (uint)(pxDst.b * 255.0f) + (((uint)(pxSrc.b * 255.0f) * bcolPercent) >> 8); mBuffer.setPixel(x, y, (byte)((r < 255) ? r : 255), (byte)((g < 255) ? g : 255), (byte)((b < 255) ? b : 255), (byte)(pxDst.a * 255.0f)); } } break; case COMBINE_METHOD.METHOD_ADD_WRAP: for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { ColourValue pxSrc = image.getPixel(x, y); ColourValue pxDst = mBuffer.getPixel(x, y); uint r = (uint)(pxDst.r * 255.0f) + (((uint)(pxSrc.r * 255.0f) * rcolPercent) >> 8); uint g = (uint)(pxDst.g * 255.0f) + (((uint)(pxSrc.g * 255.0f) * gcolPercent) >> 8); uint b = (uint)(pxDst.b * 255.0f) + (((uint)(pxSrc.b * 255.0f) * bcolPercent) >> 8); mBuffer.setPixel(x, y, (byte)(r % 255), (byte)(g % 255), (byte)(b % 255), (byte)(pxDst.a * 255.0f)); } } break; case COMBINE_METHOD.METHOD_SUB_CLAMP: for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { ColourValue pxSrc = image.getPixel(x, y); ColourValue pxDst = mBuffer.getPixel(x, y); int r = (int)(pxDst.r * 255.0f) - (((int)(pxSrc.r * 255.0f) * (int)rcolPercent) >> 8); int g = (int)(pxDst.g * 255.0f) - (((int)(pxSrc.g * 255.0f) * (int)gcolPercent) >> 8); int b = (int)(pxDst.b * 255.0f) - (((int)(pxSrc.b * 255.0f) * (int)bcolPercent) >> 8); mBuffer.setPixel(x, y, (byte)((r > 0) ? r : 0), (byte)((g > 0) ? g : 0), (byte)((b > 0) ? b : 0), (byte)(pxDst.a * 255.0f)); } } break; case COMBINE_METHOD.METHOD_SUB_WRAP: for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { ColourValue pxSrc = image.getPixel(x, y); ColourValue pxDst = mBuffer.getPixel(x, y); int r = (int)(pxDst.r * 255.0f) - (((int)(pxSrc.r * 255.0f) * (int)rcolPercent) >> 8); int g = (int)(pxDst.g * 255.0f) - (((int)(pxSrc.g * 255.0f) * (int)gcolPercent) >> 8); int b = (int)(pxDst.b * 255.0f) - (((int)(pxSrc.b * 255.0f) * (int)bcolPercent) >> 8); mBuffer.setPixel(x, y, (byte)(r % 255), (byte)(g % 255), (byte)(b % 255), (byte)(pxDst.a * 255.0f)); } } break; case COMBINE_METHOD.METHOD_MULTIPLY: for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { ColourValue pxSrc = image.getPixel(x, y); ColourValue pxDst = mBuffer.getPixel(x, y); uint r = (uint)(pxDst.r * 255.0f) * (((uint)(pxSrc.r * 255.0f) * rcolPercent) >> 8); uint g = (uint)(pxDst.g * 255.0f) * (((uint)(pxSrc.g * 255.0f) * gcolPercent) >> 8); uint b = (uint)(pxDst.b * 255.0f) * (((uint)(pxSrc.b * 255.0f) * bcolPercent) >> 8); mBuffer.setPixel(x, y, (byte)(r >> 8), (byte)(g >> 8), (byte)(b >> 8), (byte)(pxDst.a * 255.0f)); } } break; case COMBINE_METHOD.METHOD_MULTIPLY2: for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { ColourValue pxSrc = image.getPixel(x, y); ColourValue pxDst = mBuffer.getPixel(x, y); uint r = (uint)(pxDst.r * 255.0f) * (((uint)(pxSrc.r * 255.0f) * rcolPercent) >> 8); r >>= 7; uint g = (uint)(pxDst.g * 255.0f) * (((uint)(pxSrc.g * 255.0f) * gcolPercent) >> 8); g >>= 7; uint b = (uint)(pxDst.b * 255.0f) * (((uint)(pxSrc.b * 255.0f) * bcolPercent) >> 8); b >>= 7; mBuffer.setPixel(x, y, (byte)((r < 255) ? r : 255), (byte)((g < 255) ? g : 255), (byte)((b < 255) ? b : 255), (byte)(pxDst.a * 255.0f)); } } break; case COMBINE_METHOD.METHOD_BLEND: for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { ColourValue pxSrc = image.getPixel(x, y); ColourValue pxDst = mBuffer.getPixel(x, y); uint r = (uint)(pxDst.r * 255.0f) + (((uint)(pxSrc.r * 255.0f) * rcolPercent) >> 8); uint g = (uint)(pxDst.g * 255.0f) + (((uint)(pxSrc.g * 255.0f) * gcolPercent) >> 8); uint b = (uint)(pxDst.b * 255.0f) + (((uint)(pxSrc.b * 255.0f) * bcolPercent) >> 8); mBuffer.setPixel(x, y, (byte)(r >> 1), (byte)(g >> 1), (byte)(b >> 1), (byte)(pxDst.a * 255.0f)); } } break; case COMBINE_METHOD.METHOD_ALPHA: for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { ColourValue pxSrc = image.getPixel(x, y); ColourValue pxDst = mBuffer.getPixel(x, y); uint a = (uint)(pxDst.a * 255.0f) + (((uint)(pxSrc.a * 255.0f) * bcolPercent) >> 8); mBuffer.setAlpha(x, y, (byte)(a >> 1)); } } break; default: //C++ TO C# CONVERTER TODO TASK: C# does not allow fall-through from a non-empty 'case': case COMBINE_METHOD.METHOD_LAYER: for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { ColourValue pxSrc = image.getPixel(x, y); ColourValue pxDst = mBuffer.getPixel(x, y); mBuffer.setPixel(x, y, (byte)(pxSrc.r * pxSrc.a * 255.0f + pxDst.r * 255.0f * (1.0f - pxSrc.a)), (byte)(pxSrc.g * pxSrc.a * 255.0f + pxDst.g * 255.0f * (1.0f - pxSrc.a)), (byte)(pxSrc.b * pxSrc.a * 255.0f + pxDst.b * 255.0f * (1.0f - pxSrc.a)), (byte)((pxDst.a - pxDst.a * pxSrc.a) * 255.0f + pxSrc.a * 255.0f)); } } break; } }