当前位置: 首页>>代码示例>>Java>>正文


Java Color.red方法代码示例

本文整理汇总了Java中android.graphics.Color.red方法的典型用法代码示例。如果您正苦于以下问题:Java Color.red方法的具体用法?Java Color.red怎么用?Java Color.red使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Color的用法示例。


在下文中一共展示了Color.red方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getColorInRange

import android.graphics.Color; //导入方法依赖的package包/类
int getColorInRange(int color, ColorPalette palette) {
    int i = 0;
    if (palette.isGrayscale) {
        i = palette.getNumberOfBits();
        int grayscale = (Color.red(color) + Color.green(color) + Color
                .blue(color)) / 3;
        color = Color.rgb(grayscale, grayscale, grayscale);
    } else
        i = palette.getNumberOfBits() / 3;

    int newR = (int) Math
            .round(((Color.red(color) >>> (8 - i)) * (255 / (Math.pow(2, i) - 1))));
    int newG = (int) Math
            .round(((Color.green(color) >>> (8 - i)) * (255 / (Math.pow(2, i) - 1))));
    int newB = (int) Math
            .round(((Color.blue(color) >>> (8 - i)) * (255 / (Math.pow(2, i) - 1))));
    return Color.rgb(newR, newG, newB);
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:19,代码来源:ColorDetectionShield.java

示例2: inColorToRGB

import android.graphics.Color; //导入方法依赖的package包/类
private int[] inColorToRGB(int color) {
    int[] rgb = new int[3];
    rgb[0] = Color.red(color);
    rgb[1] = Color.green(color);
    rgb[2] = Color.blue(color);
    return rgb;
}
 
开发者ID:lfnasc,项目名称:rgb2hexconverter,代码行数:8,代码来源:MainActivity.java

示例3: getImagePixels

import android.graphics.Color; //导入方法依赖的package包/类
protected void getImagePixels() {
    int w = this.image.getWidth();
    int h = this.image.getHeight();
    Bitmap localBitmap1 = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Canvas localCanvas = new Canvas(localBitmap1);
    localCanvas.save();
    Paint localPaint = new Paint();
    localCanvas.drawBitmap(image, postX, postY, localPaint);
    localCanvas.restore();

    this.pixels = new byte[w * h * 3];
    int[] arrayOfInt = new int[w * h];
    int k = 0;
    int l = 0;
    int i1 = w;
    localBitmap1.getPixels(arrayOfInt, 0, w, k, l, i1, h);
    int localObject = 0;
    while (true) {

        if (localObject >= arrayOfInt.length)
            return;
        pixels[localObject * 3] = (byte) Color.blue(arrayOfInt[localObject]);
        pixels[localObject * 3 + 1] = (byte) Color.green(arrayOfInt[localObject]);
        pixels[localObject * 3 + 2] = (byte) Color.red(arrayOfInt[localObject]);
        ++localObject;
    }
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:28,代码来源:AnimatedGifEncoder.java

示例4: getComplimentColor

import android.graphics.Color; //导入方法依赖的package包/类
/**
 * 从颜色得到另一个对比度高的颜色,其实就是给出黑白两种色,
 * 不过传入的颜色如果较暗,那就是白色,如果较亮那就是黑色
 * @param color
 * @return
 */
public static int getComplimentColor(@ColorInt int color) {
    // get existing colors
    int alpha = Color.alpha(color);
    int red = Color.red(color);
    int blue = Color.blue(color);
    int green = Color.green(color);

    // find compliments
    red = (~red) & 0xff;
    blue = (~blue) & 0xff;
    green = (~green) & 0xff;

    return Color.argb(alpha, red, green, blue);
}
 
开发者ID:halohoop,项目名称:AndroidDigIn,代码行数:21,代码来源:Utils.java

示例5: blendColors

import android.graphics.Color; //导入方法依赖的package包/类
/**
 * Blend {@code color1} and {@code color2} using the given ratio.
 *
 * @param ratio of which to blend. 1.0 will return {@code color1}, 0.5 will give an even blend,
 *              0.0 will return {@code color2}.
 */
private static int blendColors(int color1, int color2, float ratio) {
    final float inverseRation = 1f - ratio;
    float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
    float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
    float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
    return Color.rgb((int) r, (int) g, (int) b);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:SlidingTabStrip.java

示例6: blendColors

import android.graphics.Color; //导入方法依赖的package包/类
/**
 * Blend {@code color1} and {@code color2} using the given ratio.
 *
 * @param ratio of which to blend. 0.0 will return {@code color1}, 0.5 will give an even blend,
 *              1.0 will return {@code color2}.
 */
private static int blendColors(int color1, int color2, float ratio) {
    final float inverseRatio = 1f - ratio;
    float a = (Color.alpha(color1) * inverseRatio) + (Color.alpha(color2) * ratio);
    float r = (Color.red(color1) * inverseRatio) + (Color.red(color2) * ratio);
    float g = (Color.green(color1) * inverseRatio) + (Color.green(color2) * ratio);
    float b = (Color.blue(color1) * inverseRatio) + (Color.blue(color2) * ratio);
    return Color.argb((int) a, (int) r, (int) g, (int) b);
}
 
开发者ID:coopese,项目名称:qmui,代码行数:15,代码来源:QMUICollapsingTextHelper.java

示例7: setDarkColor

import android.graphics.Color; //导入方法依赖的package包/类
public static int setDarkColor(int color, int factor) {
    int alpha = Color.alpha(color);
    int red = Color.red(color) - factor;
    int green = Color.green(color) - factor;
    int blue = Color.blue(color) - factor;
    if (factor < 0) {
        red = (red > 0xff) ? 0xff : red;
        green = (green > 0xff) ? 0xff : green;
        blue = (blue > 0xff) ? 0xff : blue;
        if (red == 0xff && green == 0xff && blue == 0xff) {
            red = factor;
            green = factor;
            blue = factor;
        }
    }
    if (factor > 0) {
        red = (red < 0) ? 0 : red;
        green = (green < 0) ? 0 : green;
        blue = (blue < 0) ? 0 : blue;
        if (red == 0 && green == 0 && blue == 0) {
            red = factor;
            green = factor;
            blue = factor;
        }
    }
    //return Color.argb(0xff, red, green, blue);
    return Color.argb(alpha, red, green, blue);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:29,代码来源:AndroidUtilities.java

示例8: adjustAlpha

import android.graphics.Color; //导入方法依赖的package包/类
private int adjustAlpha(int color, boolean b) {
    int alpha = (b) ? Color.alpha(color) : 0xff;
    int red = Color.red(color);
    int green = Color.green(color);
    int blue = Color.blue(color);
    return Color.argb(alpha, red, green, blue);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:8,代码来源:ColorSelectorDialog.java

示例9: interpolateColor

import android.graphics.Color; //导入方法依赖的package包/类
public static int interpolateColor(int colorFrom, int colorTo, int posFrom, int posTo) {
    float delta = posTo - posFrom;
    int red = (int) ((Color.red(colorFrom) - Color.red(colorTo)) * delta / posTo + Color.red(colorTo));
    int green = (int) ((Color.green(colorFrom) - Color.green(colorTo)) * delta / posTo + Color.green(colorTo));
    int blue = (int) ((Color.blue(colorFrom) - Color.blue(colorTo)) * delta / posTo) + Color.blue(colorTo);
    return Color.argb(255, red, green, blue);
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:8,代码来源:ColorUtils.java

示例10: invertColor

import android.graphics.Color; //导入方法依赖的package包/类
@ColorInt
public static int invertColor(@ColorInt int color) {
    final int r = 255 - Color.red(color);
    final int g = 255 - Color.green(color);
    final int b = 255 - Color.blue(color);
    return Color.argb(Color.alpha(color), r, g, b);
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:8,代码来源:ColorUtil.java

示例11: translucentColor

import android.graphics.Color; //导入方法依赖的package包/类
@ColorInt private static int translucentColor(int color) {
    final float factor = 0.7f;
    int alpha = Math.round(Color.alpha(color) * factor);
    int red = Color.red(color);
    int green = Color.green(color);
    int blue = Color.blue(color);
    return Color.argb(alpha, red, green, blue);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:CircleView.java

示例12: calculateLuminance

import android.graphics.Color; //导入方法依赖的package包/类
/**
 * Returns the luminance of a color.
 *
 * Formula defined here: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
 */
private static double calculateLuminance(int color) {
    double red = Color.red(color) / 255d;
    red = red < 0.03928 ? red / 12.92 : Math.pow((red + 0.055) / 1.055, 2.4);

    double green = Color.green(color) / 255d;
    green = green < 0.03928 ? green / 12.92 : Math.pow((green + 0.055) / 1.055, 2.4);

    double blue = Color.blue(color) / 255d;
    blue = blue < 0.03928 ? blue / 12.92 : Math.pow((blue + 0.055) / 1.055, 2.4);

    return (0.2126 * red) + (0.7152 * green) + (0.0722 * blue);
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:18,代码来源:ColorUtils.java

示例13: getBlackWhiteColor

import android.graphics.Color; //导入方法依赖的package包/类
public static int getBlackWhiteColor(int color) {
    double darkness = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255;
    if (darkness >= 0.5) {
        return Color.WHITE;
    } else return Color.BLACK;
}
 
开发者ID:ceji-longquan,项目名称:ceji_android,代码行数:7,代码来源:CommonUtils.java

示例14: setRGBColor

import android.graphics.Color; //导入方法依赖的package包/类
public CallServiceRequest setRGBColor(int rgbColor) {
    this.rgbColor = new Integer[]{Color.red(rgbColor), Color.green(rgbColor), Color.blue(rgbColor)};
    return this;
}
 
开发者ID:axzae,项目名称:homeassist-builder,代码行数:5,代码来源:CallServiceRequest.java

示例15: emboss

import android.graphics.Color; //导入方法依赖的package包/类
/**
 * 浮雕效果处理
 *
 * @param bitmap 原图
 * @return 浮雕效果处理后的图片
 */
public static Bitmap emboss(Bitmap bitmap) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Bitmap newBitmap = Bitmap.createBitmap(width, height,
            Config.RGB_565);

    int pixR = 0;
    int pixG = 0;
    int pixB = 0;

    int pixColor = 0;

    int newR = 0;
    int newG = 0;
    int newB = 0;

    int[] pixels = new int[width * height];
    bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
    int pos = 0;
    for (int i = 1, length = height - 1; i < length; i++) {
        for (int k = 1, len = width - 1; k < len; k++) {
            pos = i * width + k;
            pixColor = pixels[pos];

            pixR = Color.red(pixColor);
            pixG = Color.green(pixColor);
            pixB = Color.blue(pixColor);

            pixColor = pixels[pos + 1];
            newR = Color.red(pixColor) - pixR + 127;
            newG = Color.green(pixColor) - pixG + 127;
            newB = Color.blue(pixColor) - pixB + 127;

            newR = Math.min(255, Math.max(0, newR));
            newG = Math.min(255, Math.max(0, newG));
            newB = Math.min(255, Math.max(0, newB));

            pixels[pos] = Color.argb(255, newR, newG, newB);
        }
    }

    newBitmap.setPixels(pixels, 0, width, 0, 0, width, height);
    return newBitmap;
}
 
开发者ID:youth5201314,项目名称:XFrame,代码行数:51,代码来源:XBitmapUtils.java


注:本文中的android.graphics.Color.red方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。