// Create a new graphics resource with the specified color converted int outputGraphics = newGraphics( inputGraphics, // Original image fromRed, fromGreen, fromBlue, fromAlpha, // Color to convert (input by user) toRed, toGreen, toBlue, toAlpha // Replacement color (transparent) );